Skip to content

Commit

Permalink
Merge pull request #11046 from aspangaro/develop
Browse files Browse the repository at this point in the history
FIX Accounting Customer dispatch with intra/export
  • Loading branch information
eldy committed Apr 19, 2019
2 parents f45462b + eab474e commit 7fd7688
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions htdocs/accountancy/customer/list.php
Expand Up @@ -421,6 +421,8 @@
$facture_static = new Facture($db);
$product_static = new Product($db);

$isSellerInEEC = isInEEC($mysoc);

while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result);

Expand All @@ -440,7 +442,7 @@
$code_sell_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid;

$isinEEC = isInEEC($objp->country_code);
$isBuyerInEEC = isInEEC($objp);

if ($objp->type_l == 1) {
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
Expand All @@ -455,15 +457,17 @@
}
if ($objp->code_sell_l == -1) $objp->code_sell_l='';

if ($objp->country_sell == '1') {
if ($objp->country_code == $mysoc->country_code) { // If buyer in same country than seller
$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 ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_p = $objp->code_sell_intra;
$objp->aarowid_suggest = $objp->aarowid_intra;
} else { // Foreign sale
$objp->code_sell_p = $objp->code_sell_export;
$objp->aarowid_suggest = $objp->aarowid_export;
}
}

if (! empty($objp->code_sell)) {
Expand Down

0 comments on commit 7fd7688

Please sign in to comment.