FactureManager

đź”§ setModuleCode

Fonction permettant la récupération de tous les modules-code, settings, li-code ... de l'objet
function setModuleCode():array { $all_settings = fwp7_param_objet_settings_list('',$this->id_type,'true'); $tligs_codes = fwp7_param_objet_tlig_list('',$this->id_type,'true'); $module_codes = fwp7_param_objet_att_list('',$this->id_type,'true'); $ligs_codes = fwp7_param_objet_lig_list('',$this->id_type,'173','true'); $result = array(); foreach ($all_settings as $item) { if (!empty($item['id_objsettings'])) { // définition de la clé de concatenation. $concat_key = "setting_".$item["code"]."_".$item["key"]."_".$item["subkey"]; $result[$concat_key] = $item['value']; // ... (truncated)

↩️ Returns

(array)

đź”§ getModuleCodes

Récupère tous les modules code de l'ObjetType
function getModuleCodes():array{ return $this->facture_module_codes; }

↩️ Returns

(array)

đź”§ process_invoice_product_lines

Traitement des lignes de produit pour une facture Cette fonction gère le traitement des lignes de produit dans une facture : - Récupère tous les attributs nécessaires - Traite chaque ligne de la facture - Met à jour les informations produit, prix et autres champs associés
function process_invoice_product_lines($id_type, $id_obje, $global_modified_att, $isCreateLig = false, $isDeleteLig = false, $user_identification_interface = '') { // Get all necessary attribute IDs $attributes = $this->get_invoice_product_line_attributes($id_type); // Get the invoice lines from global modified attributes $lignes_de_facture = $global_modified_att[$id_type][$id_obje]["lig"][$attributes['att_tlig_ligne_de_produit']] ?? []; // If there are no lines or we're creating/deleting a line, return if (empty($lignes_de_facture) || $isCreateLig || $isDeleteLig) { return; } // Process each invoice line foreach ($lignes_de_facture as $key_lig_id => $value) { $this->update_invoice_product_line( $id_type, $id_obje, // ... (truncated)

⚙️ Parameters

↩️ Returns

(void)

đź”§ get_invoice_product_line_attributes

Récupère tous les identifiants d'attributs nécessaires pour le traitement des lignes de produit de facture
function get_invoice_product_line_attributes($id_type): array { return [ 'att_tlig_ligne_de_produit' => fwp7_param_template_tlg_get_number('', $id_type, 'ligne_de_documents'), 'att_tlig_produit' => fwp7_param_template_lig_get_number('', $id_type, fwp7_param_template_tlg_get_number('', $id_type, 'ligne_de_documents'), 'produit_facture'), 'att_id_type_produit' => fwp7_param_objet_setting_get('', $id_type, 'produit', 'id_type'), 'att_prod_puht_produit' => fwp7_param_template_lig_get_number('', $id_type, fwp7_param_template_tlg_get_number('', $id_type, 'ligne_de_documents'), 'prod_puht'), 'attnomproduit_personnalise' => fwp7_param_template_lig_get_number('', $id_type, fwp7_param_template_tlg_get_number('', $id_type, 'ligne_de_documents'), 'lig_produit_id_designation_metier'), 'attnomproduit_qty_lignedefacture' => fwp7_param_template_lig_get_number('', $id_type, fwp7_param_template_tlg_get_number('', $id_type, 'ligne_de_documents'), 'lig_produit_quantite'), 'att_prod_totalpuht_produit' => fwp7_param_template_lig_get_number('', $id_type, fwp7_param_template_tlg_get_number('', $id_type, 'ligne_de_documents'), 'lig_document_total_ht'), 'att_unite_produit' => fwp7_param_template_att_get_number('', '', 'unite_produit'), // ... (truncated)

⚙️ Parameters

↩️ Returns

(array) Tableau des identifiants d'attributs

đź”§ update_invoice_product_line

Met Ă  jour une ligne de produit de facture
function update_invoice_product_line($id_type, $id_obje, $key_lig_id, $value, $attributes, $user_identification_interface) { $line = fwc7_data_objet_lig('', $id_type, $id_obje, $attributes['att_tlig_ligne_de_produit'], $key_lig_id); $values_sets = []; // If product line is changed or added if (isset($value[$attributes['att_tlig_produit']])) { $product_id = $value[$attributes['att_tlig_produit']]['new']; $product = $product_id !== '' ? fwc7_data_objet_att('', $attributes['att_id_type_produit'], $product_id) : null; $modifier = new Facture_ProductLineModifier($id_type, $id_obje, $key_lig_id, $line, $product); $parent_product = $modifier->getProduitParent(); $child_product = $modifier->getChildProduct_selected(); $user_info = fwc7_TS_NOOA_user_infos(''); // ... (truncated)

⚙️ Parameters

↩️ Returns

(void)

đź”§ upsertStatutDeReglement

function upsertStatutDeReglement(){ // BROUILLON --> statut par défaut tant que la facture est en broulillon // A PAYER → Soldée = false ET Montant Réglé TTC = 0 (couleur Rouge) // PARTIELLEMENT PAYÉE → Soldée = false ET Montant Réglé TTC > 0 (couleur Orange) // PAYÉE → Soldée = true (couleur Vert) // message trop perçu potentielle )-> message(). // > récupérer le total TTC rémisé de la facture $TotalRemiseTTC = (float)$this->facture[$this->getModuleCodes()['att_remise_totttc']]; // > récupérer le total TTC de tous les règlements effectués $totalReglements = array_sum(array_column($this->reglements, 'lig2')); // avertissement si trop perçu $dataSet = []; if($totalReglements < $TotalRemiseTTC && $totalReglements !== 0 ){ $dataSet["att29"] = "partiellement_paye"; //fwk7_affiche_alert_message('Le total du règlement saisi complète partiellement le montant de la facture '.$this->facture["att1"].' (total : '.$TotalRemiseTTC. '€ )','warning'); } else if($totalReglements > $TotalRemiseTTC){ $dataSet["att29"] = "trop_percu"; //fwk7_affiche_alert_message('Le total du règlement saisi est supérieur au montant de la facture concernée '.$this->facture["att1"].' (total : '.$TotalRemiseTTC. '€ )','warning'); }else if($totalReglements == $TotalRemiseTTC){ // ... (truncated)

⚠️ Throws


đź”§ handleInterlocuteur

function handleInterlocuteur(){ $id_user = $this->facture["att25"]; return $id_user; }

↩️ Returns

(mixed)

đź”§ getAddressData

Récupère l'adresse d'intervention ou l'adresse de facturation depuis le devis et la formatte
function getAddressData() { // att des champs d'intervention $addressFields = ($this->addressType == 'FACTURATION') ? ['21', '22', '23', '24', '25'] : ['21', '22', '23', '24', '25']; // att des champs de facturation return [ 'adresseLigne1' => $this->facture["att" . $addressFields[0]], 'adresseLigne2' => $this->facture["att" . $addressFields[1]], 'cp' => $this->facture["att" . $addressFields[2]], 'ville' => $this->facture["att" . $addressFields[3]], 'pays' => $this->facture["att" . $addressFields[4]] ]; }

↩️ Returns

(array)

đź”§ getAddressDataIntervention

Récupère l'adresse d'intervention depuis le devis et la formatte
function getAddressDataIntervention() { $addressFields = ['92', '39', '40', '41', '42']; // att des champs d'intervention return [ 'adresseLigne1' => $this->facture["att" . $addressFields[0]], ]; }

↩️ Returns

(array)

đź”§ formatClientHeader

function formatClientHeader() { $html = ''; // nom de la société if ($this->client['att8'] == 'professionnel' || $this->client['att8'] == 'collectivite') { $html .= self::makeParagraph('<strong>'.$this->client["att9"].'</strong>'); } // nom du client et sa civilité $html .= self::makeParagraph('<strong>'. ($this->civilites[$this->client['att10']] ? $this->civilites[$this->client['att10']] . ' ' : ''). $this->client["att3"] . ' ' . fwk7_txt_toupper($this->client["att1"]).'</strong>' ); // ... (truncated)

↩️ Returns

(string)

đź”§ generateFormattedAddressIntervention

Méthode pour générer l'adresse d'intervention formatée
function generateFormattedAddressIntervention(): string { $addressData = $this->getAddressDataIntervention(); //$devisOBJ = $this->getDevisInfos(); $html = '<div style="font-size: 10px;">'; $html .= '<p style="line-height: 1em; font-weight: bold; font-size: 9px;">Adresse du chantier </p>'; $html .= $this->formatAddress($addressData); //$html .= $this->formatPhone(); $html .= '</div>'; return $html; }

↩️ Returns

(string)

đź”§ getAllContacts

function getAllContacts(){ // chercher sur la table client, tous les Contacts destinataire. $wc =array(); $wc[]=" att8 ='".$this->client["id_obje"]."' "; $all_contacts = fwc7_data_objet_atts('',MapperFacture::TYPE_CONTACT($this->id_type),"1",$wc); return array_column(array_values($all_contacts), 'att6'); }

↩️ Returns

(mixed)

đź”§ generateInfosFacture

Méthode pour générer les infos de la facture formatté
function generateInfosFacture(): string { $infoFacture = $this->getFactureInfos(); $infoDevis = $this->getDevisFacture(); $attDateFacture = fwp7_param_template_att_get_number('',$this->id_type,'att_date_facture'); $attDateEcheance = fwp7_param_template_att_get_number('',$this->id_type,'att_date_echeance'); $html = '<div style="margin-top: 5px">'. '<p style="font-size: 2em; font-weight: bold; line-height: 1em; color: '.MapperFacture::COULEUR_TEXT($this->id_type).';">Facture</p>'. '<p style="line-height: 1em; font-size: 10px;">N° '.$infoFacture['att1']. '</p>'. '<p style="line-height: 1em; font-size: 10px;">Devis en référence : '.$infoDevis['att4']. '</p>'. (!empty($infoFacture[$attDateFacture])?'<p style="line-height: 1em; font-size: 10px;">En date du : '.date('d/m/Y', strtotime($infoFacture[$attDateFacture])). '</p>':''). // ... (truncated)

↩️ Returns

(string)

đź”§ generateInfosAvoir

Méthode pour générer les infos de la facture formatté
function generateInfosAvoir(): string { $infoFacture = $this->getFactureInfos(); $attDateFacture = fwp7_param_template_att_get_number('',$this->id_type,'att_date_facture'); $attDateEcheance = fwp7_param_template_att_get_number('',$this->id_type,'att_date_echeance'); $html = '<div style="margin-top: 5px">'. '<p style="font-size: 2em; font-weight: bold; line-height: 1em; color: '.MapperFacture::COULEUR_TEXT($this->id_type).';">Avoir</p>'. '<p style="line-height: 1em; font-size: 10px;">Avoir : '.$infoFacture['att1'].'</p>'. '<p style="line-height: 1em; font-size: 10px;">'.$infoFacture['att9']. '</p>'. (!empty($infoFacture[$attDateFacture])?'<p style="line-height: 1em; font-size: 10px;">En date du : '.date('d/m/Y', strtotime($infoFacture[$attDateFacture])). '</p>':''). (!empty($infoFacture[$attDateEcheance])?'<p style="line-height: 1em; font-size: 10px;">Date d\'échéance : '.date('d/m/Y', strtotime($infoFacture[$attDateEcheance])). '</p>':''). // ... (truncated)

↩️ Returns

(string)

đź”§ generateTauxTVA

Méthode principale pour avoir les lignes de TVA de la facture
function generateTauxTVA(): string { $ligneDevis = fwc7_data_objet_ligs('', $this->id_type, $this->id_objet, MapperFacture::IDLIG_PRODUIT($this->id_type), 'all', 1, ''); $groupedArray = []; foreach ($ligneDevis as $item) { $tva_value = $item[MapperFacture::TAUX_TVA_PRODUIT($this->id_type)] ?? 'undefined'; // undefined si pas de TVA renseigné // s'assurer que $tva_value est bien une valeur numérique de type 5.5 / 10 / 20 / 0 // supprimer et trim de la valeur au caus ou (string)'%' persisterai $groupedArray[$tva_value][] = $item; } $resultString = ""; // ... (truncated)

↩️ Returns

(string)

đź”§ generateTotalFacture

Méthode pour générer les infos de la facture formatté
function generateTotalFacture(): string { $infoFacture = $this->getFactureInfos(); $infoCommande = $this->getThisComandebyFacture(); // Check du type de la facture, si "acompte" ou "intermédiaire" $typeFactureCorrespond = false; $typeFacture = $infoFacture[$this->getModuleCodes()['fac_type_partiel']]; if ($typeFacture == "acompte" || $typeFacture == "intermediaire") { $typeFactureCorrespond = true; } $html = '<div style="display: flex; justify-content: space-between; line-height: 0; width: 100%;">'; $html .= '<p style="text-align: left;"><strong>Total HT : </strong></p>'; // ... (truncated)

↩️ Returns

(string)

đź”§ getTamponAcquite

fonction permettant la récupération du chemin vers l'image de tampon facture acquitté
function getTamponAcquite(){ $imageTampon = '<p ><img src="'.fwp7_param_params_detail('','tampon_acquite').'" alt="image tampon facture acquité"></p>'; return $imageTampon; }

↩️ Returns

(string)