Browse Source

Système compte prépayés

feature/export_comptable
Fab 4 years ago
parent
commit
8de3339228
8 changed files with 267 additions and 112 deletions
  1. +7
    -0
      ShopBundle/Context/PayoffInterface.php
  2. +63
    -0
      ShopBundle/Form/Backend/UserMerchant/CreditHistoryType.php
  3. +30
    -19
      ShopBundle/Model/CreditHistory.php
  4. +2
    -93
      ShopBundle/Model/OrderPayoffTrait.php
  5. +106
    -0
      ShopBundle/Model/PayoffTrait.php
  6. +29
    -0
      ShopBundle/Resources/views/backend/usermerchant/modal_addcredithistory.html.twig
  7. +12
    -0
      ShopBundle/Resources/views/backend/usermerchant/new.html.twig
  8. +18
    -0
      ShopBundle/Resources/views/backend/usermerchant/show.html.twig

+ 7
- 0
ShopBundle/Context/PayoffInterface.php View File

@@ -0,0 +1,7 @@
<?php

namespace Lc\ShopBundle\Context;

interface PayoffInterface
{
}

+ 63
- 0
ShopBundle/Form/Backend/UserMerchant/CreditHistoryType.php View File

@@ -0,0 +1,63 @@
<?php

namespace Lc\ShopBundle\Form\Backend\Order;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class CreditHistoryType extends AbstractType
{
protected $em;


public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$entity = $options['data'];

$reductionCreditClass = $this->em->getClassMetadata(ReductionCreditInterface::class);
$reductionCreditRepo = $this->em->getRepository(ReductionCreditInterface::class);;

$builder
->add('reductionCredit', EntityType::class, array(
'class' => $reductionCreditClass->getName(),
'choices' => $reductionCreditRepo->findReductionCreditsByUser($entity->getUser()),
//'choices' => $this->orderUtils->getReductionCreditsAvailable($entity),

'required' => true,
'mapped'=>false
));
$builder->add('add', ButtonType::class, array(
'label' => 'action.add'
));


}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(),
]);
}
}

+ 30
- 19
ShopBundle/Model/CreditHistory.php View File

@@ -8,27 +8,28 @@ use App\Entity\UserMerchant;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\OrderRefundInterface;
use Lc\ShopBundle\Context\PayoffInterface;
use Lc\ShopBundle\Context\UserMerchantInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class CreditHistory extends AbstractEntity
abstract class CreditHistory extends AbstractEntity implements PayoffInterface
{
use PayoffTrait;

const TYPE_CREDIT = 'credit';
const TYPE_DEBIT = 'debit';

/**
* @ORM\Column(type="float")
* @ORM\Column(type="float", nullable=true)
*/
protected $amount;

/**
* @ORM\Column(type="string", length=31)
*/
protected $meanPayment;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $comment;
protected $type;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserMerchantInterface", inversedBy="creditHistories")
@@ -52,33 +53,43 @@ abstract class CreditHistory extends AbstractEntity
return $this->amount;
}

public function setAmount(float $amount): self
public function setAmount(?float $amount): self
{
$this->amount = $amount;

return $this;
}

public function getMeanPayment(): ?string
public function getAmountInherited(): float
{
return $this->meanPayment;
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getAmount();
} else if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getAmount();
} else {
return $this->getAmount();
}
}

public function setMeanPayment(string $meanPayment): self
public function getMeanPaymentInherited(): string
{
$this->meanPayment = $meanPayment;

return $this;
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getMeanPayment();
} else if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getMeanPayment();
} else {
return $this->getMeanPayment();
}
}

public function getComment(): ?string
public function getType(): ?string
{
return $this->comment;
return $this->type;
}

public function setComment(string $comment): self
public function setType(string $meanPayment): self
{
$this->comment = $comment;
$this->meanPayment = $meanPayment;

return $this;
}

+ 2
- 93
ShopBundle/Model/OrderPayoffTrait.php View File

