Преглед изворни кода

Documents : méthode de calcul TVA #478

refactoring
Guillaume Bourgeois пре 2 година
родитељ
комит
6049868897
3 измењених фајлова са 30 додато и 29 уклоњено
  1. +3
    -1
      backend/controllers/DocumentController.php
  2. +27
    -26
      common/models/Document.php
  3. +0
    -2
      console/migrations/m220916_062206_add_column_document_tax_calculation_method.php

+ 3
- 1
backend/controllers/DocumentController.php Прегледај датотеку

@@ -88,7 +88,9 @@ class DocumentController extends BackendController
);

foreach($validatedDocumentsArray as $document) {
$document->generatePdf(Pdf::DEST_FILE);
if(!file_exists($document->getFilenameComplete())) {
$document->generatePdf(Pdf::DEST_FILE);
}
}
}


+ 27
- 26
common/models/Document.php Прегледај датотеку

@@ -258,15 +258,14 @@ class Document extends ActiveRecordCommon
{
$filenameComplete = $this->getFilenameComplete();

if(!file_exists($filenameComplete)) {
if (!file_exists($filenameComplete)) {
$this->generatePdf(Pdf::DEST_FILE);
}

if(file_exists($filenameComplete)) {
return Yii::$app->response->sendFile($filenameComplete, $this->getFilename(), ['inline'=>true]);
}
else {
throw new ErrorException('File '.$filenameComplete.' not found');
if (file_exists($filenameComplete)) {
return Yii::$app->response->sendFile($filenameComplete, $this->getFilename(), ['inline' => true]);
} else {
throw new ErrorException('File ' . $filenameComplete . ' not found');
}
}

@@ -396,25 +395,27 @@ class Document extends ActiveRecordCommon
if ($ordersArray && count($ordersArray)) {
foreach ($ordersArray as $order) {
foreach ($order->productOrder as $productOrder) {
$indexProductOrder = $productOrder->product->order;
$newProductOrder = clone $productOrder;

if (!isset($productsOrdersArray[$indexProductOrder])) {
$productsOrdersArray[$indexProductOrder] = [$newProductOrder];
} else {
$productOrderMatch = false;
foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) {
if ($theProductOrder->unit == $productOrder->unit
&& ((!$this->isInvoicePrice() && $theProductOrder->price == $productOrder->price)
|| ($this->isInvoicePrice() && $theProductOrder->invoice_price == $productOrder->invoice_price)
)) {

$theProductOrder->quantity += $productOrder->quantity;
$productOrderMatch = true;
if ($productOrder->product) {
$indexProductOrder = $productOrder->product->order;
$newProductOrder = clone $productOrder;

if (!isset($productsOrdersArray[$indexProductOrder])) {
$productsOrdersArray[$indexProductOrder] = [$newProductOrder];
} else {
$productOrderMatch = false;
foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) {
if ($theProductOrder->unit == $productOrder->unit
&& ((!$this->isInvoicePrice() && $theProductOrder->price == $productOrder->price)
|| ($this->isInvoicePrice() && $theProductOrder->invoice_price == $productOrder->invoice_price)
)) {

$theProductOrder->quantity += $productOrder->quantity;
$productOrderMatch = true;
}
}
if (!$productOrderMatch) {
$productsOrdersArray[$indexProductOrder][] = $newProductOrder;
}
}
if (!$productOrderMatch) {
$productsOrdersArray[$indexProductOrder][] = $newProductOrder;
}
}
}
@@ -438,14 +439,14 @@ class Document extends ActiveRecordCommon

public function getAliasDirectoryBase()
{
return '@app/web/pdf/'.$this->id_producer.'/';
return '@app/web/pdf/' . $this->id_producer . '/';
}

public function initDirectoryPdf()
{
$aliasDirectoryBase = $this->getAliasDirectoryBase();
$directoryPdf = Yii::getAlias($aliasDirectoryBase);
if(!file_exists($directoryPdf)) {
if (!file_exists($directoryPdf)) {
mkdir($directoryPdf, 0755);
}
}

+ 0
- 2
console/migrations/m220916_062206_add_column_document_tax_calculation_method.php Прегледај датотеку

@@ -25,8 +25,6 @@ class m220916_062206_add_column_document_tax_calculation_method extends Migratio
$columnTaxCalculationMethod = 'tax_calculation_method';
foreach(self::$tableDocumentArray as $tableName) {
$this->addColumn($tableName, $columnTaxCalculationMethod, $schemaTaxCalculationMethod);
// méthode appliquée jusqu'à maintenant
$this->execute('UPDATE `'.$tableName.'` SET `'.$columnTaxCalculationMethod.'` = \''.Document::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS.'\'');
}
}


Loading…
Откажи
Сачувај