Explorar el Código

Tiller : synchro avec commande partiellement payées #1025

refactoring
Guillaume hace 1 año
padre
commit
4088854821
Se han modificado 4 ficheros con 13 adiciones y 9 borrados
  1. +1
    -1
      backend/controllers/DistributionController.php
  2. +4
    -4
      common/helpers/Tiller.php
  3. +7
    -4
      common/logic/Order/Order/Service/OrderBuilder.php
  4. +1
    -0
      producer/controllers/OrderController.php

+ 1
- 1
backend/controllers/DistributionController.php Ver fichero

'type' => $typePaymentTiller, 'type' => $typePaymentTiller,
'amount' => $orderManager->getOrderAmountWithTax( 'amount' => $orderManager->getOrderAmountWithTax(
$order, $order,
Order::AMOUNT_TOTAL
Order::AMOUNT_PAID
) * 100, ) * 100,
'status' => 'ACCEPTED', 'status' => 'ACCEPTED',
'date' => $strDate 'date' => $strDate

+ 4
- 4
common/helpers/Tiller.php Ver fichero

if (isset($ordersTiller->orders)) { if (isset($ordersTiller->orders)) {
foreach ($ordersTiller->orders as $orderTiller) { foreach ($ordersTiller->orders as $orderTiller) {
if ($orderOpendistrib->tiller_external_id == $orderTiller->id) { if ($orderOpendistrib->tiller_external_id == $orderTiller->id) {
$amountTotalOrderOpendistrib = (int)round(
$orderManager->getOrderAmountWithTax($orderOpendistrib, Order::AMOUNT_TOTAL) * 100
$amountTotalPaidOrderOpendistrib = (int)round(
$orderManager->getOrderAmountWithTax($orderOpendistrib, Order::AMOUNT_PAID) * 100
); );
if ($amountTotalOrderOpendistrib >= (int)$orderTiller->currentPayedAmount
|| $amountTotalOrderOpendistrib >= (int)$orderTiller->currentBill) {
if ($amountTotalPaidOrderOpendistrib >= (int)$orderTiller->currentPayedAmount
|| $amountTotalPaidOrderOpendistrib >= (int)$orderTiller->currentBill) {
$ordersOpendistribSynchro[$orderOpendistrib->id] = true; $ordersOpendistribSynchro[$orderOpendistrib->id] = true;
} }
} }

+ 7
- 4
common/logic/Order/Order/Service/OrderBuilder.php Ver fichero

*/ */
public function initOrderPaidAmount(Order $order): void public function initOrderPaidAmount(Order $order): void
{ {
if (isset($order->creditHistory)) {
// Attention : $order->creditHistory pas à jour si un paiement vient d'avoir lieu
/*if (isset($order->creditHistory)) {
$history = $order->creditHistory; $history = $order->creditHistory;
} else { } else {
$history = $this->creditHistoryRepository->getByOrder($order); $history = $this->creditHistoryRepository->getByOrder($order);
}
}*/

$history = $this->creditHistoryRepository->getByOrder($order);


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


if (!is_null($synchroTiller)) { if (!is_null($synchroTiller)) {
$order->tiller_synchronization = $synchroTiller; $order->tiller_synchronization = $synchroTiller;
} else { } else {
$paymentStatus = $this->orderSolver->getPaymentStatus($order);
$amountPaid = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID);


if ($paymentStatus == Order::PAYMENT_PAID) {
if ($amountPaid >= 0.01) {
$order->tiller_synchronization = 1; $order->tiller_synchronization = 1;
} else { } else {
$order->tiller_synchronization = 0; $order->tiller_synchronization = 0;

+ 1
- 0
producer/controllers/OrderController.php Ver fichero

} }
} }


$orderManager->initOrder($order);
$orderManager->updateOrderTillerSynchronization($order); $orderManager->updateOrderTillerSynchronization($order);
} }



Cargando…
Cancelar
Guardar