Merge pull request #1478 from atm-alexis/develop
Add feature : import line from origin invoice in the new credit note
This commit is contained in:
commit
7a304bff62
@ -643,8 +643,37 @@ else if ($action == 'add' && $user->rights->facture->creer) {
|
|||||||
|
|
||||||
$id = $object->create($user);
|
$id = $object->create($user);
|
||||||
|
|
||||||
|
if(GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) {
|
||||||
|
|
||||||
|
$facture_source = new Facture($db); // fetch origin object
|
||||||
|
if($facture_source->fetch($object->fk_facture_source)>0) {
|
||||||
|
|
||||||
|
foreach($facture_source->lines as $line) {
|
||||||
|
|
||||||
|
$line->fk_facture = $object->id;
|
||||||
|
|
||||||
|
$line->subprice =-$line->subprice; // invert price for object
|
||||||
|
$line->pa_ht = -$line->pa_ht;
|
||||||
|
$line->total_ht=-$line->total_ht;
|
||||||
|
$line->total_tva=-$line->total_tva;
|
||||||
|
$line->total_ttc=-$line->total_ttc;
|
||||||
|
$line->total_localtax1=-$line->total_localtax1;
|
||||||
|
$line->total_localtax2=-$line->total_localtax2;
|
||||||
|
|
||||||
|
$line->insert();
|
||||||
|
|
||||||
|
$object->lines[] = $line; // insert new line in current object
|
||||||
|
}
|
||||||
|
|
||||||
|
$object->update_price(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Add predefined lines
|
// Add predefined lines
|
||||||
for($i = 1; $i <= $NBLINES; $i ++) {
|
/*
|
||||||
|
TODO delete
|
||||||
|
for($i = 1; $i <= $NBLINES; $i ++) {
|
||||||
if ($_POST ['idprod' . $i]) {
|
if ($_POST ['idprod' . $i]) {
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$product->fetch($_POST ['idprod' . $i]);
|
$product->fetch($_POST ['idprod' . $i]);
|
||||||
@ -652,7 +681,7 @@ else if ($action == 'add' && $user->rights->facture->creer) {
|
|||||||
$endday = dol_mktime(12, 0, 0, $_POST ['date_end' . $i . 'month'], $_POST ['date_end' . $i . 'day'], $_POST ['date_end' . $i . 'year']);
|
$endday = dol_mktime(12, 0, 0, $_POST ['date_end' . $i . 'month'], $_POST ['date_end' . $i . 'day'], $_POST ['date_end' . $i . 'year']);
|
||||||
$result = $object->addline($product->description, $product->price, $_POST ['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST ['idprod' . $i], $_POST ['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
|
$result = $object->addline($product->description, $product->price, $_POST ['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST ['idprod' . $i], $_POST ['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2000,12 +2029,12 @@ if ($action == 'create')
|
|||||||
if (empty($origin) && $socid > 0)
|
if (empty($origin) && $socid > 0)
|
||||||
{
|
{
|
||||||
// Credit note
|
// Credit note
|
||||||
print '<tr height="18"><td valign="middle">';
|
print '<tr height="18"><td valign="top">';
|
||||||
print '<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked=true' : '');
|
print '<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked=true' : '');
|
||||||
if (! $optionsav)
|
if (! $optionsav)
|
||||||
print ' disabled="disabled"';
|
print ' disabled="disabled"';
|
||||||
print '>';
|
print '>';
|
||||||
print '</td><td valign="middle">';
|
print '</td><td valign="top">';
|
||||||
print '<script type="text/javascript" language="javascript">
|
print '<script type="text/javascript" language="javascript">
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
jQuery("#fac_avoir").click(function() {
|
jQuery("#fac_avoir").click(function() {
|
||||||
@ -2028,6 +2057,9 @@ if ($action == 'create')
|
|||||||
$text .= '</select>';
|
$text .= '</select>';
|
||||||
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1);
|
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1);
|
||||||
print $desc;
|
print $desc;
|
||||||
|
|
||||||
|
print ' <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 '</td></tr>' . "\n";
|
print '</td></tr>' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,7 @@ InvoiceReplacementDesc=<b>Replacement invoice</b> is used to cancel and replace
|
|||||||
InvoiceAvoir=Credit note
|
InvoiceAvoir=Credit note
|
||||||
InvoiceAvoirAsk=Credit note to correct invoice
|
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).
|
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
|
||||||
ReplaceInvoice=Replace invoice %s
|
ReplaceInvoice=Replace invoice %s
|
||||||
ReplacementInvoice=Replacement invoice
|
ReplacementInvoice=Replacement invoice
|
||||||
ReplacedByInvoice=Replaced by invoice %s
|
ReplacedByInvoice=Replaced by invoice %s
|
||||||
|
|||||||
@ -28,6 +28,7 @@ InvoiceReplacementDesc=La <b>facture de remplacement</b> sert à annuler et remp
|
|||||||
InvoiceAvoir=Facture avoir
|
InvoiceAvoir=Facture avoir
|
||||||
InvoiceAvoirAsk=Facture avoir pour correction de la facture
|
InvoiceAvoirAsk=Facture avoir pour correction de la facture
|
||||||
InvoiceAvoirDesc=La <b>facture d'avoir</b> est une facture négative destinée à compenser un montant de facture qui diffère du montant réellement versé (suite à un trop versé par le client par erreur ou un manque non versé par le client suite à un retour produit par exemple).
|
InvoiceAvoirDesc=La <b>facture d'avoir</b> est une facture négative destinée à compenser un montant de facture qui diffère du montant réellement versé (suite à un trop versé par le client par erreur ou un manque non versé par le client suite à un retour produit par exemple).
|
||||||
|
invoiceAvoirWithLines=Créer la facture d'avoir avec les lignes de la facture d'origine
|
||||||
ReplaceInvoice=Remplace la facture %s
|
ReplaceInvoice=Remplace la facture %s
|
||||||
ReplacementInvoice=Remplacement facture
|
ReplacementInvoice=Remplacement facture
|
||||||
ReplacedByInvoice=Remplacée par la facture %s
|
ReplacedByInvoice=Remplacée par la facture %s
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user