fix : keep lines order when creating invoices from orders
This commit is contained in:
parent
6080e1f988
commit
ffa6cb0610
@ -635,6 +635,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
|||||||
|
|
||||||
$TFact = array();
|
$TFact = array();
|
||||||
$TFactThird = array();
|
$TFactThird = array();
|
||||||
|
$TFactThirdNbLines = array();
|
||||||
|
|
||||||
$nb_bills_created = 0;
|
$nb_bills_created = 0;
|
||||||
$lastid= 0;
|
$lastid= 0;
|
||||||
@ -685,6 +686,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
|||||||
$lastid = $objecttmp->id;
|
$lastid = $objecttmp->id;
|
||||||
|
|
||||||
$TFactThird[$cmd->socid] = $objecttmp;
|
$TFactThird[$cmd->socid] = $objecttmp;
|
||||||
|
$TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang
|
||||||
} else {
|
} else {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->error);
|
$errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->error);
|
||||||
@ -774,6 +776,11 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
|||||||
|
|
||||||
$objecttmp->context['createfromclone'];
|
$objecttmp->context['createfromclone'];
|
||||||
|
|
||||||
|
$rang = $lines[$i]->rang;
|
||||||
|
//there may already be rows from previous orders
|
||||||
|
if (!empty($createbills_onebythird))
|
||||||
|
$rang = $TFactThirdNbLines[$cmd->socid];
|
||||||
|
|
||||||
$result = $objecttmp->addline(
|
$result = $objecttmp->addline(
|
||||||
$desc,
|
$desc,
|
||||||
$lines[$i]->subprice,
|
$lines[$i]->subprice,
|
||||||
@ -791,7 +798,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
|||||||
'HT',
|
'HT',
|
||||||
0,
|
0,
|
||||||
$product_type,
|
$product_type,
|
||||||
$lines[$i]->rang,
|
$rang,
|
||||||
$lines[$i]->special_code,
|
$lines[$i]->special_code,
|
||||||
$objecttmp->origin,
|
$objecttmp->origin,
|
||||||
$lines[$i]->rowid,
|
$lines[$i]->rowid,
|
||||||
@ -806,6 +813,8 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
|||||||
);
|
);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$lineid = $result;
|
$lineid = $result;
|
||||||
|
if (!empty($createbills_onebythird)) //increment rang to keep order
|
||||||
|
$TFactThirdNbLines[$rcp->socid]++;
|
||||||
} else {
|
} else {
|
||||||
$lineid = 0;
|
$lineid = 0;
|
||||||
$error++;
|
$error++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user