Quellcode durchsuchen

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

feature/souke
Guillaume Bourgeois vor 1 Jahr
Ursprung
Commit
5111f783e6
20 geänderte Dateien mit 310 neuen und 149 gelöschten Zeilen
  1. +8
    -2
      backend/controllers/DistributionController.php
  2. +13
    -2
      backend/controllers/DocumentController.php
  3. +1
    -1
      backend/controllers/ProducerController.php
  4. +96
    -67
      backend/views/distribution/index.php
  5. +15
    -6
      backend/views/document/_form.php
  6. +16
    -5
      backend/views/invoice/index.php
  7. +53
    -45
      backend/web/css/screen.css
  8. +17
    -0
      backend/web/js/vuejs/distribution-index.js
  9. +1
    -1
      backend/web/sass/_adminlte.scss
  10. +11
    -3
      backend/web/sass/distribution/_index.scss
  11. +1
    -1
      common/config/params.php
  12. +22
    -8
      common/logic/Order/Order/Repository/OrderRepository.php
  13. +1
    -2
      common/logic/Order/Order/Service/OrderBuilder.php
  14. +2
    -1
      common/logic/Order/ProductOrder/Model/ProductOrder.php
  15. +2
    -0
      common/logic/Payment/Model/Payment.php
  16. +3
    -1
      common/logic/Payment/Repository/PaymentRepository.php
  17. +8
    -2
      common/logic/Payment/Service/PaymentSolver.php
  18. +1
    -1
      common/logic/Producer/Producer/Service/ProducerBuilder.php
  19. +13
    -1
      common/logic/User/User/Repository/UserRepository.php
  20. +26
    -0
      console/migrations/m230920_081923_add_column_payment_date_transaction.php

+ 8
- 2
backend/controllers/DistributionController.php Datei anzeigen

@@ -151,6 +151,7 @@ class DistributionController extends BackendController

public function buildAjaxInfosResponsePointsSale(Distribution $distribution)
{
$producerManager = $this->getProducerManager();
$pointSaleManager = $this->getPointSaleManager();
$pointSaleDistributionManager = $this->getPointSaleDistributionManager();

@@ -170,6 +171,8 @@ class DistributionController extends BackendController
]
];
}

$pointSaleArray['credit_functioning'] = $producerManager->getPointSaleCreditFunctioning($pointSale);
}

return $pointsSaleArray;
@@ -187,7 +190,9 @@ class DistributionController extends BackendController
$jsonProduct['quantity_ordered'] = $quantityOrder;

if (!isset($product->productDistribution[0])) {
$jsonProduct['productDistribution'][0] = $distributionManager->addProduct($distribution, $product)->getAttributes();
$productDistributionAdd = $distributionManager->addProduct($distribution, $product);
$jsonProduct['productDistribution'][0] = $productDistributionAdd->getAttributes();
$product->populateRelation('productDistribution', [$productDistributionAdd]);
}
else {
foreach($product->productDistribution as $key => $productDistribution) {
@@ -333,7 +338,7 @@ class DistributionController extends BackendController
'date' => date('d/m/Y H:i:s', strtotime($payment->date)),
'user' => $payment->getUserObject() ? $userManager->getUsername($payment->getUserObject()) : '',
'user_action' => $paymentManager->getStrUserAction($payment),
'wording' => $paymentManager->getStrWording($payment),
'wording' => $paymentManager->getStrWording($payment, $order),
'amount' => $paymentManager->getAmount($payment, Order::AMOUNT_TOTAL, true),
];
}
@@ -371,6 +376,7 @@ class DistributionController extends BackendController
'isCreditAutoPayment' => $orderManager->isCreditAutoPayment($order),
'isCreditContext' => $orderManager->isCreditContext($order),
'isPaid' => $orderManager->isOrderPaid($order),
'isPaidViaInvoice' => $orderManager->isOrderPaidViaInvoice($order),
'paymentLabelShort' => $orderManager->getPaymentLabelShort($order)
]);
}

+ 13
- 2
backend/controllers/DocumentController.php Datei anzeigen

