Browse Source

[Administration] Documents > Factures : gestion des paiements #1219

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
e89c875524
4 changed files with 80 additions and 22 deletions
  1. +3
    -1
      backend/controllers/DistributionController.php
  2. +23
    -18
      backend/views/distribution/index.php
  3. +52
    -2
      common/logic/Order/Order/Repository/OrderRepository.php
  4. +2
    -1
      common/logic/Order/Order/Service/OrderSolver.php

+ 3
- 1
backend/controllers/DistributionController.php View File

'isCreditContext' => $orderManager->isCreditContext($order), 'isCreditContext' => $orderManager->isCreditContext($order),
'isPaid' => $orderManager->isOrderPaid($order), 'isPaid' => $orderManager->isOrderPaid($order),
'isPaidViaInvoice' => $orderManager->isOrderPaidViaInvoice($order), 'isPaidViaInvoice' => $orderManager->isOrderPaidViaInvoice($order),
'paymentLabelShort' => $orderManager->getPaymentLabelShort($order)
'paymentLabelShort' => $orderManager->getPaymentLabelShort($order),
'isCreditFunctioningMandatory' => $orderManager->isOrderCreditFunctioningMandatory($order),
'isCreditFunctioningUser' => $orderManager->isOrderCreditFunctioningUser($order),
]); ]);
} }
} }

+ 23
- 18
backend/views/distribution/index.php View File

<th class="column-point-sale" v-if="idActivePointSale == 0">Point de vente</th> <th class="column-point-sale" v-if="idActivePointSale == 0">Point de vente</th>
<th class="column-amount">Montant</th> <th class="column-amount">Montant</th>
<th class="column-state-payment">Paiement</th> <th class="column-state-payment">Paiement</th>
<th class="column-credit" v-if="!pointSaleActive || (pointSaleActive && pointSaleActive.credit == 1)">Crédit</th>
<th class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)">Crédit</th>
<th class="column-actions">Actions</th> <th class="column-actions">Actions</th>
<th class="column-tiller" v-if="producer && producer.tiller">Tiller</th> <th class="column-tiller" v-if="producer && producer.tiller">Tiller</th>
</tr> </tr>
</div> </div>
</td> </td>
<td class="column-state-payment"> <td class="column-state-payment">
<order-state-payment :order="order" :producer="producer"></order-state-payment>
<a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">
<order-state-payment :order="order" :producer="producer"></order-state-payment>
</a>
<span class="glyphicon glyphicon-time" title="Débit automatique du crédit la veille de la distribution" v-if="order.auto_payment && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span> <span class="glyphicon glyphicon-time" title="Débit automatique du crédit la veille de la distribution" v-if="order.auto_payment && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
</td> </td>
<td class="column-credit" v-if="!pointSaleActive || (pointSaleActive && pointSaleActive.credit == 1)">
<td class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)">
<template v-if="order.isCreditContext"> <template v-if="order.isCreditContext">
<a :href="baseUrl+'/user/credit?id='+order.id_user" :class="order.user.credit >= 0 ? 'positive' : 'negative'"> <a :href="baseUrl+'/user/credit?id='+order.id_user" :class="order.user.credit >= 0 ? 'positive' : 'negative'">
{{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }} {{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}
<span class="glyphicon glyphicon-piggy-bank"></span> {{ getLabelPaymentRefund(order, 'Débiter', 'Recréditer', 'le crédit') }} <span class="glyphicon glyphicon-piggy-bank"></span> {{ getLabelPaymentRefund(order, 'Débiter', 'Recréditer', 'le crédit') }}
</a> </a>
</li> </li>
<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="money">
<span class="glyphicon glyphicon-euro"></span> {{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'en espèce') }}
</a>
</li>
<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="cheque">
<span class="glyphicon glyphicon-euro"></span> {{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'par chèque') }}
</a>
</li>
<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="transfer">
<span class="glyphicon glyphicon-euro"></span> {{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'par virement') }}
</a>
</li>
<template v-if="(!order.isCreditFunctioningMandatory && !order.isCreditFunctioningUser) || !order.id_user">
<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="money">
<span class="glyphicon glyphicon-euro"></span> {{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'en espèce') }}
</a>
</li>
<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="cheque">
<span class="glyphicon glyphicon-euro"></span> {{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'par chèque') }}
</a>
</li>
<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="transfer">
<span class="glyphicon glyphicon-euro"></span> {{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'par virement') }}
</a>
</li>
</template>
</template> </template>
<!--<li> <!--<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="credit-card"> <a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="credit-card">


