|
|
@@ -159,7 +159,7 @@ class ReportController extends BackendController |
|
|
|
$resArray[] = [ |
|
|
|
'name' => '', |
|
|
|
'quantity' => '', |
|
|
|
'total' => '<strong>' . Price::format(round($totalGlobal, 2)) . '</strong>', |
|
|
|
'total' => '<strong>' . Price::format(round($totalGlobal, 2)) . ' HT</strong>', |
|
|
|
]; |
|
|
|
|
|
|
|
return $resArray; |
|
|
@@ -181,7 +181,6 @@ class ReportController extends BackendController |
|
|
|
public function actionPayments(string $dateStart, string $dateEnd) |
|
|
|
{ |
|
|
|
$orderModule = $this->getOrderModule(); |
|
|
|
$paymentModule = $this->getPaymentModule(); |
|
|
|
$ordersArray = $orderModule->getRepository() |
|
|
|
->findOrdersByPeriod( |
|
|
|
new \DateTime($dateStart), |
|
|
@@ -203,31 +202,60 @@ class ReportController extends BackendController |
|
|
|
] |
|
|
|
]; |
|
|
|
|
|
|
|
$sumAmountTotalSpentByCredit = 0; |
|
|
|
$sumAmountTotalSpentByMoney = 0; |
|
|
|
$sumAmountTotalSpentByCheque = 0; |
|
|
|
$sumAmountTotalSpentByTransfer = 0; |
|
|
|
$sumAmountTotalSpentByCreditCard = 0; |
|
|
|
|
|
|
|
foreach($ordersArray as $order) { |
|
|
|
$orderModule->getBuilder()->initOrder($order); |
|
|
|
|
|
|
|
$strPayment = ''; |
|
|
|
foreach($order->payment as $payment) { |
|
|
|
$strPayment .= $paymentModule->getSolver()->getStrMeanPayment($payment).', '; |
|
|
|
$hasInvoice = false; |
|
|
|
$referenceInvoice = 'Non'; |
|
|
|
if($order->invoice) { |
|
|
|
$hasInvoice = true; |
|
|
|
$referenceInvoice = $order->invoice->reference.""; |
|
|
|
} |
|
|
|
|
|
|
|
$amountTotalSpentByCredit = $orderModule->getSolver()->getAmountTotalSpentByMeanPayment($order, MeanPayment::CREDIT); |
|
|
|
$sumAmountTotalSpentByCredit += $amountTotalSpentByCredit; |
|
|
|
$amountTotalSpentByMoney = $orderModule->getSolver()->getAmountTotalSpentByMeanPayment($order, MeanPayment::MONEY); |
|
|
|
$sumAmountTotalSpentByMoney += $amountTotalSpentByMoney; |
|
|
|
$amountTotalSpentByCheque = $orderModule->getSolver()->getAmountTotalSpentByMeanPayment($order, MeanPayment::CHEQUE); |
|
|
|
$sumAmountTotalSpentByCheque += $amountTotalSpentByCheque; |
|
|
|
$amountTotalSpentByTransfer = $orderModule->getSolver()->getAmountTotalSpentByMeanPayment($order, MeanPayment::TRANSFER); |
|
|
|
$sumAmountTotalSpentByTransfer += $amountTotalSpentByTransfer; |
|
|
|
$amountTotalSpentByCreditCard = $orderModule->getSolver()->getAmountTotalSpentByMeanPayment($order, MeanPayment::CREDIT_CARD); |
|
|
|
$sumAmountTotalSpentByCreditCard += $amountTotalSpentByCreditCard; |
|
|
|
|
|
|
|
$datas[] = [ |
|
|
|
$order->distribution->date, |
|
|
|
$orderModule->getSolver()->getOrderUsername($order), |
|
|
|
$orderModule->getSolver()->getOrderAmountWithTax($order), |
|
|
|
$order->invoice ? $order->invoice->reference : 'Non', |
|
|
|
$orderModule->getSolver()->getAmountTotalByMeanPayment($order, MeanPayment::CREDIT), |
|
|
|
$orderModule->getSolver()->getAmountTotalByMeanPayment($order, MeanPayment::MONEY), |
|
|
|
$orderModule->getSolver()->getAmountTotalByMeanPayment($order, MeanPayment::CHEQUE), |
|
|
|
$orderModule->getSolver()->getAmountTotalByMeanPayment($order, MeanPayment::TRANSFER), |
|
|
|
$orderModule->getSolver()->getAmountTotalByMeanPayment($order, MeanPayment::CREDIT_CARD), |
|
|
|
count($order->payment) . ' : '.$strPayment |
|
|
|
CSV::formatNumber($orderModule->getSolver()->getOrderAmountWithTax($order)), |
|
|
|
$referenceInvoice, |
|
|
|
$hasInvoice ? '' : CSV::formatNumber($amountTotalSpentByCredit), |
|
|
|
$hasInvoice ? '' : CSV::formatNumber($amountTotalSpentByMoney), |
|
|
|
$hasInvoice ? '' : CSV::formatNumber($amountTotalSpentByCheque), |
|
|
|
$hasInvoice ? '' : CSV::formatNumber($amountTotalSpentByTransfer), |
|
|
|
$hasInvoice ? '' : CSV::formatNumber($amountTotalSpentByCreditCard) |
|
|
|
]; |
|
|
|
|
|
|
|
//print_r($order->payment); |
|
|
|
//die(); |
|
|
|
} |
|
|
|
|
|
|
|
$datas[] = [ |
|
|
|
'', |
|
|
|
'', |
|
|
|
'', |
|
|
|
'Totaux paiements', |
|
|
|
CSV::formatNumber($sumAmountTotalSpentByCredit), |
|
|
|
CSV::formatNumber($sumAmountTotalSpentByMoney), |
|
|
|
CSV::formatNumber($sumAmountTotalSpentByCheque), |
|
|
|
CSV::formatNumber($sumAmountTotalSpentByTransfer), |
|
|
|
CSV::formatNumber($sumAmountTotalSpentByCreditCard), |
|
|
|
CSV::formatNumber($sumAmountTotalSpentByCredit + $sumAmountTotalSpentByMoney + $sumAmountTotalSpentByCheque + |
|
|
|
$sumAmountTotalSpentByTransfer + $sumAmountTotalSpentByCreditCard) |
|
|
|
]; |
|
|
|
|
|
|
|
CSV::send('commandes.csv', $datas); |
|
|
|
} |
|
|
|
|