Browse Source

[Administration] Distributions > commandes : libellé paiement #1305

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
81ff749999
6 changed files with 38 additions and 79 deletions
  1. +3
    -3
      backend/controllers/DistributionController.php
  2. +11
    -62
      backend/views/distribution/index.php
  3. +1
    -1
      common/logic/Distribution/Distribution/Service/DistributionBuilder.php
  4. +12
    -8
      common/logic/Order/Order/Repository/OrderRepository.php
  5. +7
    -1
      common/logic/Payment/Service/PaymentUtils.php
  6. +4
    -4
      producer/views/order/order.php

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

@@ -130,7 +130,7 @@ class DistributionController extends BackendController

if ($dateObject && $dateObject->format($format) === $date) {
$distribution = $distributionManager->createDistributionIfNotExist($date);
$ordersArray = $orderManager->findOrdersByDistribution($distribution);
$ordersArray = $orderManager->findOrdersByDistribution($distribution, false);
$ordersArrayObject = $ordersArray;
$productsArray = $productManager->findProductsByDistribution($distribution, false);

@@ -369,8 +369,8 @@ class DistributionController extends BackendController
$order = array_merge($order->getAttributes(), [
'selected' => false,
'weight' => $order->weight,
'amount' => Price::numberTwoDecimals($orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL)),
'amount_paid' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_PAID)),
'amount' => (float) Price::numberTwoDecimals($orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL)),
'amount_paid' => (float) Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_PAID)),
'amount_remaining' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING)),
'amount_surplus' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_SURPLUS)),
'user' => (isset($order->user)) ? array_merge(

+ 11
- 62
backend/views/distribution/index.php View File

@@ -382,7 +382,7 @@ $this->setPageTitle('Distributions') ;
</template>
</td>
<td class="column-amount">
{{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}
{{ order.amount.toFixed(2)+'&nbsp;€' }}
<div class="state-payment-mobile">
<order-state-payment :order="order" :producer="producer"></order-state-payment>
</div>
@@ -392,6 +392,15 @@ $this->setPageTitle('Distributions') ;
<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.amount != 0 && order.auto_payment && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>

<div v-if="order.amount_paid > 0 && order.amount_paid < order.amount">
<span class="glyphicon glyphicon-alert"></span> Reste à payer
</div>
<div v-if="order.amount_paid > order.amount">
<span class="glyphicon glyphicon-alert"></span> Surplus à rembourser
{{ order.amount_paid }} /
{{ order.amount }}
</div>
</td>
<td class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)">
<template v-if="order.isCreditContext">
@@ -400,31 +409,6 @@ $this->setPageTitle('Distributions') ;
</a>
</template>
</td>
<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
</button>
<button class="btn btn-xs btn-default" v-else-if="order.amount_paid == 0" @click="orderPaymentClick" :data-id-order="order.id" data-type="payment" :data-amount="order.amount">
<span class="glyphicon glyphicon-euro"></span> Débiter
</button>
<button class="btn btn-xs btn-default" v-else-if="order.amount_paid < order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="payment" :data-amount="order.amount_remaining">
<span class="glyphicon glyphicon-euro"></span> Débiter
</button>
<button class="btn btn-xs btn-default" v-else-if="order.amount_paid > order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="refund" :data-amount="order.amount_surplus">
<span class="glyphicon glyphicon-euro"></span> Recréditer
</button>

<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">Historique</a></li>
</ul>
</div>-->
</td>

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

@@ -460,11 +444,6 @@ $this->setPageTitle('Distributions') ;
</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">
{{ 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
@@ -506,8 +485,6 @@ $this->setPageTitle('Distributions') ;
<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 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>
@@ -549,7 +526,7 @@ $this->setPageTitle('Distributions') ;
<div class="info-box-content">
<span class="info-box-text">Montant</span>
<span class="info-box-number">
{{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
{{ order.amount.toFixed(2)+' €' }}
</span>
</div>
</div>
@@ -639,19 +616,7 @@ $this->setPageTitle('Distributions') ;
</div>

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

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

<!--<span class="label label-success input-group-addon" v-if="order.amount_paid == order.amount">débité</span>
<span class="label label-default input-group-addon" v-else-if="order.amount_paid == 0">non débité</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>-->
</script>

<!-- template for the order-form component -->
@@ -694,13 +659,6 @@ $this->setPageTitle('Distributions') ;
<option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id"">{{ pointSale.name }}</option>
</select>
</div>
<div class="form-group">
<!--<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>-->
</div>
<div class="form-group">
<label class="control-label" for="textarea-comment">Commentaire</label>
<textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea>
@@ -789,15 +747,6 @@ $this->setPageTitle('Distributions') ;
</modal>
</script>

<script type="text/x-template" id="order-state-payment">
<div class="input-group">
<span class="label label-success input-group-addon" v-if="order.amount_paid == order.amount">payé</span>
<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>
</div>
</script>

<!-- template for the modal component -->
<script type="text/x-template" id="modal-template">
<transition name="modal">

+ 1
- 1
common/logic/Distribution/Distribution/Service/DistributionBuilder.php View File

@@ -155,7 +155,7 @@ class DistributionBuilder extends AbstractBuilder

public function updateOrderProductPrices(Distribution $distribution, Product $product): void
{
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution, 'origin != "user"');
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution, false, 'origin != "user"');

if ($ordersArray) {
foreach ($ordersArray as $order) {

+ 12
- 8
common/logic/Order/Order/Repository/OrderRepository.php View File

@@ -124,14 +124,18 @@ class OrderRepository extends AbstractRepository
->find();
}

public function findOrdersByDistribution(Distribution $distribution, string $conditionAppend = '')
public function findOrdersByDistribution(Distribution $distribution, bool $filterIsValid = true, string $conditionAppend = '')
{
return $this->createDefaultQuery()
$query = $this->createDefaultQuery()
->filterByDistributionDate($distribution->date)
->filterIsValid()
->filterByCondition($conditionAppend)
->orderBy('point_sale.name ASC, user.lastname ASC, user.name ASC, comment_point_sale ASC')
->find();
->orderBy('point_sale.name ASC, user.lastname ASC, user.name ASC, comment_point_sale ASC');

if($filterIsValid) {
$query->filterIsValid();
}

return $query->find();
}

public function findOrdersByUserAndInvoice(User $user, Invoice $invoice)
@@ -521,7 +525,7 @@ class OrderRepository extends AbstractRepository
$classLabel = 'default';
$titleLabel = '';

if(!$amountPaid) {
if($amountPaid > -0.01 && $amountPaid < 0.01) {
if($isOrderPaid && $amountTotal != 0) {
$label = 'Facture payée';
}
@@ -553,7 +557,7 @@ class OrderRepository extends AbstractRepository
}

$orderPaymentStatus = $this->orderSolver->getPaymentStatus($order);
if($amountPaid == 0 && !$isOrderPaid) {
if($amountPaid > -0.01 && $amountPaid < 0.01 && !$isOrderPaid) {
$classLabel = 'default';
}
elseif($orderPaymentStatus == Order::PAYMENT_SURPLUS) {
@@ -565,7 +569,7 @@ class OrderRepository extends AbstractRepository
}
elseif($orderPaymentStatus == Order::PAYMENT_UNPAID) {
$classLabel = 'warning';
$titleLabel = 'Paiement partiel';
$titleLabel = 'Paiement partiel '.$amountPaid;
}

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

+ 7
- 1
common/logic/Payment/Service/PaymentUtils.php View File

@@ -121,9 +121,15 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$amountPaid = round($this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID), 2);

if ($amountPaid >= 0.01 && $order->id_user) {

$amount = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID);
if($meanPayment == MeanPayment::CREDIT) {
$amount = $this->orderSolver->getOrderAmountPaidByCredit($order);
}

$this->paymentBuilder->createPayment(
Payment::TYPE_REFUND,
$this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID),
$amount,
$this->getProducerContext(),
$order->user,
$userAction,

+ 4
- 4
producer/views/order/order.php View File

@@ -334,10 +334,10 @@ $this->setTitle('Commander');
<span class="other">
<span v-if="product.weight">({{ product.weight }}&nbsp;g)</span>
</span>
<span v-if="product.quantity_max > 0 && ((product.quantity_form / product.coefficient_unit == product.quantity_remaining) || ((product.quantity_remaining * product.coefficient_unit) - product.quantity_form) < product.step)"
class="label label-danger">
Épuisé
</span>
<div>
<span v-if="product.quantity_max > 0 && ((product.quantity_form / product.coefficient_unit == product.quantity_remaining) || ((product.quantity_remaining * product.coefficient_unit) - product.quantity_form) < product.step)"
class="label label-danger">Épuisé</span>
</div>
<div class="description" v-if="product.description.length">
{{ product.description }}
</div>

Loading…
Cancel
Save