@@ -179,7 +179,7 @@ class DocumentController extends BackendController
if($documentManager->isDocumentInvoice($document) && $documentManager->isStatusValid($document)) {
$payment = $paymentManager->instanciatePayment(
Payment::TYPE_PAYMENT,
$documentManager->getAmountWithTax($document),
number_format($documentManager->getAmountWithTax($document), 3),
$this->getProducerCurrent(),
null,
null,
@@ -187,11 +187,22 @@ class DocumentController extends BackendController
null,
$document
);
$payment->amount = number_format($payment->amount, 2);

if ($payment->load(\Yii::$app->request->post()) && $payment->save()) {
$posts = \Yii::$app->request->post();
if(isset($posts['Payment']['date_transaction'])) {
$posts['Payment']['date_transaction'] = date('Y-m-d', strtotime(str_replace('/', '-', $posts['Payment']['date_transaction'])));
}

if ($payment->load($posts) && $payment->save()) {
$this->setFlash('success', 'Le règlement a bien été ajouté.');
return $this->redirect(['invoice/update', 'id' => $document->id]);
}
else {
if($payment->date_transaction) {
$payment->date_transaction = date('d/m/Y', strtotime($payment->date_transaction));
}
}
}

return $this->render('/document/update', [

+ 1
- 1
backend/controllers/ProducerController.php Datei anzeigen

@@ -194,7 +194,7 @@ class ProducerController extends BackendController
public function actionUpdateOpendistribVersion()
{
$producerManager = $this->getProducerManager();
$producerManager->updateOpendistribVersion(GlobalParam::getCurrentProducer());
$producerManager->updateOpendistribVersion($this->getProducerCurrent());

return $this->redirect(\Yii::$app->request->referrer);
}

+ 96
- 67
backend/views/distribution/index.php Datei anzeigen

@@ -335,10 +335,8 @@ $this->setPageTitle('Distributions') ;
<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-payment"></th>
<th class="column-actions">Actions</th>
<th class="column-tiller" v-if="producer && producer.tiller">Tiller</th>
<th class="column-actions"></th>
<th class="column-delivery-note"></th>
</tr>
</thead>
<tbody>
@@ -388,49 +386,16 @@ $this->setPageTitle('Distributions') ;
</td>
<td class="column-state-payment">
<order-state-payment :order="order" :producer="producer"></order-state-payment>
<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)">
<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>
<td class="column-payment" v-if="producer && producer.credit">

<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Paiement <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li v-if="order.isCreditContext">
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="credit">
{{ 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">
{{ 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">
{{ 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">
{{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'par virement') }}
</a>
</li>
<!--<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="credit-card">
{{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'par carte bancaire') }}
</a>
</li>-->
<li><a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">Historique</a></li>
</ul>

<td class="column-payment" v-if="false && producer && producer.credit">
<!--<div class="btn-group" v-if="order.user && !order.date_delete">
<button class="btn btn-xs btn-default" v-if="order.amount_paid == order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="refund" :data-amount="order.amount">
<span class="glyphicon glyphicon-euro"></span> Recréditer
@@ -454,25 +419,93 @@ $this->setPageTitle('Distributions') ;
</ul>
</div>-->
</td>
<td v-if="producer && producer.tiller" class="tiller column-tiller">
<input v-if="order.tiller_synchronization == true" type="checkbox" checked="checked" :id="'checkbox-tiller-synchronization-'+order.id" :data-id-order="order.id" @change="changeSynchroTiller" />
<input v-else type="checkbox" :id="'checkbox-tiller-synchronization-'+order.id" :data-id-order="order.id" @change="changeSynchroTiller" />
<label :for="'checkbox-tiller-synchronization-'+order.id">Tiller</label>
</td>

<td class="column-actions">
<span v-if="order.oneProductUnactivated" class="glyphicon glyphicon-warning-sign" title="Contient un produit non activé"></span>
<span v-if="false && order.oneProductUnactivated" class="glyphicon glyphicon-warning-sign" title="Contient un produit non activé"></span>

<a href="javascript:void(0);" class="btn btn-default btn-xs" :data-id-order="order.id" @click="orderViewClick"><span :class="'glyphicon ' + ((showViewProduct && idOrderView == order.id) ? 'glyphicon-eye-close' : 'glyphicon-eye-open')"></span></a>
<a href="javascript:void(0);" class="btn btn-default btn-xs" :data-id-order="order.id" @click="updateOrderClick"><span class="glyphicon glyphicon-pencil"></span></a>

<div class="wrapper-button-dropdown">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
€ <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<template v-if="!order.isPaidViaInvoice">
<li v-if="order.isCreditContext">
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="credit">
<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>
<!--<li>
<a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="credit-card">
{{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'par carte bancaire') }}
</a>
</li>-->
<li>
<a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">
<span class="glyphicon glyphicon-th-list"></span> Historique
</a>
</li>
</ul>
</div>

<div class="wrapper-button-dropdown">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Action <span class="caret"></span>
<span class="glyphicon glyphicon-file"></span> <template v-if="countDocuments(order)">{{ countDocuments(order) }}</template> <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="orderViewClick"><span :class="'glyphicon ' + ((showViewProduct && idOrderView == order.id) ? 'glyphicon-eye-close' : 'glyphicon-eye-open')"></span> Voir</a></li>
<li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="updateOrderClick"><span class="glyphicon glyphicon-pencil"></span> Modifier</a></li>
<li v-if="!order.id_delivery_note">
<a href="javascript:void(0);" class="" :data-id-order="order.id" @click="generateDeliveryNote">
<span class="glyphicon glyphicon-plus"></span> Générer un bon de livraison
</a>
</li>
<li v-if="order.id_quotation">
<a :href="UrlManager.getBaseUrl()+'quotation/update?id='+order.id_quotation">
<span class="glyphicon glyphicon-file"></span> Devis
</a>
</li>
<li v-if="order.id_delivery_note">
<a :href="UrlManager.getBaseUrl()+'delivery-note/update?id='+order.id_delivery_note">
<span class="glyphicon glyphicon-file"></span> Bon de livraison
</a>
</li>
<li v-if="order.id_invoice">
<a :href="UrlManager.getBaseUrl()+'invoice/update?id='+order.id_invoice">
<span class="glyphicon glyphicon-file"></span> Facture
</a>
</li>
</ul>
</div>

<div class="wrapper-button-dropdown">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<!--<li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="orderViewClick"><span :class="'glyphicon ' + ((showViewProduct && idOrderView == order.id) ? 'glyphicon-eye-close' : 'glyphicon-eye-open')"></span> Voir</a></li>
<li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="updateOrderClick"><span class="glyphicon glyphicon-pencil"></span> Modifier</a></li>-->
<li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="deleteOrderClick"><span class="glyphicon glyphicon-trash"></span> Supprimer</a></li>
<li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="generateDeliveryNote"><span class="glyphicon glyphicon-file"></span> Générer un bon de livraison</a></li>
<li v-if="order.id_subscription > 0"><a class="" :href="baseUrl+'/subscription/update?id='+order.id_subscription"><span class="glyphicon glyphicon-repeat"></span> Modifier l'abonnement associé</a></li>
<li v-else><a class="add-subscription" :href="baseUrl+'/subscription/create?idOrder='+order.id"><span class="glyphicon glyphicon-plus"></span><span class="glyphicon glyphicon-repeat"></span>Créer un abonnement sur cette base</a></li>
<li v-if="order.id_subscription > 0"><a class="" :href="baseUrl+'/subscription/update?id='+order.id_subscription"><span class="glyphicon glyphicon-repeat"></span> Modifier l'abonnement lié</a></li>
<li v-else><a class="add-subscription" :href="baseUrl+'/subscription/create?idOrder='+order.id"><span class="glyphicon glyphicon-plus"></span><span class="glyphicon glyphicon-repeat"></span>Créer un abonnement</a></li>
</ul>
</div>

<order-form
v-if="showModalFormOrderUpdate && idOrderUpdate == order.id"
@@ -527,7 +560,7 @@ $this->setPageTitle('Distributions') ;

<div class="row">
<div class="col-md-12">
<h4>Historique</h4>
<h4>Historique paiements</h4>
<table class="table table-condensed table-bordered table-hover" v-if="order.paymentsArray && order.paymentsArray.length > 0">
<thead>
<tr>
@@ -553,22 +586,21 @@ $this->setPageTitle('Distributions') ;
</tbody>
</table>
<div class="alert alert-info" v-else>
Aucun paiement enregistré sur cette commande.
Aucun paiement rattaché à commande.
</div>
<div class="alert alert-success" v-if="order.isPaidViaInvoice">
La commande est payée via la <a :href="UrlManager.getBaseUrl()+'invoice/update?id='+order.id_invoice">facture</a> à laquelle elle est rattachée.
</div>
</div>
</div>

</div>
</modal>

</td>
<td class="column-delivery-note">
<a v-if="order.id_delivery_note" class="btn btn-default btn-xs" :href="UrlManager.getBaseUrl()+'delivery-note/update?id='+order.id_delivery_note">
<span class="glyphicon glyphicon-file"></span> BL
</a>
<a v-if="order.id_invoice" class="btn btn-default btn-xs" :href="UrlManager.getBaseUrl()+'invoice/update?id='+order.id_invoice">
<span class="glyphicon glyphicon-file"></span> FA
</a>
<td v-if="producer && producer.tiller" class="tiller column-tiller">
<input v-if="order.tiller_synchronization == true" type="checkbox" checked="checked" :id="'checkbox-tiller-synchronization-'+order.id" :data-id-order="order.id" @change="changeSynchroTiller" />
<input v-else type="checkbox" :id="'checkbox-tiller-synchronization-'+order.id" :data-id-order="order.id" @change="changeSynchroTiller" />
<label :for="'checkbox-tiller-synchronization-'+order.id">Tiller</label>
</td>
</tr>
<tr class="view" v-if="showViewProduct && idOrderView == order.id">
@@ -603,8 +635,7 @@ $this->setPageTitle('Distributions') ;

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

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

@@ -658,11 +689,11 @@ $this->setPageTitle('Distributions') ;
</select>
</div>
<div class="form-group">
<label class="control-label" for="select-mean-payment">Moyen de paiement</label>
<!--<label class="control-label" for="select-mean-payment">Moyen de paiement</label>
<select class="form-control" id="select-mean-payment" v-model="order.mean_payment">
<option value="0">--</option>
<option v-for="(wordingMeanPayment, keyMeanPayment) in meansPayment" :value="keyMeanPayment">{{ wordingMeanPayment }}</option>
</select>
</select>-->
</div>
<div class="form-group">
<label class="control-label" for="textarea-comment">Commentaire</label>
@@ -757,9 +788,7 @@ $this->setPageTitle('Distributions') ;
<span class="label label-default input-group-addon" v-else-if="order.amount_paid == 0">non réglé</span>
<span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span>
<span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à débiter</span>

<span class="glyphicon glyphicon-time" title="Paiement automatique" v-if="order.auto_payment && producer && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
</div>
</div>
</script>

<!-- template for the modal component -->

+ 15
- 6
backend/views/document/_form.php Datei anzeigen

@@ -175,7 +175,7 @@ $documentClass = $documentManager->getClass($model);
<div class="info-box-content">
<span class="info-box-text">
Total<span v-if="taxRateProducer != 0"> (TTC)</span>
<?php if($invoiceManager->isInvoicePaid($model)): ?>
<?php if($invoiceManager->isDocumentInvoice($model) && $invoiceManager->isInvoicePaid($model)): ?>
<span class="label label-success">PAYÉE</span>
<?php endif; ?>
</span>
@@ -254,6 +254,7 @@ $documentClass = $documentManager->getClass($model);
<thead>
<tr>
<th>Moyen de paiement</th>
<th>Date transaction</th>
<th>Montant</th>
</tr>
</thead>
@@ -261,6 +262,7 @@ $documentClass = $documentManager->getClass($model);
<?php foreach($model->payments as $payment): ?>
<tr>
<td><?= $paymentManager->getStrMeanPayment($payment); ?></td>
<td><?= $payment->date_transaction ? date('d/m/Y', strtotime($payment->date_transaction)) : '' ?></td>
<td><?= Price::format($payment->amount); ?></td>
</tr>
<?php endforeach; ?>
@@ -268,16 +270,23 @@ $documentClass = $documentManager->getClass($model);
</table>
<?php endif; ?>

<?php if(!$invoiceManager->isInvoicePaid($model)): ?>
<?php if($invoiceManager->isDocumentInvoice($model) && !$invoiceManager->isInvoicePaid($model)): ?>
<div class="row">
<?php $form = ActiveForm::begin(); ?>
<div class="col-md-4">
<div class="col-md-3">
<?= $form->field($payment, 'mean_payment')->dropDownList(MeanPayment::getAll()); ?>
</div>
<div class="col-md-4">
<?= $form->field($payment, 'amount')->textInput(); ?>
<div class="col-md-3">
<?= $form->field($payment, 'date_transaction')->textInput([
'class' => 'datepicker form-control'
]); ?>
</div>
<div class="col-md-4">
<div class="col-md-3">
<?= $form->field($payment, 'amount', [
'template' => '{label}<div class="input-group">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}',
])->textInput(); ?>
</div>
<div class="col-md-3">
<div class="form-group">
<br>
<?= Html::submitButton('Ajouter', ['class' => 'btn btn-primary']) ?>

+ 16
- 5
backend/views/invoice/index.php Datei anzeigen

@@ -107,16 +107,27 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
'format' => 'raw',
'value' => function ($invoice) use ($invoiceManager) {
$amountWithTax = $invoiceManager->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL);
$html = $invoiceManager->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL, true);
return $invoiceManager->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL, true);
}
],
[
'header' => 'Payée',
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($invoice) use ($invoiceManager) {
$amountWithTax = $invoiceManager->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL);
if($amountWithTax && $invoiceManager->isInvoicePaid($invoice)) {
$html .= ' <span class="label label-success">Payée</span>';
return '<span class="label label-success">Oui</span>';
}
return $html;

return '<span class="label label-default">Non</span>';
}
],
[
'attribute' => 'is_sent',
'header' => 'Envoyé',
'header' => 'Envoyée',
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
@@ -125,7 +136,7 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon-
if ($model->is_sent) {
return '<span class="label label-success">Oui</span>';
} else {
return '<span class="label label-danger">Non</span>';
return '<span class="label label-default">Non</span>';
}
}
],

+ 53
- 45
backend/web/css/screen.css Datei anzeigen

@@ -1798,7 +1798,7 @@ body.skin-black .content-wrapper .table th {
}
/* line 279, ../sass/_adminlte.scss */
body.skin-black .content-wrapper .table th.column-actions, body.skin-black .content-wrapper .table td.column-actions {
width: 150px;
width: 172px;
text-align: right;
}
/* line 283, ../sass/_adminlte.scss */
@@ -2270,10 +2270,14 @@ termes.
font-style: italic;
}
/* line 278, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-delivery-note {
position: relative;
}
/* line 282, ../sass/distribution/_index.scss */
.distribution-index #orders table td.tiller {
width: 60px;
}
/* line 281, ../sass/distribution/_index.scss */
/* line 285, ../sass/distribution/_index.scss */
.distribution-index #orders table td.tiller label {
font-size: 12px;
cursor: pointer;
@@ -2281,84 +2285,88 @@ termes.
top: -2px;
font-weight: normal;
}
/* line 290, ../sass/distribution/_index.scss */
/* line 294, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions {
position: relative;
text-align: right;
}
/* line 294, ../sass/distribution/_index.scss */
/* line 298, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .wrapper-button-dropdown {
display: inline-block;
}
/* line 302, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .dropdown-menu {
top: 0px;
right: 0px;
left: -70px;
width: 227px;
}
/* line 299, ../sass/distribution/_index.scss */
/* line 307, ../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 304, ../sass/distribution/_index.scss */
/* line 312, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .add-subscription {
position: relative;
}
/* line 307, ../sass/distribution/_index.scss */
/* line 315, ../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 316, ../sass/distribution/_index.scss */
/* line 324, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-state-payment {
width: 120px;
width: 133px;
}
/* line 322, ../sass/distribution/_index.scss */
/* line 330, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-credit a.positive {
color: green;
}
/* line 325, ../sass/distribution/_index.scss */
/* line 333, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-credit a.negative {
color: red;
}
/* line 331, ../sass/distribution/_index.scss */
/* line 339, ../sass/distribution/_index.scss */
.distribution-index #orders table .state-payment-mobile {
display: none;
}
/* line 335, ../sass/distribution/_index.scss */
/* line 343, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-payment {
position: relative;
}
/* line 338, ../sass/distribution/_index.scss */
/* line 346, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-payment div.btn-group {
width: 125px;
}
/* line 344, ../sass/distribution/_index.scss */
/* line 352, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view ul {
list-style-type: none;
margin-left: 0px;
padding-left: 15px;
}
/* line 354, ../sass/distribution/_index.scss */
/* line 362, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view .comment {
margin-top: 20px;
}
/* line 358, ../sass/distribution/_index.scss */
/* line 366, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view .delivery {
margin-top: 20px;
}
/* line 367, ../sass/distribution/_index.scss */
/* line 375, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container {
width: 100%;
padding: 0px;
}
/* line 371, ../sass/distribution/_index.scss */
/* line 379, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-body {
padding-right: 15px;
}
/* line 374, ../sass/distribution/_index.scss */
/* line 382, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-body table {
margin-bottom: 150px;
}
/* line 379, ../sass/distribution/_index.scss */
/* line 387, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer {
border-top-color: #f4f4f4;
position: fixed;
@@ -2370,64 +2378,64 @@ termes.
text-align: center;
border-top: solid 1px #e0e0e0;
}
/* line 391, ../sass/distribution/_index.scss */
/* line 399, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer .actions-form button {
float: none;
}
/* line 395, ../sass/distribution/_index.scss */
/* line 403, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer .actions-form div.right {
float: right;
}
/* line 402, ../sass/distribution/_index.scss */
/* line 410, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .btn-credit {
float: right;
}
/* line 408, ../sass/distribution/_index.scss */
/* line 416, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products .product-ordered td {
background-color: #e9e9e9;
}
/* line 412, ../sass/distribution/_index.scss */
/* line 420, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products .product-ordered input.input-quantity {
font-size: 16px;
font-weight: bold;
}
/* line 418, ../sass/distribution/_index.scss */
/* line 426, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price {
width: 150px;
}
/* line 421, ../sass/distribution/_index.scss */
/* line 429, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price input {
text-align: center;
}
/* line 425, ../sass/distribution/_index.scss */
/* line 433, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price .input-group-addon {
background-color: #eee;
}
/* line 429, ../sass/distribution/_index.scss */
/* line 437, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price .invoice-price {
margin-top: 8px;
}
/* line 431, ../sass/distribution/_index.scss */
/* line 439, ../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 439, ../sass/distribution/_index.scss */
/* line 447, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity {
width: 165px;
}
/* line 442, ../sass/distribution/_index.scss */
/* line 450, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity input {
text-align: center;
color: black;
}
/* line 447, ../sass/distribution/_index.scss */
/* line 455, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .form-control {
border-right: 0px none;
padding-right: 4px;
}
/* line 452, ../sass/distribution/_index.scss */
/* line 460, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .input-group-addon {
padding: 5px;
padding-left: 0px;
@@ -2435,35 +2443,35 @@ termes.
border-left: 0px none;
border-right: 0px none;
}
/* line 461, ../sass/distribution/_index.scss */
/* line 469, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining {
text-align: right;
}
/* line 464, ../sass/distribution/_index.scss */
/* line 472, ../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 468, ../sass/distribution/_index.scss */
/* line 476, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.negative {
color: #DD4B39;
}
/* line 472, ../sass/distribution/_index.scss */
/* line 480, ../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 479, ../sass/distribution/_index.scss */
/* line 487, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .actions-form button {
margin-left: 15px;
}
/* line 487, ../sass/distribution/_index.scss */
/* line 495, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon {
width: 50px;
}
/* line 490, ../sass/distribution/_index.scss */
/* line 498, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon i {
font-size: 30px;
}
/* line 495, ../sass/distribution/_index.scss */
/* line 503, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-content {
margin-left: 50px;
}

+ 17
- 0
backend/web/js/vuejs/distribution-index.js Datei anzeigen

@@ -893,6 +893,23 @@ var app = new Vue({

return false;
},
countDocuments: function(order) {
var count = 0;

if(order.id_delivery_note) {
count ++;
}

if(order.id_quotation) {
count ++;
}

if(order.id_invoice) {
count ++;
}

return count;
}
},
});


+ 1
- 1
backend/web/sass/_adminlte.scss Datei anzeigen

@@ -277,7 +277,7 @@ body.skin-black {
font-size: 13px ;
}
th.column-actions, td.column-actions {
width: 150px ;
width: 172px;
text-align: right ;
}
td.text-small, th.text-small {

+ 11
- 3
backend/web/sass/distribution/_index.scss Datei anzeigen

@@ -275,6 +275,10 @@ termes.
}
}

td.column-delivery-note {
position: relative;
}

td.tiller {
width: 60px;

@@ -291,9 +295,13 @@ termes.
position: relative;
text-align: right;

.wrapper-button-dropdown {
display: inline-block;
}

.dropdown-menu {
top: 0px;
right: 0px;
left: -70px;
width: 227px;
}

.modal-form-order,
@@ -314,7 +322,7 @@ termes.
}

td.column-state-payment {
width: 120px;
width: 133px;
}

td.column-credit {

+ 1
- 1
common/config/params.php Datei anzeigen

@@ -37,7 +37,7 @@
*/

