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

@@ -40,6 +40,7 @@ namespace backend\controllers;

use common\helpers\CSV;
use common\helpers\GlobalParam;
use common\helpers\Price;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Document\Document\Model\Document;
use common\logic\Document\Invoice\Model\Invoice;
@@ -210,6 +211,7 @@ class DocumentController extends BackendController
public function actionExportCsvEvoliz(int $id)
{
$documentManager = $this->getDocumentManager();
$productOrderManager = $this->getProductOrderManager();

$datas = [];
$document = $this->findModel($id);
@@ -262,6 +264,14 @@ class DocumentController extends BackendController
$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[] = [
$document->reference, // N° facture externe *
date('d/m/Y', strtotime($document->date)), // Date facture *
@@ -292,12 +302,12 @@ class DocumentController extends BackendController
'', // Réf.
$productOrder->product->name, // Désignation *
$productOrder->quantity, // Qté *
'', // Product::strUnit($productOrder->unit, 'wording'), // Unité
'', // Product::strUnit($productOrder->unit, 'wording'), // Unité
$price, // PU HT *
'', // Remise
$productOrder->taxRate->value * 100, // TVA
'', // Total TVA
'', // Total HT
$tva, // Total TVA
$priceTotal, // Total HT
'', // Créateur
];
}

Loading…
Cancel
Save