Merge branch 'fixes/fix-defunt-cover-business-logic' into staging

This commit is contained in:
Tiavina 2025-02-20 09:51:11 +03:00
commit 6384d55de2
4 changed files with 71 additions and 43 deletions

8
Jenkinsfile vendored
View File

@ -9,5 +9,13 @@ pipeline {
sudo su jenkins -c "git stash && git pull origin staging" '''
}
}
stage ("deploy to DRL dev ezway") {
when { branch 'releases/release-hytha' }
agent { label 'apache && dev' }
steps {
sh '''cd /var/www/drl-nextcloud/custom_apps
sudo su jenkins -c "git stash && git pull origin releases/release-hytha" '''
}
}
}
}

View File

@ -1701,7 +1701,7 @@ class PageController extends Controller {
$factures = json_decode($this->myDb->getFactures($this->idNextcloud));
foreach ($factures as $key => $facture) {
$facture_temp = array(
'num' => explode('/',$facture->num)[2],
'num' => $facture->num,
'client' => $facture->entreprise,
'nom_client' => $facture->nom,
'date' => $facture->date,

View File

@ -3321,27 +3321,16 @@ class Bdd {
}
private function getProductAsDefuntCoverProduct($productCoverId){
$sqlConditionsPlaceholder = implode(',', array_fill(0, count(ProductConstant::PRODUCT_COVER_REFERENCE_LIST), '?'));
$sql = "SELECT
produit.id,
produit.reference
FROM ".$this->tableprefix."produit as produit
WHERE produit.id = ? AND
produit.reference IN ($sqlConditionsPlaceholder)
LIMIT 1;";
$product = $this->execSQLNoJsonReturn(
$sql,
array_merge(
[$productCoverId],
ProductConstant::PRODUCT_COVER_REFERENCE_LIST
)
);
if(!empty($product)){
return $product[0];
$product = $this->getProductByProductId($productCoverId);
if($product == null){
return null;
}
$productCoverType = $this->getProductTypeByKey(ProductConstant::PRODUCT_COVER_TYPE_KEY);
if($product["fk_product_type_id"] == $productCoverType["id"]){
return $product;
}
return null;
}
private function isProductAlreadyExistInDevis($productId,$devisId){
$sql = "SELECT
@ -3396,6 +3385,22 @@ class Bdd {
$this->insertDevisArticle(devisId: $devisId, articleId: $productId,idNextcloud: $idNextcloud);
}
}
private function getProductByProductId($productId){
$sql = "SELECT
produit.id,
produit.reference,
produit.fk_product_type_id
FROM ".$this->tableprefix."produit as produit
WHERE produit.id = ?
LIMIT 1;";
$result = $this->execSQLNoJsonReturn($sql,[$productId]);
if(!empty($result)){
return $result[0];
}
return null;
}
public function setDefuntCover($defuntId, $productCoverId){
$defunt = $this->getDefuntById($defuntId);
if($defunt == null){
@ -3409,13 +3414,14 @@ class Bdd {
return null;
}
$productCoverReferencesList = ProductConstant::PRODUCT_COVER_REFERENCE_LIST;
foreach($productCoverReferencesList as $currentProductCoverReference){
if($currentProductCoverReference === $product["reference"]){
$coverProductList = $this->getProductsByProductTypeKey(ProductConstant::PRODUCT_COVER_TYPE_KEY);
$coverProductList = json_decode($coverProductList);
foreach($coverProductList as $currentCoverProduct){
if($currentCoverProduct->id == $product["id"]){
$this->createProductDevisIfNotExist($product["id"],$defunt["devis_id"]);
}
else{
$this->removeProductFromDevisByProductReference($currentProductCoverReference,$defunt["devis_id"]);
$this->removeProductFromDevis($currentCoverProduct->id,$defunt["devis_id"]);
}
}
return true;

View File

@ -331,29 +331,31 @@ class InvoiceRecapService {
// le cadre des articles
// ***********************
// cadre avec 18 lignes max ! et 118 de hauteur --> 80 + 118 = 198 pour les traits verticaux
$pdf->SetLineWidth(0.2); $pdf->Rect(5, 80, 200, 153, "D");
$pdf->SetLineWidth(0.2);
$pdf->Rect(5, 80, 200, 153, "D");
// cadre titre des colonnes
$pdf->SetFillColor(255);
$pdf->Line(5, 90, 205, 90);
// les traits verticaux colonnes
$pdf->Line(145, 80, 145, 233); $pdf->Line(163, 80, 163, 233);
$pdf->Line(145, 80, 145, 233);
$pdf->Line(163, 80, 163, 233);
if($num_page == $nb_page){
$pdf->Line(183, 80, 183, 240);
$pdf->Line(25, 80, 25, 225);
$pdf->Line(46, 80, 46, 225);
$pdf->Line(84, 80, 84, 225);
$pdf->Line(99, 80, 99, 225);
}
else{
$pdf->Line(183, 80, 183, 233);
$pdf->Line(25, 80, 25, 233);
$pdf->Line(46, 80, 46, 233);
$pdf->Line(84, 80, 84, 233);
$pdf->Line(99, 80, 99, 233);
}
// titre colonne
$pdf->SetXY( 1, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 30, 8, FileExportHelpers::FormatTextForExport(""), 0, 0, 'C');
$pdf->SetXY( 26, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 18, 8, "Date", 0, 0, 'C');
$pdf->SetXY( 47, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 35, 8, FileExportHelpers::FormatTextForExport("Défunt"), 0, 0, 'C');
$pdf->SetXY( 85, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 60, 8, FileExportHelpers::FormatTextForExport("Articles"), 0, 0, 'C');
$pdf->SetXY( 47, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 50, 8, FileExportHelpers::FormatTextForExport("Défunt"), 0, 0, 'C');
$pdf->SetXY( 100, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 45, 8, FileExportHelpers::FormatTextForExport("Articles"), 0, 0, 'C');
$pdf->SetXY( 147, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 13, 8, "H.T.", 0, 0, 'C');
$pdf->SetXY( 168, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 10, 8, "TVA 20%", 0, 0, 'C');
$pdf->SetXY( 183, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 22, 8, "T.T.C", 0, 0, 'C');
@ -372,10 +374,19 @@ class InvoiceRecapService {
for ($index_facture_position; $index_facture_position < ($init_index + $max_nb_toget) ; $index_facture_position++) {
$date_soin_temp = new DateTime($mois[$index_facture_position]['date_soin']);
$defuntNameText = $mois[$index_facture_position]['defunt'];
$defuntNameTextWidth = $pdf->GetStringWidth($defuntNameText);
$defuntNameTextIsMultiline = $defuntNameTextWidth >= 50;
$pdf->SetXY( 6, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, $mois[$index_facture_position]['num'], 0, 0, '');
$pdf->SetXY( 29, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, utf8_decode($formatter_ds->format($date_soin_temp)), 0, 0, '');
$pdf->SetXY( 47, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->MultiCell( 35, 5, FileExportHelpers::FormatTextForExport($defuntNameText),0,'L');
$pdf->SetXY( 85, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 38, 5, FileExportHelpers::FormatTextForExport($mois[$index_facture_position]['produit_references']), 0, 0, '');
$pdf->SetXY( 47, $y_facture );
$pdf->SetFont('ComicSans','',8);
if($defuntNameTextIsMultiline){
$pdf->MultiCell( 50, 5, FileExportHelpers::FormatTextForExport($defuntNameText),0,'L');
}
else{
$pdf->Cell( 50, 5, FileExportHelpers::FormatTextForExport($defuntNameText),0);
}
$pdf->SetXY( 100, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 38, 5, FileExportHelpers::FormatTextForExport($mois[$index_facture_position]['produit_references']), 0, 0, '');
$pdf->SetXY( 147, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 13, 5, number_format($mois[$index_facture_position]['montant_htc'],2,'.','').chr(128), 0, 0, 'C');
$pdf->SetXY( 168, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 10, 5, number_format($mois[$index_facture_position]['montant_tva'],2,'.','').chr(128), 0, 0, 'C');
$pdf->SetXY( 183, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 22, 5, number_format($mois[$index_facture_position]['montant_ttc'],2,'.','').chr(128), 0, 0, 'C');
@ -384,8 +395,6 @@ class InvoiceRecapService {
$montant_tva_total = $montant_tva_total+$mois[$index_facture_position]['montant_tva'];
$montant_ttc_total = $montant_ttc_total+$mois[$index_facture_position]['montant_ttc'];
$defuntNameTextWidth = $pdf->GetStringWidth($defuntNameText);
$defuntNameTextIsMultiline = $defuntNameTextWidth > 35;
if($defuntNameTextIsMultiline){
$y_facture=$y_facture+5;
}
@ -749,19 +758,19 @@ class InvoiceRecapService {
$pdf->Line(183, 80, 183, 240);
$pdf->Line(25, 80, 25, 225);
$pdf->Line(46, 80, 46, 225);
$pdf->Line(84, 80, 84, 225);
$pdf->Line(99, 80, 99, 225);
}
else{
$pdf->Line(183, 80, 183, 233);
$pdf->Line(25, 80, 25, 233);
$pdf->Line(46, 80, 46, 233);
$pdf->Line(84, 80, 84, 233);
$pdf->Line(99, 80, 99, 233);
}
// titre colonne
$pdf->SetXY( 1, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 30, 8, FileExportHelpers::FormatTextForExport(""), 0, 0, 'C');
$pdf->SetXY( 26, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 18, 8, "Date", 0, 0, 'C');
$pdf->SetXY( 47, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 35, 8, FileExportHelpers::FormatTextForExport("Défunt"), 0, 0, 'C');
$pdf->SetXY( 85, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 60, 8, "Articles", 0, 0, 'C');
$pdf->SetXY( 47, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 50, 8, FileExportHelpers::FormatTextForExport("Défunt"), 0, 0, 'C');
$pdf->SetXY( 100, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 45, 8, "Articles", 0, 0, 'C');
$pdf->SetXY( 147, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 13, 8, "H.T.", 0, 0, 'C');
$pdf->SetXY( 168, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 10, 8, "TVA 20%", 0, 0, 'C');
$pdf->SetXY( 183, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 22, 8, "T.T.C", 0, 0, 'C');
@ -780,10 +789,18 @@ class InvoiceRecapService {
for ($index_facture_position; $index_facture_position < ($init_index + $max_nb_toget) ; $index_facture_position++) {
$date_soin_temp = new DateTime($client[$index_facture_position]['date_soin']);
$defuntNameText = $client[$index_facture_position]['defunt'];
$defuntNameTextWidth = $pdf->GetStringWidth($defuntNameText);
$defuntNameTextIsMultiline = $defuntNameTextWidth >= 50;
$pdf->SetXY( 6, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, $client[$index_facture_position]['num'], 0, 0, '');
$pdf->SetXY( 29, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 18, 5, utf8_decode($formatter_ds->format($date_soin_temp)), 0, 0, '');
$pdf->SetXY( 47, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->MultiCell( 35, 5, FileExportHelpers::FormatTextForExport($defuntNameText));
$pdf->SetXY( 85, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, utf8_decode(html_entity_decode($client[$index_facture_position]['produit_references'])), 0, 0, '');
$pdf->SetXY( 47, $y_facture ); $pdf->SetFont('ComicSans','',8);
if($defuntNameTextIsMultiline){
$pdf->MultiCell( 50, 5, FileExportHelpers::FormatTextForExport($defuntNameText));
}
else{
$pdf->Cell( 50, 5, FileExportHelpers::FormatTextForExport($defuntNameText),0);
}
$pdf->SetXY( 100, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, utf8_decode(html_entity_decode($client[$index_facture_position]['produit_references'])), 0, 0, '');
$pdf->SetXY( 147, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 13, 5, number_format($client[$index_facture_position]['montant_htc'],2,'.','').chr(128), 0, 0, 'C');
$pdf->SetXY( 168, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 10, 5, number_format($client[$index_facture_position]['montant_tva'],2,'.','').chr(128), 0, 0, 'C');
$pdf->SetXY( 183, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 22, 5, number_format($client[$index_facture_position]['montant_ttc'],2,'.','').chr(128), 0, 0, 'C');
@ -791,9 +808,6 @@ class InvoiceRecapService {
$montant_ht_total = $montant_ht_total+$client[$index_facture_position]['montant_htc'];
$montant_tva_total = $montant_tva_total+$client[$index_facture_position]['montant_tva'];
$montant_ttc_total = $montant_ttc_total+$client[$index_facture_position]['montant_ttc'];
$defuntNameTextWidth = $pdf->GetStringWidth($defuntNameText);
$defuntNameTextIsMultiline = $defuntNameTextWidth > 35;
if($defuntNameTextIsMultiline){
$y_facture=$y_facture+5;
}