FIX Creation of credit note on invoice with deposit stole the discount.
This commit is contained in:
parent
2c07d2df22
commit
4f76626f51
@ -812,14 +812,14 @@ if (empty($reshook))
|
|||||||
$line->fk_parent_line = $fk_parent_line;
|
$line->fk_parent_line = $fk_parent_line;
|
||||||
|
|
||||||
$line->subprice =-$line->subprice; // invert price for object
|
$line->subprice =-$line->subprice; // invert price for object
|
||||||
$line->pa_ht = -$line->pa_ht;
|
$line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here
|
||||||
$line->total_ht=-$line->total_ht;
|
$line->total_ht=-$line->total_ht;
|
||||||
$line->total_tva=-$line->total_tva;
|
$line->total_tva=-$line->total_tva;
|
||||||
$line->total_ttc=-$line->total_ttc;
|
$line->total_ttc=-$line->total_ttc;
|
||||||
$line->total_localtax1=-$line->total_localtax1;
|
$line->total_localtax1=-$line->total_localtax1;
|
||||||
$line->total_localtax2=-$line->total_localtax2;
|
$line->total_localtax2=-$line->total_localtax2;
|
||||||
|
|
||||||
$result = $line->insert();
|
$result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked
|
||||||
|
|
||||||
$object->lines[] = $line; // insert new line in current object
|
$object->lines[] = $line; // insert new line in current object
|
||||||
|
|
||||||
|
|||||||
@ -4096,10 +4096,11 @@ class FactureLigne extends CommonInvoiceLine
|
|||||||
/**
|
/**
|
||||||
* Insert line into database
|
* Insert line into database
|
||||||
*
|
*
|
||||||
* @param int $notrigger 1 no triggers
|
* @param int $notrigger 1 no triggers
|
||||||
* @return int <0 if KO, >0 if OK
|
* @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function insert($notrigger=0)
|
function insert($notrigger=0, $noerrorifdiscountalreadylinked=0)
|
||||||
{
|
{
|
||||||
global $langs,$user,$conf;
|
global $langs,$user,$conf;
|
||||||
|
|
||||||
@ -4243,13 +4244,16 @@ class FactureLigne extends CommonInvoiceLine
|
|||||||
// Check if discount was found
|
// Check if discount was found
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// Check if discount not already affected to another invoice
|
// Check if discount not already affected to another invoice
|
||||||
if ($discount->fk_facture)
|
if ($discount->fk_facture_line > 0)
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorDiscountAlreadyUsed",$discount->id);
|
if (empty($noerrorifdiscountalreadylinked))
|
||||||
dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
|
{
|
||||||
$this->db->rollback();
|
$this->error=$langs->trans("ErrorDiscountAlreadyUsed",$discount->id);
|
||||||
return -3;
|
dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
|
||||||
|
$this->db->rollback();
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user