Browse Source

[Backend] Adaptation export Evoliz : inclure TVA #913

refactoring
Guillaume Bourgeois 1 year ago
parent
commit
9d0e3de6d9
1 changed files with 13 additions and 3 deletions
  1. +13
    -3
      backend/controllers/DocumentController.php

+ 13
- 3
backend/controllers/DocumentController.php View File



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
]; ];
} }

Loading…
Cancel
Save