@@ -12,47 +12,19 @@ use Lc\ShopBundle\Context\ReductionInterface;
trait OrderPayoffTrait
{

use PayoffTrait;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderPayments")
* @ORM\JoinColumn(nullable=false)
*/
protected $orderShop;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $meanPayment;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $reference;

/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $paidAt;

/**
* @ORM\Column(type="float")
*/
protected $amount;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $comment;

/**
* @ORM\Column(type="boolean")
*/
protected $editable;

public function __toString()
{
return $this->amount. '€ par '.$this->type.' le '.$this->getPaidAt()->format('d-m-Y');
}

public function getOrderShop(): ?OrderShop
{
return $this->orderShop;
@@ -65,69 +37,6 @@ trait OrderPayoffTrait
return $this;
}

public function setMeanPayment(?string $meanPayment): self
{
$this->meanPayment = $meanPayment;

return $this;
}

public function getMeanPayment(?string $meanPayment): self
{
$this->meanPayment = $meanPayment;

return $this;
}


public function getReference(): ?string
{
return $this->reference;
}

public function setReference(?string $reference): self
{
$this->reference = $reference;

return $this;
}

public function getPaidAt(): ?\DateTimeInterface
{
return $this->paidAt;
}

public function setPaidAt(?\DateTimeInterface $paidAt): self
{
$this->paidAt = $paidAt;

return $this;
}

public function getAmount(): ?float
{
return $this->amount;
}

public function setAmount(float $amount): self
{
$this->amount = $amount;

return $this;
}

public function getComment(): ?string
{
return $this->comment;
}

public function setComment(?string $comment): self
{
$this->comment = $comment;

return $this;
}

public function setEditable(bool $editable): self
{
$this->editable = $editable;

+ 106
- 0
ShopBundle/Model/PayoffTrait.php View File

@@ -0,0 +1,106 @@
<?php

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\ReductionInterface;

/**
* @ORM\MappedSuperclass()
*/
trait PayoffTrait
{

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $meanPayment;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $reference;

/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $paidAt;

/**
* @ORM\Column(type="float")
*/
protected $amount;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $comment;



public function setMeanPayment(?string $meanPayment): self
{
$this->meanPayment = $meanPayment;

return $this;
}

public function getMeanPayment(?string $meanPayment): self
{
$this->meanPayment = $meanPayment;

return $this;
}


public function getReference(): ?string
{
return $this->reference;
}

public function setReference(?string $reference): self
{
$this->reference = $reference;

return $this;
}

public function getPaidAt(): ?\DateTimeInterface
{
return $this->paidAt;
}

public function setPaidAt(?\DateTimeInterface $paidAt): self
{
$this->paidAt = $paidAt;

return $this;
}

public function getAmount(): ?float
{
return $this->amount;
}

public function setAmount(float $amount): self
{
$this->amount = $amount;

return $this;
}

public function getComment(): ?string
{
return $this->comment;
}

public function setComment(?string $comment): self
{
$this->comment = $comment;

return $this;
}


}

+ 29
- 0
ShopBundle/Resources/views/backend/usermerchant/modal_addcredithistory.html.twig View File

@@ -0,0 +1,29 @@
{% trans_default_domain 'lcshop' %}

<div class="modal fade show" id="modal-add-reduction-cart">
{{ form_start(form_add_order_reduction_cart, {'attr': { 'id' : 'addOrderReductionCartForm'}}) }}
{% form_theme form_add_order_reduction_cart '@LcShop/backend/form/custom_bootstrap_4.html.twig' %}
<div class="modal-dialog">

<div class="modal-content">
<div class="modal-header">
<h4>{{ "action.order.addReductionCart"|trans }}</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="col">
{{ form_row(form_add_order_reduction_cart.reductionCart) }}
</div>

</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
{{ form_row(form_add_order_reduction_cart.add, {"attr": {'class' : 'btn btn-primary', '@click': 'addOrderReductionCart'}}) }}
</div>
</div>
<!-- /.modal-content -->
</div>
{{ form_end(form_add_order_reduction_cart) }}
</div>

+ 12
- 0
ShopBundle/Resources/views/backend/usermerchant/new.html.twig View File

@@ -0,0 +1,12 @@
{% extends '@LcShop/backend/default/new.html.twig' %}


{% block entity_form %}
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
{{ macros.startCard(8, 'UserMerchant.selectUser') }}
<div class="col-12">
{{ form(form) }}
</div>
{{ macros.endCard() }}
{% endblock entity_form %}


+ 18
- 0
ShopBundle/Resources/views/backend/usermerchant/show.html.twig View File

@@ -0,0 +1,18 @@
{% extends '@LcShop/backend/default/show.html.twig' %}

{% block main %}
{% for creditHistory in entity.creditHistories %}
<li>{{ creditHistory.amount }}</li>

{% else %}
<li><i>Aucun mouvement pour ce compte prépayé</i></li>
{% endfor %}

<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-add-credit-hitory">
{{ "action.addCreditHistory"|trans }}
</button>


{% endblock main %}



Loading…
Cancel
Save