Procházet zdrojové kódy

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

feature/souke
Guillaume Bourgeois před 1 rokem
rodič
revize
e89c875524
4 změnil soubory, kde provedl 80 přidání a 22 odebrání
  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 Zobrazit soubor

@@ -377,7 +377,9 @@ class DistributionController extends BackendController
'isCreditContext' => $orderManager->isCreditContext($order),
'isPaid' => $orderManager->isOrderPaid($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 Zobrazit soubor

@@ -337,7 +337,7 @@ $this->setPageTitle('Distributions') ;
<th class="column-point-sale" v-if="idActivePointSale == 0">Point de vente</th>
<th class="column-amount">Montant</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-tiller" v-if="producer && producer.tiller">Tiller</th>
</tr>
@@ -388,10 +388,12 @@ $this->setPageTitle('Distributions') ;
</div>
</td>
<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>
</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">
<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;€' }}
@@ -440,21 +442,23 @@ $this->setPageTitle('Distributions') ;
<span class="glyphicon glyphicon-piggy-bank"></span> {{ getLabelPaymentRefund(order, 'Débiter', 'Recréditer', 'le crédit') }}
</a>
</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>
<!--<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="credit-card">
@@ -639,6 +643,7 @@ $this->setPageTitle('Distributions') ;

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


<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>-->

+ 52
- 2
common/logic/Order/Order/Repository/OrderRepository.php Zobrazit soubor

@@ -520,14 +520,22 @@ class OrderRepository extends AbstractRepository
{
$isOrderPaid = $this->isOrderPaid($order);
$amountPaid = $this->orderSolver->getOrderAmountPaid($order);
$amountTotal = $this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL);
$label = '&nbsp;';
$classLabel = 'default';
$titleLabel = '';

if(!$amountPaid) {
if($isOrderPaid) {
$label = 'Facture payée';
}
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 {
$label = 'Non réglé';
@@ -545,6 +553,48 @@ class OrderRepository extends AbstractRepository
}
}

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 Zobrazit soubor

@@ -9,6 +9,8 @@ use common\logic\Document\Document\Service\DocumentSolver;
use common\logic\Order\Order\Model\Order;
use common\logic\Payment\Model\Payment;
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\Product\Product\Model\Product;
use common\logic\SolverInterface;
@@ -474,5 +476,4 @@ class OrderSolver extends AbstractService implements SolverInterface

return $str;
}

}

Načítá se…
Zrušit
Uložit