|
|
|
|
|
|
|
|
|
|
|
|
|
|
use common\helpers\CSV; |
|
|
use common\helpers\CSV; |
|
|
use common\helpers\GlobalParam; |
|
|
use common\helpers\GlobalParam; |
|
|
|
|
|
use common\helpers\Price; |
|
|
use common\logic\Document\DeliveryNote\Model\DeliveryNote; |
|
|
use common\logic\Document\DeliveryNote\Model\DeliveryNote; |
|
|
use common\logic\Document\Document\Model\Document; |
|
|
use common\logic\Document\Document\Model\Document; |
|
|
use common\logic\Document\Invoice\Model\Invoice; |
|
|
use common\logic\Document\Invoice\Model\Invoice; |
|
|
|
|
|
|
|
|
public function actionExportCsvEvoliz(int $id) |
|
|
public function actionExportCsvEvoliz(int $id) |
|
|
{ |
|
|
{ |
|
|
$documentManager = $this->getDocumentManager(); |
|
|
$documentManager = $this->getDocumentManager(); |
|
|
|
|
|
$productOrderManager = $this->getProductOrderManager(); |
|
|
|
|
|
|
|
|
$datas = []; |
|
|
$datas = []; |
|
|
$document = $this->findModel($id); |
|
|
$document = $this->findModel($id); |
|
|
|
|
|
|
|
|
$price = $productOrder->getInvoicePrice(); |
|
|
$price = $productOrder->getInvoicePrice(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$typeTotal = $documentManager->isInvoicePrice($document) ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; |
|
|
|
|
|
$priceTotal = $productOrderManager->getPriceByTypeTotal($productOrder, $typeTotal) * $productOrder->quantity; |
|
|
|
|
|
$tva = Price::getVat( |
|
|
|
|
|
$priceTotal, |
|
|
|
|
|
$productOrder->taxRate->value, |
|
|
|
|
|
$document->tax_calculation_method |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
$datas[] = [ |
|
|
$datas[] = [ |
|
|
$document->reference, // N° facture externe * |
|
|
$document->reference, // N° facture externe * |
|
|
date('d/m/Y', strtotime($document->date)), // Date facture * |
|
|
date('d/m/Y', strtotime($document->date)), // Date facture * |
|
|
|
|
|
|
|
|
'', // Réf. |
|
|
'', // Réf. |
|
|
$productOrder->product->name, // Désignation * |
|
|
$productOrder->product->name, // Désignation * |
|
|
$productOrder->quantity, // Qté * |
|
|
$productOrder->quantity, // Qté * |
|
|
'', // Product::strUnit($productOrder->unit, 'wording'), // Unité |
|
|
|
|
|
|
|
|
'', // Product::strUnit($productOrder->unit, 'wording'), // Unité |
|
|
$price, // PU HT * |
|
|
$price, // PU HT * |
|
|
'', // Remise |
|
|
'', // Remise |
|
|
$productOrder->taxRate->value * 100, // TVA |
|
|
$productOrder->taxRate->value * 100, // TVA |
|
|
'', // Total TVA |
|
|
|
|
|
'', // Total HT |
|
|
|
|
|
|
|
|
$tva, // Total TVA |
|
|
|
|
|
$priceTotal, // Total HT |
|
|
'', // Créateur |
|
|
'', // Créateur |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |