From 177b5de7374f9939e1f7b6b1a6f057b424d7547a Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Wed, 19 Feb 2025 18:10:45 +0100 Subject: [PATCH] Clean code - no duplicate amount if not foreign currency --- htdocs/compta/facture/card.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e374e52450e..12438c60e71 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1413,8 +1413,9 @@ if (empty($reshook)) { $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'restricthtml')); $object->note_private = trim(GETPOST('note_private', 'restricthtml')); + $object->ref_customer = GETPOST('ref_client'); - $object->ref_client = $object->ref_customer; + $object->model_pdf = GETPOST('model'); $object->fk_project = GETPOSTINT('projectid'); $object->cond_reglement_id = (GETPOSTINT('type') == 3 ? 1 : GETPOST('cond_reglement_id')); @@ -3319,7 +3320,13 @@ if ($action == 'create') { $objectsrc->fetch_thirdparty(); $projectid = (!empty($projectid) ? $projectid : $objectsrc->fk_project); - $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : (!empty($objectsrc->ref_customer) ? $objectsrc->ref_customer : '')); + + // Propagate ref customer of src object to the invoice ? + if (getDolGlobalString("INVOICE_DO_NOT_PROPAGATE_REF_CUSTOMER_Of_SRC_TO_INVOICE")) { + $ref_client = ""; + } else { + $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : (!empty($objectsrc->ref_customer) ? $objectsrc->ref_customer : '')); + } // only if socid not filled else it's already done above if (empty($socid)) { @@ -3329,8 +3336,6 @@ if ($action == 'create') { $dateinvoice = (empty($dateinvoice) ? (!getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : '') : $dateinvoice); if ($element == 'expedition') { - $ref_client = (!empty($objectsrc->ref_customer) ? $objectsrc->ref_customer : ''); - $elem = $subelem = $objectsrc->origin; $expeoriginid = $objectsrc->origin_id; dol_include_once('/'.$elem.'/class/'.$subelem.'.class.php'); @@ -4235,21 +4240,23 @@ if ($action == 'create') { echo ' - '.$langs->trans('LatestRelatedBill').' '.end($objectsrc->linkedObjects['facture'])->getNomUrl(1); } echo ''; - print ''.$langs->trans('AmountHT').''.price($objectsrc->total_ht).''; - print ''.$langs->trans('AmountVAT').''.price($objectsrc->total_tva).""; + + print ''.$langs->trans('AmountHT').''.price($objectsrc->total_ht, 1, $langs, 1, -1, '', $conf->currency).''; + print ''.$langs->trans('AmountVAT').''.price($objectsrc->total_tva, 1, $langs, 1, -1, '', $conf->currency).""; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) { // Localtax1 - print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1).""; + print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1, 1, $langs, 1, -1, '', $conf->currency).""; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) { // Localtax2 - print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2).""; + print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2, 1, $langs, 1, -1, '', $conf->currency).""; } - print ''.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc).""; + print ''.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc, 1, $langs, 1, -1, '', $conf->currency).""; - if (isModEnabled('multicurrency')) { - print ''.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).''; - print ''.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva).""; - print ''.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc).""; + if (isModEnabled('multicurrency') && $objectsrc->multicurrency_code != $conf->currency) { + //var_dump($objectsrc); + print ''.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht, 1, $langs, 1, -1, '', $objectsrc->multicurrency_code).''; + print ''.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva, 1, $langs, 1, -1, '', $objectsrc->multicurrency_code).""; + print ''.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc, 1, $langs, 1, -1, '', $objectsrc->multicurrency_code).""; } }