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



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


$order = array_merge($order->getAttributes(), [ $order = array_merge($order->getAttributes(), [
'selected' => false, 'selected' => false,
'weight' => $order->weight, '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_remaining' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING)),
'amount_surplus' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_SURPLUS)), 'amount_surplus' => Price::numberTwoDecimals($orderManager->getOrderAmount($order, Order::AMOUNT_SURPLUS)),
'user' => (isset($order->user)) ? array_merge( 'user' => (isset($order->user)) ? array_merge(

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

</template> </template>
</td> </td>
<td class="column-amount"> <td class="column-amount">
{{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}
{{ order.amount.toFixed(2)+'&nbsp;€' }}
<div class="state-payment-mobile"> <div class="state-payment-mobile">
<order-state-payment :order="order" :producer="producer"></order-state-payment> <order-state-payment :order="order" :producer="producer"></order-state-payment>
</div> </div>
<order-state-payment :order="order" :producer="producer"></order-state-payment> <order-state-payment :order="order" :producer="producer"></order-state-payment>
</a> </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> <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>
<td class="column-credit" v-if="!idActivePointSale || (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> </a>
</template> </template>
</td> </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"> <td class="column-actions">
<span v-if="false && 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>


</li> </li>
</template> </template>
</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> <li>
<a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id"> <a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">
<span class="glyphicon glyphicon-th-list"></span> Historique <span class="glyphicon glyphicon-th-list"></span> Historique
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu"> <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="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-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> <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>
<div class="info-box-content"> <div class="info-box-content">
<span class="info-box-text">Montant</span> <span class="info-box-text">Montant</span>
<span class="info-box-number"> <span class="info-box-number">
{{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
{{ order.amount.toFixed(2)+' €' }}
</span> </span>
</div> </div>
</div> </div>
</div> </div>


<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="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> </script>


<!-- template for the order-form component --> <!-- template for the order-form component -->
<option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id"">{{ pointSale.name }}</option> <option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id"">{{ pointSale.name }}</option>
</select> </select>
</div> </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"> <div class="form-group">
<label class="control-label" for="textarea-comment">Commentaire</label> <label class="control-label" for="textarea-comment">Commentaire</label>
<textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea> <textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea>
</modal> </modal>
</script> </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 --> <!-- template for the modal component -->
<script type="text/x-template" id="modal-template"> <script type="text/x-template" id="modal-template">
<transition name="modal"> <transition name="modal">

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



public function updateOrderProductPrices(Distribution $distribution, Product $product): void 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) { if ($ordersArray) {
foreach ($ordersArray as $order) { foreach ($ordersArray as $order) {

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

->find(); ->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) ->filterByDistributionDate($distribution->date)
->filterIsValid()
->filterByCondition($conditionAppend) ->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) public function findOrdersByUserAndInvoice(User $user, Invoice $invoice)
$classLabel = 'default'; $classLabel = 'default';
$titleLabel = ''; $titleLabel = '';


if(!$amountPaid) {
if($amountPaid > -0.01 && $amountPaid < 0.01) {
if($isOrderPaid && $amountTotal != 0) { if($isOrderPaid && $amountTotal != 0) {
$label = 'Facture payée'; $label = 'Facture payée';
} }
} }


$orderPaymentStatus = $this->orderSolver->getPaymentStatus($order); $orderPaymentStatus = $this->orderSolver->getPaymentStatus($order);
if($amountPaid == 0 && !$isOrderPaid) {
if($amountPaid > -0.01 && $amountPaid < 0.01 && !$isOrderPaid) {
$classLabel = 'default'; $classLabel = 'default';
} }
elseif($orderPaymentStatus == Order::PAYMENT_SURPLUS) { elseif($orderPaymentStatus == Order::PAYMENT_SURPLUS) {
} }
elseif($orderPaymentStatus == Order::PAYMENT_UNPAID) { elseif($orderPaymentStatus == Order::PAYMENT_UNPAID) {
$classLabel = 'warning'; $classLabel = 'warning';
$titleLabel = 'Paiement partiel';
$titleLabel = 'Paiement partiel '.$amountPaid;
} }


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

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

$amountPaid = round($this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID), 2); $amountPaid = round($this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID), 2);


if ($amountPaid >= 0.01 && $order->id_user) { 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( $this->paymentBuilder->createPayment(
Payment::TYPE_REFUND, Payment::TYPE_REFUND,
$this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID),
$amount,
$this->getProducerContext(), $this->getProducerContext(),
$order->user, $order->user,
$userAction, $userAction,

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

<span class="other"> <span class="other">
<span v-if="product.weight">({{ product.weight }}&nbsp;g)</span> <span v-if="product.weight">({{ product.weight }}&nbsp;g)</span>
</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"> <div class="description" v-if="product.description.length">
{{ product.description }} {{ product.description }}
</div> </div>

Loading…
Cancel
Save