Merge branch 'develop-ezway' into production-hfc

This commit is contained in:
Tiavina 2025-09-05 10:43:53 +03:00
commit 085acaf193
27 changed files with 128 additions and 24 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

View File

@ -482,6 +482,7 @@ class Bdd
foreach($facturesList as $currentFacture) {
$produits = $this->getProduitsDevisByDevisId($currentFacture->id_devis);
$currentFacture->produits = $produits;
$currentFacture->totalPrices = $this->getFactureTotalPrices($currentFacture->id);
}
return json_encode($facturesList);
}
@ -4993,7 +4994,7 @@ COMMENTAIRES: ".$comment;
$conditions = [$clientGroupFacturationId,$year,$month];
if(!empty($mentionFilters)) {
$mentionsFilterPlaceholders = implode(',', array_fill(0, count($mentionFilters), '?'));
$sql .= " AND ". $this->tableprefix."devis.mentions IN ($mentionsFilterPlaceholders)";
$sql .= " AND "."devis.mentions IN ($mentionsFilterPlaceholders)";
$conditions = array_merge($conditions, $mentionFilters);
}
$sql .= ";";
@ -5221,6 +5222,26 @@ COMMENTAIRES: ".$comment;
return $devisList;
}
public function getDevisIdsGroupByFactureId($factureId,$mentionFilters = []){
$sql = "SELECT devis.id
FROM ".$this->tableprefix."devis as devis
WHERE devis.fk_facture_id = ? ";
$conditions = [$factureId];
if(!empty($mentionFilters)){
$mentionsFilterPlaceholders = implode(',', array_fill(0, count($mentionFilters), '?'));
$sql .= " AND devis.mentions IN ($mentionsFilterPlaceholders)";
$conditions = array_merge($conditions, $mentionFilters);
}
$sql.= ";";
$devisList = $this->execSQLNoJsonReturn($sql,$conditions);
$devisIds = [];
foreach($devisList as $devis){
$devisIds[] = $devis['id'];
}
return $devisIds;
}
public function getDevisDataGroupByFactureId($factureId, $mentionFilters = [])
{
$sql = "SELECT
@ -5658,4 +5679,79 @@ COMMENTAIRES: ".$comment;
}
return null;
}
private function getProductsTotalPrices($products)
{
$configs = json_decode($this->getConfiguration(BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD));
$currentConfig = $configs[0];
$totalHt = 0;
$totalTtc = 0;
foreach ($products as $product) {
$valueHt = $product['produit_price'] * $product['quantite'];
$valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt, $currentConfig->tva_default);
$totalHt += $valueHt;
$totalTtc += $valueTtc;
}
return [
"total_ht" => $totalHt,
"total_ttc" => $totalTtc,
"tva" => $currentConfig->tva_default
];
}
private function getDevisIdsListByFactureId($factureId){
$factureData = $this->getFactureByFactureId(factureId: $factureId);
$isFactureGroupOfDevis = $factureData["facture_type"] == FactureTypeConstant::TYPE_GROUP;
$factureDevisIdsList = [];
if($isFactureGroupOfDevis){
$isFactureForSingleClient = $factureData['fk_client_id'] != null && $factureData['fk_client_id'] != 0;
$devisMentionFilters = [
DevisMentionConstant::FACTURED_FORMATTED,
DevisMentionConstant::FACTURED
];
$devis = $this->getDevisByFkFactureId($factureId);
$factureGroupIsRelatedToAnyDevis = $devis != null;
if (!$factureGroupIsRelatedToAnyDevis) {
if($isFactureForSingleClient){
$factureDevisIdsList = $this->getDevisIdsByClientIdAndMonthYear(
$factureData['fk_client_id'],
$factureData['month'],
$factureData['year'],$devisMentionFilters
);
}else{
$factureDevisIdsList = $this->getDevisIdsByClientGroupFacturationIdAndMonthYear(
$factureData['fk_client_group_facturation_id'],
$factureData['month'],
$factureData['year'],$devisMentionFilters
);
}
}else{
$factureDevisIdsList = $this->getDevisIdsGroupByFactureId($factureId, $devisMentionFilters );
}
}
else{
$factureDevisIdsList = $factureData['id_devis'] ? [$factureData['id_devis']] : [];
}
return $factureDevisIdsList;
}
private function getFactureTotalPrices($factureId)
{
$factureDevisIds = $this->getDevisIdsListByFactureId($factureId);
$totalHt = 0;
$totalTtc = 0;
$tva = 0;
foreach($factureDevisIds as $devisId){
$products = $this->getDevisProduits($devisId);
$totalPrices = $this->getProductsTotalPrices($products);
$totalHt += $totalPrices["total_ht"];
$totalTtc += $totalPrices["total_ttc"];
$tva = $totalPrices["tva"];
}
return [
"total_ht" => PriceHelpers::formatDecimalPriceWithCurrency($totalHt),
"total_ttc" => PriceHelpers::formatDecimalPriceWithCurrency($totalTtc),
"tva" => PriceHelpers::formatDecimalPriceWithCurrency($tva)
];
}
}

View File

@ -17,4 +17,9 @@ class PriceHelpers
return number_format($price,2,'.','');
}
public static function formatDecimalPriceWithCurrency($price,$currency = '€')
{
return self::formatDecimalPrice($price) . $currency;
}
}

View File

@ -58,6 +58,7 @@ export class Facture {
this.clientName = ((myresp.facture_group_name == null || myresp.facture_group_name.length == 0) ? '-' : myresp.facture_group_name);
}
}
this.totalTtc = myresp?.totalPrices?.total_ttc ?? 0;
}
getDocumentStateLabel(documentState){
@ -86,6 +87,7 @@ export class Facture {
'<div>' + this.payment_date + '</div>',
'<div><span class="badge '+this.isDocumentAlreadyGeneratedClass+'">' + this.isDocumentAlreadyGeneratedLabel + '</span></div>',
'<div><span class="badge '+this.isDocumentAlreadySentClass+'">' + this.isDocumentAlreadySentLabel + '</span></div>',
'<div><span>'+this.totalTtc + '</span></div>',
'<div style="display:inline-block;margin-right:0px;width:80%;"><a href="' + this.baseUrl +'"><button>' + t('gestion', 'Open') + '</button></a></div><div data-modifier="facture" data-id=' + this.id + ' data-table="facture" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>',
];
return myrow;

View File

@ -39,6 +39,7 @@
<th><?php p($l->t('Date de paiement'));?></th>
<th><?php p($l->t('Générée'));?></th>
<th><?php p($l->t('Envoyée au client'));?></th>
<th><?php p($l->t('Total TTC'));?></th>
<th><?php p($l->t('Actions'));?></th>
</tr>
</thead>