Merge branch 'hotfixes/hotfix-order' into releases/release-h2f

This commit is contained in:
Tiavina 2025-02-25 16:02:03 +03:00
commit 1e012ae61c
34 changed files with 119 additions and 49 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -336,6 +336,7 @@ class OrderBdd {
thanato_product_discount.id,
thanato_product_discount.fk_thanato_id,
thanato_product_discount.fk_product_id,
thanato_product_discount.ht_price as discount_price,
thanato.nom as thanato_nom,
thanato.prenom as thanato_prenom,
produit.reference as produit_reference,

View File

@ -34,6 +34,7 @@ use OCA\Gestion\Db\Bdd;
use OCA\Gestion\Db\OrderBdd;
use OCA\Gestion\Helpers\DateHelpers;
use OCA\Gestion\Helpers\FileExportHelpers;
use OCA\Gestion\Helpers\PriceHelpers;
use OCA\Gestion\Service\Order\PdfHandler\OrderPdfHandler;
use OCP\Files\IRootFolder;
@ -74,6 +75,7 @@ class OrderPdfService {
}
private function formatOrderDataForPdfExport($orderPdfData,$config){
$tvaValue = $config->tva_default;
$orderPdfData["configuration"] = $config;
$configurationAdresses = FileExportHelpers::GetAddressAndCityFromAddress($config->adresse);
$orderPdfData["configuration_adresse"] = $configurationAdresses["address"];
@ -86,6 +88,26 @@ class OrderPdfService {
$devisDate = DateTime::createFromFormat('Y-m-d',$devisDate);
$devisDate = $devisDate->format('d-m-Y');
$orderPdfData['devis_date'] = $devisDate;
$totalHt = 0;
$totalTtc = 0;
$totalTva = 0;
$orderProducts = $orderPdfData["products"];
foreach($orderProducts as $orderProduct){
$valueHt = $orderProduct['produit_price'] * $orderProduct['quantite'];
$valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue);
$totalHt+=$valueHt;
$totalTtc+=$valueTtc;
$tvaAmount = $valueTtc - $valueHt;
$totalTva += $tvaAmount;
}
$totaPricesArray = [
"TOTAL HT" => $totalHt,
"TVA ".$tvaValue. "%" => $totalTva,
"TOTAL TTC" => $totalTtc
];
$orderPdfData["totalPrices"] = $totaPricesArray;
return $orderPdfData;
}

View File

@ -37,6 +37,17 @@ class OrderPdfHandler extends FPDF {
private $logoExist = false;
private $logoPath = "/var/www/html/data/admin/files/.gestion/";
private $orderProducts = [];
private $totalPrices = [];
private $tvaDefault = 20;
private $currentIndexPosition = 0;
private $initialIndexPosition = 0;
private $articlesCountToGet = 0;
private const MAX_ARTICLES_PER_PAGE = 15;
private const DEFAULT_SUBCONTRACTOR_NAME = "SOUS TRAITANT";
function Header()
{
@ -46,9 +57,12 @@ class OrderPdfHandler extends FPDF {
else{
$this->Cell(55,30,'');
}
$this->DrawOrderCompanyAndClientInfo();
$this->DrawOrderInfoTable();
}
function Footer()
{
$this->DrawBankAndTotalPriceInfo($this->totalPrices);
$this->SetY(-40);
$this->SetFont('Arial', '', 7);
$this->MultiCell(0,5,utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ( Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.')));
@ -64,6 +78,11 @@ class OrderPdfHandler extends FPDF {
public function OrderPdfFactory(array $factureData,$logoExist = false){
$this->orderData = $factureData;
$this->logoExist = $logoExist;
$this->orderProducts = $this->orderData["products"];
$this->tvaDefault = $this->orderData["configuration"]->tva_default;
$this->totalPrices = $this->orderData["totalPrices"];
$orderProductsCount = sizeof($this->orderProducts);
$this->articlesCountToGet = ($orderProductsCount <= self::MAX_ARTICLES_PER_PAGE ) ? $orderProductsCount : self::MAX_ARTICLES_PER_PAGE;
}
private function DrawOrderCompanyAndClientInfo(){
@ -101,7 +120,7 @@ class OrderPdfHandler extends FPDF {
$this->Ln(4);
}
private function DrawArticlesTable(){
private function DrawArticlesTableRect(){
$this->SetLineWidth(0.1);
$this->Rect(10, 105, 190, 100, "D");
// cadre titre des colonnes
@ -117,7 +136,7 @@ class OrderPdfHandler extends FPDF {
$tvaValue = $this->orderData["configuration"]->tva_default;
$this->SetFont('Arial','',10);
$this->SetXY( 10,106 );
$this->Cell( 20, 8, "Date", 0, 0, 'C');
$this->Cell( 24, 8, "Date", 0, 0, 'C');
$this->SetXY( 35,106 );
$this->Cell( 100, 8, "Description", 0, 0, 'C');
@ -133,15 +152,18 @@ class OrderPdfHandler extends FPDF {
}
public function DrawArticlesTableValueAndReturnTotalPrice(){
public function DrawArticlesTableValue(){
$this->SetFont('Arial','',10);
$tvaValue = $this->orderData["configuration"]->tva_default;
$totalHt = 0;
$totalTtc = 0;
$totalTva = 0;
$products = $this->orderData["products"];
// var_dump($products);
$yValue = 116;
foreach($products as $product){
$currentIndexPosition = $this->currentIndexPosition;
for($currentIndexPosition;$currentIndexPosition<($this->initialIndexPosition + $this->articlesCountToGet);$currentIndexPosition++){
$product = $products[$currentIndexPosition];
$valueHt = $product['produit_price'] * $product['quantite'];
$valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue);
$totalHt+=$valueHt;
@ -156,7 +178,7 @@ class OrderPdfHandler extends FPDF {
}
$tvaAmount = $valueTtc - $valueHt;
$this->SetXY( 10,$yValue );
$this->Cell(20, 6, $dateValue, 0,0);
$this->Cell(25, 6, $dateValue, 0,0,'C');
$this->SetXY( 35,$yValue );
$this->MultiAlignCell(100, 6, FileExportHelpers::FormatTextForExport($productDescription),0);
@ -169,15 +191,15 @@ class OrderPdfHandler extends FPDF {
$this->SetXY( 175,$yValue );
$this->Cell(25, 6, number_format($valueTtc,2,'.','').chr(128), 0, 1, 'C');
$yValue += 12;
$yValue += 6;
$totalTva += $tvaAmount;
}
$this->currentIndexPosition = $currentIndexPosition;
$this->initialIndexPosition += $this->currentIndexPosition;
$chargedOrderCount = $this->currentIndexPosition + 1;
$articlesLeftToGet = sizeof($this->orderProducts) - $chargedOrderCount;
$this->articlesCountToGet = ($articlesLeftToGet <= self::MAX_ARTICLES_PER_PAGE) ? $articlesLeftToGet + 1 : self::MAX_ARTICLES_PER_PAGE;
return [
"TOTAL HT" => $totalHt,
"TVA ".$tvaValue. "%" => $totalTva,
"TOTAL TTC" => $totalTtc
];
}
private function DrawBankAndTotalPriceInfo($totalPriceArray){
@ -210,15 +232,30 @@ class OrderPdfHandler extends FPDF {
}
}
private function DrawPageNumbersText($pageNumber,$pageCount){
$this->SetXY( 120, 5 );
$this->Cell( 160, 8, $pageNumber . '/' . $pageCount, 0, 0, 'C');
}
private function DrawArticlesTable(){
$pageCount = ceil(sizeof($this->orderProducts) / 15);
$pageNumber = 1;
while($pageNumber <= $pageCount){
if($pageNumber > 1){
$this->AddPage();
$this->DrawPageNumbersText($pageNumber,$pageCount);
}
$this->DrawArticlesTableRect();
$this->DrawArticlesTableHeader();
$this->DrawArticlesTableValue();
$pageNumber++;
}
}
public function SetOrderContent(){
$this->AddPage();
$this->SetMargins(10,0,10);
$this->DrawOrderCompanyAndClientInfo();
$this->DrawOrderInfoTable();
$this->SetMargins(10,0,right: 10);
$this->DrawArticlesTable();
$this->DrawArticlesTableHeader();
$totalPriceValue = $this->DrawArticlesTableValueAndReturnTotalPrice();
$this->DrawBankAndTotalPriceInfo($totalPriceValue);
}
function MultiAlignCell($w,$h,$text,$border=0,$ln=0,$align='L',$fill=false)

View File

@ -23,7 +23,7 @@ export class Order {
this.clientId = ((myresp.fk_client_id == null || myresp.fk_client_id.length === 0) ? '-' : myresp.fk_client_id);
this.locationId = ((myresp.fk_lieu_id == null || myresp.fk_lieu_id.length === 0) ? '-' : myresp.fk_lieu_id);
this.statusKey = ((myresp.fk_order_status_key == null || myresp.fk_order_status_key.length === 0) ? '-' : myresp.fk_order_status_key);
this.productReferences = ((myresp.product_references == null || myresp.product_references.length === 0) ? '-' : myresp.product_references);
this.productReferences = Order.getProductReferences(myresp);
this.orderDetailsUrl = generateUrl(`/apps/gestion/order/${this.id}/details`);
this.fkProviderId = myresp.fk_provider_id;
this.providerName = ((myresp.provider_name == null || myresp.provider_name.length === 0) ? '-' : myresp.provider_name);
@ -31,7 +31,17 @@ export class Order {
this.thanatoColumnClass = myresp.fk_order_type_key == OrderTypeDevis ? "" : "getThanatosSubcontractor";
}
static getProductReferences(myresp){
let productReferences = '-';
const isOrderTypePurchase = myresp.fk_order_type_key == OrderTypePurchase;
if(isOrderTypePurchase){
return productReferences;
}
if(myresp.product_references != null && myresp.product_references.length != 0){
productReferences = myresp.product_references;
}
return productReferences;
}
static getClientFullname(myresp){
let clientPrenom = '';

View File

@ -10,7 +10,7 @@ export class ThanatoProductFee {
this.id = myresp.id;
this.thanatoFullName = ThanatoProductFee.getThanatoFullname(myresp);
this.productReference = ((myresp.produit_reference == null || myresp.produit_reference.length === 0) ? '-' : myresp.produit_reference);
this.htAmount = myresp.produit_ht_price;
this.htAmount = myresp.discount_price;
this.thanatoId = myresp.fk_thanato_id;
this.productId = myresp.fk_product_id;
}

View File

@ -13,7 +13,7 @@ use OCA\Gestion\Constants\OrderTypeConstant;
$clientFullName = $isOrderDevis ?
$order->client_prenom . " " . $order->client_nom :
$order->provider_name . " " . $order->provider_last_name;
$order->provider_company_name;
$clientAddress = $isOrderDevis ?
$order->client_adresse :