[ task #640 ] Better deposit invoice management

This commit is contained in:
fhenry 2013-04-20 17:10:03 +02:00
parent 61b78666a2
commit cae761d522
4 changed files with 1983 additions and 1898 deletions

View File

@ -794,6 +794,8 @@ else if ($action == 'add' && $user->rights->facture->creer)
} }
} }
// Standard or deposit or proforma invoice // Standard or deposit or proforma invoice
if (($_POST['type'] == 0 || $_POST['type'] == 3 || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0) if (($_POST['type'] == 0 || $_POST['type'] == 3 || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0)
{ {
@ -872,6 +874,76 @@ else if ($action == 'add' && $user->rights->facture->creer)
if ($id > 0) if ($id > 0)
{ {
//If deposit invoice
if ($_POST['type'] == 3) {
$typeamount=GETPOST('typedeposit','alpha');
$valuedeposit=GETPOST('valuedeposit','int');
if ($typeamount=='amount') {
$amountdeposit=$valuedeposit;
}else {
$amountdeposit=0;
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement);
$srcobject = new $classname($db);
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add deposit line");
$result=$srcobject->fetch($object->origin_id);
if ($result > 0)
{
$totalamount=0;
$lines = $srcobject->lines;
$num=count($lines);
for ($i=0;$i<$num;$i++)
{
$totalamount=+$lines[$i]->subprice;
}
if ($totalamount!=0) {
$amountdeposit=($totalamount*$valuedeposit)/100;
}
}
else
{
$mesgs[]=$srcobject->error;
$error++;
}
}
$result = $object->addline(
$id,
$langs->trans('Deposit'),
$amountdeposit, //subprice
1, //quantity
$lines[$i]->tva_tx,
0, //localtax1_tx
0, //localtax2_tx
0, //fk_product
0, //remise_percent
0, //date_start
0, //date_end
0,
$lines[$i]->info_bits, //info_bits
0, //info_bits
'HT',
0,
0, //product_type
1,
$lines[$i]->special_code,
$object->origin,
0,
0,
0,
0,
$langs->trans('Deposit')
);
}else {
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement); $classname = ucfirst($subelement);
@ -994,6 +1066,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
$error++; $error++;
} }
} }
}
else else
{ {
$mesgs[]=$object->error; $mesgs[]=$object->error;
@ -2039,14 +2112,20 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }
if (empty($origin)) if ((empty($origin)) || (($origin=='propal') && (!empty($originid))))
{ {
// Deposit // Deposit
print '<tr height="18"><td width="16px" valign="middle">'; print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" name="type" value="3"'.(GETPOST('type')==3?' checked="checked"':'').'>'; print '<input type="radio" name="type" value="3"'.(GETPOST('type')==3?' checked="checked"':'').'>';
print '</td><td valign="middle">'; print '</td><td valign="middle" nowrap="nowrap">';
$desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1);
print $desc; print '<table class="nobordernopadding"><tr><td>'.$desc.'</td>';
if (($origin=='propal') ) {
print '<td><select name="typedeposit"><option value="amount">'.$langs->trans('FixAmount').'</option>';
print '<option value="variable">'.$langs->trans('VarAmount').'</option></select></td>';
print '<td>'.$langs->trans('Value').':<input type="text" name="valuedeposit" size="3" value="'.GETPOST('valuedeposit','int').'"/>';
}
print '</td></tr></table>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }

View File

@ -311,6 +311,8 @@ PaymentConditionShortPT_ORDER=On order
PaymentConditionPT_ORDER=On order PaymentConditionPT_ORDER=On order
PaymentConditionShortPT_5050=50-50 PaymentConditionShortPT_5050=50-50
PaymentConditionPT_5050=50%% in advance, 50%% on delivery PaymentConditionPT_5050=50%% in advance, 50%% on delivery
FixAmount=Fix amount
VarAmount=Variable amount (%% tot.)
# PaymentType # PaymentType
PaymentTypeVIR=Bank deposit PaymentTypeVIR=Bank deposit

View File

@ -287,6 +287,8 @@ TotalOfTwoDiscountMustEqualsOriginal=La suma del importe de los 2 nuevos descuen
ConfirmRemoveDiscount=¿Está seguro de querer eliminar este descuento? ConfirmRemoveDiscount=¿Está seguro de querer eliminar este descuento?
RelatedBill=Factura asociada RelatedBill=Factura asociada
RelatedBills=Facturas asociadas RelatedBills=Facturas asociadas
FixAmount=Importe fijo
VarAmount=Importe variable (%% total)
# PaymentConditions # PaymentConditions
PaymentConditionShortRECEP=A la recepción PaymentConditionShortRECEP=A la recepción

View File

@ -322,6 +322,8 @@ PaymentTypeVAD=Paiement en ligne
PaymentTypeShortVAD=Paiement en ligne PaymentTypeShortVAD=Paiement en ligne
PaymentTypeTRA=Paiement par traite PaymentTypeTRA=Paiement par traite
PaymentTypeShortTRA=Traite PaymentTypeShortTRA=Traite
FixAmount=Montant Fixe
VarAmount=Montant variable (%% tot.)
BankDetails=Coordonnées bancaires BankDetails=Coordonnées bancaires
BankCode=Code banque BankCode=Code banque