NEW Can create an deposit from order using a percentage of qty.
This commit is contained in:
parent
c8f7b79c48
commit
9c73bb1aef
@ -1386,12 +1386,12 @@ if (empty($reshook))
|
||||
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines or deposit lines");
|
||||
$result = $srcobject->fetch($object->origin_id);
|
||||
|
||||
// If deposit invoice
|
||||
if ($_POST['type'] == Facture::TYPE_DEPOSIT)
|
||||
{
|
||||
$typeamount = GETPOST('typedeposit', 'alpha');
|
||||
$valuedeposit = GETPOST('valuedeposit', 'int');
|
||||
$typeamount = GETPOST('typedeposit', 'aZ09');
|
||||
$valuedeposit = GETPOST('valuedeposit', 'int');
|
||||
|
||||
// If deposit invoice
|
||||
if ($_POST['type'] == Facture::TYPE_DEPOSIT && in_array($typeamount, array('amount', 'variable')))
|
||||
{
|
||||
$amountdeposit = array();
|
||||
if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA))
|
||||
{
|
||||
@ -1419,7 +1419,7 @@ if (empty($reshook))
|
||||
{
|
||||
$amountdeposit[0] = $valuedeposit;
|
||||
}
|
||||
else
|
||||
elseif ($typeamount == 'variable')
|
||||
{
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -1449,11 +1449,15 @@ if (empty($reshook))
|
||||
|
||||
$amount_ttc_diff = $amountdeposit[0];
|
||||
}
|
||||
|
||||
foreach ($amountdeposit as $tva => $amount)
|
||||
{
|
||||
if (empty($amount)) continue;
|
||||
|
||||
$arraylist = array('amount' => 'FixAmount', 'variable' => 'VarAmount');
|
||||
$arraylist = array(
|
||||
'amount' => 'FixAmount',
|
||||
'variable' => 'VarAmount'
|
||||
);
|
||||
$descline = '(DEPOSIT)';
|
||||
//$descline.= ' - '.$langs->trans($arraylist[$typeamount]);
|
||||
if ($typeamount == 'amount') {
|
||||
@ -1500,7 +1504,8 @@ if (empty($reshook))
|
||||
$object->updateline($object->lines[0]->id, $object->lines[0]->desc, $subprice_diff, $object->lines[0]->qty, $object->lines[0]->remise_percent, $object->lines[0]->date_start, $object->lines[0]->date_end, $object->lines[0]->tva_tx, 0, 0, 'HT', $object->lines[0]->info_bits, $object->lines[0]->product_type, 0, 0, 0, $object->lines[0]->pa_ht, $object->lines[0]->label, 0, array(), 100);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if ($_POST['type'] != Facture::TYPE_DEPOSIT || ($_POST['type'] == Facture::TYPE_DEPOSIT && $typeamount == 'variablealllines'))
|
||||
{
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -1511,6 +1516,16 @@ if (empty($reshook))
|
||||
$lines = $srcobject->lines;
|
||||
}
|
||||
|
||||
// If we create a deposit with all lines and a percent, we change amount
|
||||
if ($_POST['type'] == Facture::TYPE_DEPOSIT && $typeamount == 'variablealllines') {
|
||||
if (is_array($lines)) {
|
||||
foreach($lines as $line) {
|
||||
// We keep ->subprice and ->pa_ht, but we change the qty
|
||||
$line->qty = price2num($line->qty * $valuedeposit / 100, 'MS');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fk_parent_line = 0;
|
||||
$num = count($lines);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
@ -2994,8 +3009,12 @@ if ($action == 'create')
|
||||
if (($origin == 'propal') || ($origin == 'commande'))
|
||||
{
|
||||
print '<td class="nowrap" style="padding-left: 5px">';
|
||||
$arraylist = array('amount' => $langs->transnoentitiesnoconv('FixAmount', $langs->transnoentitiesnoconv('Deposit')), 'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit')));
|
||||
print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1);
|
||||
$arraylist = array(
|
||||
'amount' => $langs->transnoentitiesnoconv('FixAmount', $langs->transnoentitiesnoconv('Deposit')),
|
||||
'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit')),
|
||||
'variablealllines' => $langs->transnoentitiesnoconv('VarAmountAllLines')
|
||||
);
|
||||
print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit', 'aZ09'), 0, 0, 0, '', 1);
|
||||
print '</td>';
|
||||
print '<td class="nowrap" style="padding-left: 5px">'.$langs->trans('Value').':<input type="text" id="valuedeposit" name="valuedeposit" size="3" value="'.GETPOST('valuedeposit', 'int').'"/>';
|
||||
}
|
||||
|
||||
@ -419,6 +419,7 @@ PaymentCondition14DENDMONTH=Within 14 days following the end of the month
|
||||
FixAmount=Fixed amount - 1 line with label '%s'
|
||||
VarAmount=Variable amount (%% tot.)
|
||||
VarAmountOneLine=Variable amount (%% tot.) - 1 line with label '%s'
|
||||
VarAmountAllLines=Variable amount (%% tot.) - all same lines
|
||||
# PaymentType
|
||||
PaymentTypeVIR=Bank transfer
|
||||
PaymentTypeShortVIR=Bank transfer
|
||||
|
||||
Loading…
Reference in New Issue
Block a user