Sfoglia il codice sorgente

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

feature/souke
Guillaume Bourgeois 1 anno fa
parent
commit
835128ea17
7 ha cambiato i file con 143 aggiunte e 58 eliminazioni
  1. +1
    -0
      backend/controllers/DistributionController.php
  2. +15
    -15
      backend/views/distribution/index.php
  3. +53
    -40
      backend/web/css/screen.css
  4. +16
    -0
      backend/web/sass/distribution/_index.scss
  5. +46
    -0
      common/logic/Order/Order/Repository/OrderRepository.php
  6. +11
    -2
      common/logic/Order/Order/Service/OrderSolver.php
  7. +1
    -1
      common/logic/User/UserProducer/Service/UserProducerBuilder.php

+ 1
- 0
backend/controllers/DistributionController.php Vedi File

@@ -364,6 +364,7 @@ class DistributionController extends BackendController
'isCreditAutoPayment' => $orderManager->isCreditAutoPayment($order),
'isCreditContext' => $orderManager->isCreditContext($order),
'isPaid' => $orderManager->isOrderPaid($order),
'paymentLabelShort' => $orderManager->getPaymentLabelShort($order)
]);
}
}

+ 15
- 15
backend/views/distribution/index.php Vedi File

@@ -313,10 +313,10 @@ $this->setPageTitle('Distributions') ;
</div>
<div v-if="producer.credit && pointSaleActive">
<span class="title">Crédit</span>
<template v-if="pointSaleActive.credit">
<template v-if="pointSaleActive.credit && pointSaleActive.credit == 1">
<template v-if="pointSaleActive.credit_functioning == 'mandatory'">Obligatoire</template>
<template v-else-if="pointSaleActive.credit_functioning == 'user'">Basé sur l'utilisateur</template>
<template v-else-if="pointSaleActive.credit_functioning == 'optionnal'">Optionnel</template>
<template v-else-if="pointSaleActive.credit_functioning == 'optional'">Optionnel</template>
</template>
<template v-else>Désactivé</template>
</div>
@@ -333,7 +333,8 @@ $this->setPageTitle('Distributions') ;
<th class="column-user">Utilisateur</th>
<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 / crédit</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-payment"></th>
<th class="column-tiller" v-if="producer && producer.tiller">Tiller</th>
<th class="column-actions"></th>
@@ -370,7 +371,7 @@ $this->setPageTitle('Distributions') ;
<a class="btn btn-default btn-sm" :href="baseUrl+'/user/orders?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="Voir les commandes"><span class="glyphicon glyphicon-eye-open"></span></a>
</span>
</span>
<span v-else>{{ order.username }}</span>
<span v-else class="no-user">{{ order.username }}</span>
<span v-if="order.comment && order.comment.length > 0" class="glyphicon glyphicon-comment"></span>
<span v-if="order.delivery_home && order.delivery_address && order.delivery_address.length > 0" class="glyphicon glyphicon-home"></span>
</td>
@@ -381,16 +382,18 @@ $this->setPageTitle('Distributions') ;
</td>
<td class="column-amount">
{{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}

<div class="state-payment-mobile">
<order-state-payment :order="order" :producer="producer"></order-state-payment>
</div>
</td>
<td class="column-state-payment">
<order-state-payment :order="order" :producer="producer"></order-state-payment>

<template v-if="order.isCreditAutoPayment">
({{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }})
</td>
<td class="column-credit" v-if="!pointSaleActive || (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;€' }}
</a>
<span class="glyphicon glyphicon-time" title="Paiement automatique la veille de la distribution" v-if="order.auto_payment && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
</template>
</td>
@@ -588,11 +591,6 @@ $this->setPageTitle('Distributions') ;
</td>
</tr>
</template>
<!--<tr v-if="idActivePointSale > 0">
<td colspan="4"><strong>Total (TTC)</strong></td>
<td><strong>{{ totalActivePointSale() }}</strong></td>
<td colspan="3"></td>
</tr>-->
</tbody>
</table>
<div class="alert alert-warning" v-else>
@@ -605,8 +603,10 @@ $this->setPageTitle('Distributions') ;

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

<span class="label label-success" v-if="order.isPaid">&nbsp;</span>
<span class="label label-default" v-else>&nbsp;</span>
<span class="label label-success" v-if="order.isPaid" v-html="order.paymentLabelShort"></span>
<span class="label label-default" v-else 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="label label-success" v-if="order.amount_paid == order.amount">&nbsp;</span>
<span class="label label-default" v-else-if="order.amount_paid == 0">&nbsp;</span>-->

+ 53
- 40
backend/web/css/screen.css Vedi File

@@ -2264,11 +2264,16 @@ termes.
top: 1px;
right: 1px;
}
/* line 273, ../sass/distribution/_index.scss */
/* line 272, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-user .no-user {
color: gray;
font-style: italic;
}
/* line 278, ../sass/distribution/_index.scss */
.distribution-index #orders table td.tiller {
width: 60px;
}
/* line 276, ../sass/distribution/_index.scss */
/* line 281, ../sass/distribution/_index.scss */
.distribution-index #orders table td.tiller label {
font-size: 12px;
cursor: pointer;
@@ -2276,76 +2281,84 @@ termes.
top: -2px;
font-weight: normal;
}
/* line 285, ../sass/distribution/_index.scss */
/* line 290, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions {
position: relative;
text-align: right;
}
/* line 289, ../sass/distribution/_index.scss */
/* line 294, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .dropdown-menu {
top: 0px;
right: 0px;
}
/* line 294, ../sass/distribution/_index.scss */
/* line 299, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .modal-form-order,
.distribution-index #orders table td.column-actions .modal-payment {
text-align: left;
}
/* line 299, ../sass/distribution/_index.scss */
/* line 304, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .add-subscription {
position: relative;
}
/* line 302, ../sass/distribution/_index.scss */
/* line 307, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .add-subscription .glyphicon-plus {
position: absolute;
top: 4px;
right: 4px;
font-size: 7px;
}
/* line 311, ../sass/distribution/_index.scss */
/* line 316, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-state-payment {
width: 120px;
}
/* line 315, ../sass/distribution/_index.scss */
/* line 322, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-credit a.positive {
color: green;
}
/* line 325, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-credit a.negative {
color: red;
}
/* line 331, ../sass/distribution/_index.scss */
.distribution-index #orders table .state-payment-mobile {
display: none;
}
/* line 319, ../sass/distribution/_index.scss */
/* line 335, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-payment {
position: relative;
}
/* line 322, ../sass/distribution/_index.scss */
/* line 338, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-payment div.btn-group {
width: 125px;
}
/* line 328, ../sass/distribution/_index.scss */
/* line 344, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view ul {
list-style-type: none;
margin-left: 0px;
padding-left: 15px;
}
/* line 338, ../sass/distribution/_index.scss */
/* line 354, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view .comment {
margin-top: 20px;
}
/* line 342, ../sass/distribution/_index.scss */
/* line 358, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view .delivery {
margin-top: 20px;
}
/* line 351, ../sass/distribution/_index.scss */
/* line 367, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container {
width: 100%;
padding: 0px;
}
/* line 355, ../sass/distribution/_index.scss */
/* line 371, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-body {
padding-right: 15px;
}
/* line 358, ../sass/distribution/_index.scss */
/* line 374, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-body table {
margin-bottom: 150px;
}
/* line 363, ../sass/distribution/_index.scss */
/* line 379, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer {
border-top-color: #f4f4f4;
position: fixed;
@@ -2357,64 +2370,64 @@ termes.
text-align: center;
border-top: solid 1px #e0e0e0;
}
/* line 375, ../sass/distribution/_index.scss */
/* line 391, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer .actions-form button {
float: none;
}
/* line 379, ../sass/distribution/_index.scss */
/* line 395, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer .actions-form div.right {
float: right;
}
/* line 386, ../sass/distribution/_index.scss */
/* line 402, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .btn-credit {
float: right;
}
/* line 392, ../sass/distribution/_index.scss */
/* line 408, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products .product-ordered td {
background-color: #e9e9e9;
}
/* line 396, ../sass/distribution/_index.scss */
/* line 412, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products .product-ordered input.input-quantity {
font-size: 16px;
font-weight: bold;
}
/* line 402, ../sass/distribution/_index.scss */
/* line 418, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price {
width: 150px;
}
/* line 405, ../sass/distribution/_index.scss */
/* line 421, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price input {
text-align: center;
}
/* line 409, ../sass/distribution/_index.scss */
/* line 425, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price .input-group-addon {
background-color: #eee;
}
/* line 413, ../sass/distribution/_index.scss */
/* line 429, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price .invoice-price {
margin-top: 8px;
}
/* line 415, ../sass/distribution/_index.scss */
/* line 431, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price .invoice-price .label-invoice-price {
font-size: 11px;
font-weight: bold;
color: gray;
}
/* line 423, ../sass/distribution/_index.scss */
/* line 439, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity {
width: 165px;
}
/* line 426, ../sass/distribution/_index.scss */
/* line 442, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity input {
text-align: center;
color: black;
}
/* line 431, ../sass/distribution/_index.scss */
/* line 447, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .form-control {
border-right: 0px none;
padding-right: 4px;
}
/* line 436, ../sass/distribution/_index.scss */
/* line 452, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .input-group-addon {
padding: 5px;
padding-left: 0px;
@@ -2422,35 +2435,35 @@ termes.
border-left: 0px none;
border-right: 0px none;
}
/* line 445, ../sass/distribution/_index.scss */
/* line 461, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining {
text-align: right;
}
/* line 448, ../sass/distribution/_index.scss */
/* line 464, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.quantity-remaining, .distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite {
color: #00A65A;
}
/* line 452, ../sass/distribution/_index.scss */
/* line 468, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.negative {
color: #DD4B39;
}
/* line 456, ../sass/distribution/_index.scss */
/* line 472, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite, .distribution-index .modal-form-order table.table-products td.quantity-remaining.empty {
font-size: 18px;
}
/* line 463, ../sass/distribution/_index.scss */
/* line 479, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .actions-form button {
margin-left: 15px;
}
/* line 471, ../sass/distribution/_index.scss */
/* line 487, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon {
width: 50px;
}
/* line 474, ../sass/distribution/_index.scss */
/* line 490, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon i {
font-size: 30px;
}
/* line 479, ../sass/distribution/_index.scss */
/* line 495, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-content {
margin-left: 50px;
}

+ 16
- 0
backend/web/sass/distribution/_index.scss Vedi File

@@ -268,6 +268,11 @@ termes.
top: 1px;
right: 1px;
}

.no-user {
color: gray;
font-style: italic;
}
}

td.tiller {
@@ -312,6 +317,17 @@ termes.
width: 120px;
}

td.column-credit {
a {
&.positive {
color: green;
}
&.negative {
color: red;
}
}
}

.state-payment-mobile {
display: none;
}

+ 46
- 0
common/logic/Order/Order/Repository/OrderRepository.php Vedi File

@@ -14,6 +14,8 @@ use common\logic\Document\Invoice\Service\InvoiceSolver;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Service\OrderSolver;
use common\logic\Order\ProductOrder\Repository\ProductOrderRepository;
use common\logic\Payment\Model\Payment;
use common\logic\Payment\Service\PaymentSolver;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\PointSale\PointSale\Repository\PointSaleRepository;
use common\logic\PointSale\UserPointSale\Repository\UserPointSaleRepository;
@@ -38,6 +40,7 @@ class OrderRepository extends AbstractRepository
protected UserPointSaleRepository $userPointSaleRepository;
protected InvoiceRepository $invoiceRepository;
protected InvoiceSolver $invoiceSolver;
protected PaymentSolver $paymentSolver;

public function loadDependencies(): void
{
@@ -53,6 +56,7 @@ class OrderRepository extends AbstractRepository
$this->userPointSaleRepository = $this->loadService(UserPointSaleRepository::class);
$this->invoiceRepository = $this->loadService(InvoiceRepository::class);
$this->invoiceSolver = $this->loadService(InvoiceSolver::class);
$this->paymentSolver = $this->loadService(PaymentSolver::class);
}

public function getDefaultOptionsSearch(): array
@@ -450,4 +454,46 @@ class OrderRepository extends AbstractRepository

return false;
}

public function getMainPayment(Order $order): ?Payment
{
foreach($order->payment as $payment) {
if($this->paymentSolver->isTypeDebit($payment)) {
return $payment;
}
}

return null;
}

public function getPaymentLabelShort(Order $order): string
{
$isOrderPaid = $this->isOrderPaid($order);
$amountPaid = $this->orderSolver->getOrderAmountPaid($order);

if(!$amountPaid) {
if($isOrderPaid) {
return 'Facture payée';
}
elseif($this->isCreditAutoPayment($order)) {
return 'Crédit non débité';
}
else {
return 'Non réglé';
}
}
else {
$mainPayment = $this->getMainPayment($order);
if($mainPayment) {
if($this->paymentSolver->isMeanPaymentCredit($mainPayment)) {
return 'Crédit débité';
}
else {
return MeanPayment::getStrBy($mainPayment->mean_payment);
}
}
}

return '&nbsp;';
}
}

+ 11
- 2
common/logic/Order/Order/Service/OrderSolver.php Vedi File

@@ -330,10 +330,20 @@ class OrderSolver extends AbstractService implements SolverInterface
}
}

public function getOrderAmountPaid(Order $order): float
{
$amount = 0;

foreach($order->payment as $payment) {
$amount += $payment->amount;
}

return $amount;
}

/**
* Retourne le montant de la commande (total, payé, restant, ou en surplus).
*/
// getAmount
public function getOrderAmount(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false)
{
$amount = $order->amount;
@@ -344,7 +354,6 @@ class OrderSolver extends AbstractService implements SolverInterface
return $this->_getAmountGeneric($order, $type, $amount, $format);
}

// getAmountWithTax
public function getOrderAmountWithTax(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false)
{
$amount = $order->amount + $this->getOrderTotalVat($order, $type);

+ 1
- 1
common/logic/User/UserProducer/Service/UserProducerBuilder.php Vedi File

@@ -71,7 +71,7 @@ class UserProducerBuilder extends AbstractBuilder
$oldCredit = $userProducer->getCredit();

$this->deductCredit($userProducer, $payment);
$this->initMeanPaymentOrder($payment);
//$this->initMeanPaymentOrder($payment);
$this->sendCreditLimitReminder($userProducer, $payment, $oldCredit);
}
}

Loading…
Annulla
Salva