Add option to set value of credit note by invoice lake of payment

This commit is contained in:
Alexis Algoud 2014-03-15 14:52:08 +01:00
parent 7a304bff62
commit 839641feaf
2 changed files with 17 additions and 1 deletions

View File

@ -670,6 +670,19 @@ else if ($action == 'add' && $user->rights->facture->creer) {
}
if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) {
$facture_source = new Facture($db); // fetch origin object if not previously defined
if($facture_source->fetch($object->fk_facture_source)>0) {
$totalpaye = $facture_source->getSommePaiement();
$totalcreditnotes = $facture_source->getSumCreditNotesUsed();
$totaldeposits = $facture_source->getSumDepositsUsed();
$remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits);
$object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC');
}
}
// Add predefined lines
/*
TODO delete
@ -2058,7 +2071,8 @@ if ($action == 'create')
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1);
print $desc;
print '&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').attr(\'checked\',\'checked\') }" /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
print '&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').attr(\'checked\',\'checked\'); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked="checked"':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
print '<br />&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').attr(\'checked\',\'checked\'); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked="checked"':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
print '</td></tr>' . "\n";
}

View File

@ -29,6 +29,8 @@ InvoiceAvoir=Credit note
InvoiceAvoirAsk=Credit note to correct invoice
InvoiceAvoirDesc=The <b>credit note</b> is a negative invoice used to solve fact that an invoice has an amount that differs than amount really paid (because customer paid too much by error, or will not paid completely since he returned some products for example).
invoiceAvoirWithLines=Create Credit Note with lines from the origin invoice
invoiceAvoirWithPaymentRestAmount=Create Credit Note with the amount of origin invoice payment's lake
invoiceAvoirLineWithPaymentRestAmount=Credit Note amount of invoice payment's lake
ReplaceInvoice=Replace invoice %s
ReplacementInvoice=Replacement invoice
ReplacedByInvoice=Replaced by invoice %s