return [
'version' => '23.9.A',
'version' => '23.9.B',
'siteName' => 'Opendistrib',
'adminEmail' => 'contact@opendistrib.net',
'supportEmail' => 'contact@opendistrib.net',

+ 22
- 8
common/logic/Order/Order/Repository/OrderRepository.php Datei anzeigen

@@ -65,15 +65,19 @@ class OrderRepository extends AbstractRepository
self::WITH => [
'productOrder',
'productOrder.product',
'productOrder.taxRate',
'pointSale',
'payment',
'payment.user',
'payment.userAction',
'pointSale',
'deliveryNote',
'invoice',
'quotation'
],
self::JOIN_WITH => [
'distribution',
'user',
'user.userProducer',
//'payment'
],
self::ORDER_BY => 'order.date ASC',
self::ATTRIBUTE_ID_PRODUCER => 'distribution.id_producer'
@@ -352,6 +356,10 @@ class OrderRepository extends AbstractRepository

public function isCreditContext(Order $order)
{
if(!$this->producerRepository->getConfig('credit')) {
return false;
}

//$pointSale = $this->pointSaleRepository->findOnePointSaleById($order->id_point_sale);
$pointSale = $order->pointSale;

@@ -448,6 +456,11 @@ class OrderRepository extends AbstractRepository
return true;
}

return $this->isOrderPaidViaInvoice($order);
}

