diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 79ff0d07ae6..a6818ecdfd1 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2019 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent @@ -212,7 +212,8 @@ if (empty($chartaccountcode)) $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; -$sql.= " aa.rowid as aarowid,"; +$sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; +$sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; $sql.= " co.code as country_code, co.label as country,"; $sql.= " s.tva_intra"; $parameters=array(); @@ -437,7 +438,9 @@ if ($result) { $code_sell_p_notset = ''; $objp->aarowid_suggest = $objp->aarowid; - if ($objp->type_l == 1) { + $isinEEC = isInEEC($objp->country_code); + + if ($objp->type_l == 1) { $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); if ($objp->aarowid == '') { $objp->aarowid_suggest = $aarowid_s; @@ -450,8 +453,19 @@ if ($result) { } if ($objp->code_sell_l == -1) $objp->code_sell_l=''; + if ($objp->country_sell == '1') { + $objp->code_sell_p = $objp->code_sell; + $objp->aarowid_suggest = $objp->aarowid; + } elseif ($isinEEC == true) { + $objp->code_sell_p = $objp->code_sell_intra; + $objp->aarowid_suggest = $objp->aarowid_intra; + } else { + $objp->code_sell_p = $objp->code_sell_export; + $objp->aarowid_suggest = $objp->aarowid_export; + } + if (! empty($objp->code_sell)) { - $objp->code_sell_p = $objp->code_sell; // Code on product + //$objp->code_sell_p = $objp->code_sell; // Code on product } else { $code_sell_p_notset = 'color:orange'; } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index d9fc881ce7b..512a5caa322 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2013-2016 Marcos García * Copyright (C) 2012-2013 Cédric Salvador - * Copyright (C) 2011-2017 Alexandre Spangaro + * Copyright (C) 2011-2019 Alexandre Spangaro * Copyright (C) 2014 Cédric Gross * Copyright (C) 2014-2015 Ferran Marcet * Copyright (C) 2015 Jean-François Ferry @@ -1179,24 +1179,21 @@ else print $formaccounting->select_account(GETPOST('accountancy_code_sell'), 'accountancy_code_sell', 1, null, 1, 1, ''); print ''; - if ($conf->global->MAIN_FEATURES_LEVEL) + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) - { - print ''.$langs->trans("ProductAccountancySellIntraCode").''; - print ''; - print $formaccounting->select_account(GETPOST('accountancy_code_sell_intra'), 'accountancy_code_sell_intra', 1, null, 1, 1, ''); - print ''; - } - - // Accountancy_code_sell_export - print ''.$langs->trans("ProductAccountancySellExportCode").''; + print ''.$langs->trans("ProductAccountancySellIntraCode").''; print ''; - print $formaccounting->select_account(GETPOST('accountancy_code_sell_export'), 'accountancy_code_sell_export', 1, null, 1, 1, ''); + print $formaccounting->select_account(GETPOST('accountancy_code_sell_intra'), 'accountancy_code_sell_intra', 1, null, 1, 1, ''); print ''; } + // Accountancy_code_sell_export + print ''.$langs->trans("ProductAccountancySellExportCode").''; + print ''; + print $formaccounting->select_account(GETPOST('accountancy_code_sell_export'), 'accountancy_code_sell_export', 1, null, 1, 1, ''); + print ''; + // Accountancy_code_buy print ''.$langs->trans("ProductAccountancyBuyCode").''; print '';