<script type="text/x-template" id="order-state-payment"> <script type="text/x-template" id="order-state-payment">



<span v-html="order.paymentLabelShort"></span> <span v-html="order.paymentLabelShort"></span>


<!--<span class="glyphicon glyphicon-signal" title="Paiement partiel ou surplus" v-if="order.amount_paid > order.amount || order.amount_paid < order.amount"></span>--> <!--<span class="glyphicon glyphicon-signal" title="Paiement partiel ou surplus" v-if="order.amount_paid > order.amount || order.amount_paid < order.amount"></span>-->

+ 52
- 2
common/logic/Order/Order/Repository/OrderRepository.php View File

{ {
$isOrderPaid = $this->isOrderPaid($order); $isOrderPaid = $this->isOrderPaid($order);
$amountPaid = $this->orderSolver->getOrderAmountPaid($order); $amountPaid = $this->orderSolver->getOrderAmountPaid($order);
$amountTotal = $this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL);
$label = '&nbsp;'; $label = '&nbsp;';
$classLabel = 'default';
$titleLabel = '';


if(!$amountPaid) { if(!$amountPaid) {
if($isOrderPaid) { if($isOrderPaid) {
$label = 'Facture payée'; $label = 'Facture payée';
} }
elseif($this->isCreditAutoPayment($order)) { elseif($this->isCreditAutoPayment($order)) {
$label = 'Crédit non débité';
if($order->subscription && $order->subscription->auto_payment == 0) {
$label = 'Crédit désactivé';
}
else {
$label = 'Crédit non débité';
}
} }
else { else {
$label = 'Non réglé'; $label = 'Non réglé';
} }
} }


return '<span class="label label-'.($isOrderPaid ? 'success' : 'default').'">'.$label.'</span>';
$orderPaymentStatus = $this->orderSolver->getPaymentStatus($order);
if($amountPaid == 0) {
$classLabel = 'default';
}
elseif($orderPaymentStatus == Order::PAYMENT_UNPAID) {
$classLabel = 'warning';
$titleLabel = 'Paiement partiel';
}
elseif($orderPaymentStatus == Order::PAYMENT_SURPLUS) {
$classLabel = 'warning';
$titleLabel = 'Paiement en surplus';
}
elseif($isOrderPaid) {
$classLabel = 'success';
}


return '<span class="label label-'.$classLabel.'" title="'.$titleLabel.'">'.$label.'</span>';
}

public function isOrderCreditFunctioningMandatory(Order $order): bool
{
$pointSale = $order->pointSale;
return $pointSale && $pointSale->credit && $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY;
}

public function isOrderCreditFunctioningUser(Order $order): bool
{
if($order->user) {

$pointSale = $order->pointSale;

// @TODO : à optimiser
$userProducer = $this->userProducerRepository->findOneUserProducer($order->user);

return $pointSale
&& $pointSale->credit
&& $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_USER
&& $userProducer
&& $userProducer->credit_active;
}

return false;
} }
} }

+ 2
- 1
common/logic/Order/Order/Service/OrderSolver.php View File

use common\logic\Order\Order\Model\Order; use common\logic\Order\Order\Model\Order;
use common\logic\Payment\Model\Payment; use common\logic\Payment\Model\Payment;
use common\logic\Payment\Service\PaymentSolver; use common\logic\Payment\Service\PaymentSolver;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Service\ProducerSolver; use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\Product\Product\Model\Product; use common\logic\Product\Product\Model\Product;
use common\logic\SolverInterface; use common\logic\SolverInterface;


return $str; return $str;
} }

} }

Loading…
Cancel
Save