From 2857619316b7af97f0e9cbe2726fa462969e4088 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Nov 2021 19:33:54 +0100 Subject: [PATCH] Clean code --- htdocs/accountancy/customer/list.php | 11 +++++++---- htdocs/accountancy/supplier/list.php | 24 +++++++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 23df93ec7d5..ab1ac678262 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -478,7 +478,6 @@ if ($result) { print ''; print ''; print ''; - //print ''; print ''; print ''; print ''; @@ -528,6 +527,9 @@ if ($result) { while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); + // product_type: 0 = service, 1 = product + // if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service + // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB ! $code_sell_l = ''; $code_sell_p = ''; @@ -662,7 +664,7 @@ if ($result) { // Vat rate $code_vat_differ = ''; - if ($product_static->tva_tx !== $facture_static_det->tva_tx && !empty($product_static->tva_tx) && !empty($facture_static_det->tva_tx)) { // Note: having a vat rate of 0 is often the normal case when sells is intra b2b or to export + if ($product_static->tva_tx !== $facture_static_det->tva_tx && price2num($product_static->tva_tx) && price2num($facture_static_det->tva_tx)) { // Note: having a vat rate of 0 is often the normal case when sells is intra b2b or to export $code_vat_differ = 'warning bold'; } print ''; @@ -731,12 +733,13 @@ if ($result) { // Column with checkbox print ''; + $ischecked = 0; if (!empty($suggestedid) && $suggestedaccountingaccountfor <> '') { - $ischecked=1; + $ischecked = 1; } elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') { $ischecked = 0; } - print ''; + print ''; print ''; print ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index b8fdfc6e0c5..a189727494c 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -529,11 +529,12 @@ if ($result) { while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); - // product_type: 0 = service ? 1 = product + // product_type: 0 = service, 1 = product // if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB ! $objp->code_buy_l = ''; $objp->code_buy_p = ''; + $objp->aarowid_suggest = ''; // Will be set later $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; @@ -575,10 +576,6 @@ if ($result) { $facturefourn_static_det->product_type = $objp->type_l; $facturefourn_static_det->desc = $objp->description; - $code_buy_p_notset = ''; - $code_buy_t_notset = ''; - $objp->aarowid_suggest = ''; // Will be set later - $accountingAccountArray = array( 'dom'=>$objp->aarowid, 'intra'=>$objp->aarowid_intra, @@ -601,6 +598,9 @@ if ($result) { } //var_dump($return); + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + // Not supported for suppliers + if (!empty($code_buy_p)) { // Value was defined previously } else { @@ -655,7 +655,7 @@ if ($result) { // Vat rate $code_vat_differ = ''; - if ($objp->vat_tx_l != $objp->vat_tx_p && !empty($objp->vat_tx_p) && !empty($objp->vat_tx_l)) { // Note: having a vat rate of 0 is often the normal case when sells is intra b2b or to export + if ($objp->vat_tx_l != $objp->vat_tx_p && price2num($objp->vat_tx_p) && price2num($objp->vat_tx_l)) { // Note: having a vat rate of 0 is often the normal case when sells is intra b2b or to export $code_vat_differ = 'warning bold'; } print ''; @@ -691,6 +691,11 @@ if ($result) { $shelp = ''; $ttype = 'help'; if ($suggestedaccountingaccountfor == 'eec') { $shelp = $langs->trans("SaleEEC"); + } elseif ($suggestedaccountingaccountfor == 'eecwithvat') { + $shelp = $langs->trans("SaleEECWithVAT"); + } elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') { + $shelp = $langs->trans("SaleEECWithoutVATNumber"); + $ttype = 'warning'; } elseif ($suggestedaccountingaccountfor == 'export') { $shelp = $langs->trans("SaleExport"); } @@ -719,12 +724,13 @@ if ($result) { // Column with checkbox print ''; - if (!empty($suggestedid)) { + $ischecked = 0; + if (!empty($suggestedid) && $suggestedaccountingaccountfor <> '') { $ischecked = 1; - } else { + } elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') { $ischecked = 0; } - print ''; + print ''; print ''; print '';