public function isOrderPaidViaInvoice(Order $order): bool
{
if($order->invoice) {
$invoice = $this->invoiceRepository->findOneInvoiceById($order->id_invoice);
if($invoice && $this->invoiceSolver->isInvoicePaid($invoice)) {
@@ -473,30 +486,31 @@ class OrderRepository extends AbstractRepository
{
$isOrderPaid = $this->isOrderPaid($order);
$amountPaid = $this->orderSolver->getOrderAmountPaid($order);
$label = '&nbsp;';

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

return '&nbsp;';
return '<span class="label label-'.($isOrderPaid ? 'success' : 'default').'">'.$label.'</span>';
}
}

+ 1
- 2
common/logic/Order/Order/Service/OrderBuilder.php Datei anzeigen

@@ -413,8 +413,7 @@ class OrderBuilder extends AbstractBuilder
*/
public function initOrderPaidAmount(Order $order): void
{
$history = $this->paymentRepository->getByOrder($order);

$history = $order->payment;
$order->paid_amount = 0;

if ($history && count($history)) {

+ 2
- 1
common/logic/Order/ProductOrder/Model/ProductOrder.php Datei anzeigen

@@ -126,9 +126,10 @@ class ProductOrder extends ActiveRecordCommon

public function afterFind()
{
if ($this->taxRate == null) {
if(!$this->id_tax_rate) {
$this->populateRelation('taxRate', GlobalParam::getCurrentProducer()->taxRate);
}

parent::afterFind();
}


+ 2
- 0
common/logic/Payment/Model/Payment.php Datei anzeigen

@@ -71,6 +71,7 @@ class Payment extends ActiveRecordCommon
[['id_user', 'id_user_action', 'id_order', 'id_invoice', 'id_producer'], 'integer'],
[['date'], 'safe'],
[['amount'], 'double'],
[['date_transaction'], 'date', 'format' => 'php:Y-m-d'],
[['type', 'mean_payment'], 'string', 'max' => 255],
[['comment'], 'string', 'max' => 2048],
];
@@ -93,6 +94,7 @@ class Payment extends ActiveRecordCommon
'id_producer' => 'Producteur',
'mean_payment' => 'Moyen de paiement',
'comment' => 'Commentaire',
'date_transaction' => 'Date transaction'
];
}


+ 3
- 1
common/logic/Payment/Repository/PaymentRepository.php Datei anzeigen

@@ -18,7 +18,9 @@ class PaymentRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
self::WITH => [],
self::WITH => [
'user'
],
self::JOIN_WITH => [],
self::ORDER_BY => Payment::tableName() . '.date ASc',
self::ATTRIBUTE_ID_PRODUCER => Payment::tableName() . '.id_producer'

+ 8
- 2
common/logic/Payment/Service/PaymentSolver.php Datei anzeigen

@@ -4,6 +4,7 @@ namespace common\logic\Payment\Service;

use common\helpers\MeanPayment;
use common\logic\AbstractService;
use common\logic\Order\Order\Model\Order;
use common\logic\Payment\Model\Payment;
use common\logic\SolverInterface;

@@ -40,7 +41,7 @@ class PaymentSolver extends AbstractService implements SolverInterface
* éventuellement de la date de sa commande associée.
*
*/
public function getStrWording(Payment $payment): string
public function getStrWording(Payment $payment, Order $order = null): string
{
$str = '';
$type = $payment->getType();
@@ -58,7 +59,12 @@ class PaymentSolver extends AbstractService implements SolverInterface
}

if (Payment::TYPE_PAYMENT == $type || Payment::TYPE_REFUND == $type) {
$order = $payment->getOrderObject();

// Optimisation
if(!$order) {
$order = $payment->order;
}

if ($order && $order->distribution) {
$str .= '<br />Commande : ' . date('d/m/Y', strtotime($order->distribution->date));
} else {

+ 1
- 1
common/logic/Producer/Producer/Service/ProducerBuilder.php Datei anzeigen

@@ -82,7 +82,7 @@ class ProducerBuilder extends AbstractBuilder
$versionsArray = Opendistrib::getVersions();
$producer->latest_version_opendistrib = reset($versionsArray);

$this->saveUpdate($producer);
$this->update($producer);
}

public function savePrivateKeyStripe($filename, $value)

+ 13
- 1
common/logic/User/User/Repository/UserRepository.php Datei anzeigen

@@ -69,7 +69,19 @@ class UserRepository extends AbstractRepository
*/
public function getCredit(User $user): float
{
$userProducer = $this->userProducerRepository->findOneUserProducer($user);
// @TODO : optimisation à refactorer
$userProducer = null;
$producerId = $this->getProducerContextId();
foreach($user->userProducer as $userProducerRelation) {
if($userProducerRelation->id_producer == $producerId) {
$userProducer = $userProducerRelation;
}
}

if(!$userProducer) {
$userProducer = $this->userProducerRepository->findOneUserProducer($user);
}

return $userProducer ? $userProducer->credit : 0;
}


+ 26
- 0
console/migrations/m230920_081923_add_column_payment_date_transaction.php Datei anzeigen

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

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m230920_081923_add_column_payment_date_transaction
*/
class m230920_081923_add_column_payment_date_transaction extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('payment', 'date_transaction', Schema::TYPE_DATE);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('payment', 'date_transaction');
}
}

Laden…
Abbrechen
Speichern