dolibarr 18.0.6
DiscountAbsolute Class Reference

Class to manage absolute discounts. More...

Public Member Functions

 __construct ($db)
 Constructor.
 
 fetch ($rowid, $fk_facture_source=0, $fk_invoice_supplier_source=0)
 Load object from database into memory.
 
 create ($user)
 Create a discount into database.
 
 delete ($user)
 Delete object in database.
 
 link_to_invoice ($rowidline, $rowidinvoice)
 Link the discount to a particular invoice line or a particular invoice.
 
 unlink_invoice ()
 Link the discount to a particular invoice line or a particular invoice.
 
 getAvailableDiscounts ($company='', $user='', $filter='', $maxvalue=0, $discount_type=0, $multicurrency=0)
 Return amount (with tax) of discounts currently available for a company, user or other criteria.
 
 getSumDepositsUsed ($invoice, $multicurrency=0)
 Return amount (with tax) of all deposits invoices used by invoice as a payment.
 
 getSumCreditNotesUsed ($invoice, $multicurrency=0)
 Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment.
 
 getSumFromThisCreditNotesNotUsed ($invoice, $multicurrency=0)
 
 getNomUrl ($withpicto, $option='invoice')
 Return clickable ref of object (with picto or not)
 
 initAsSpecimen ()
 Initialise an instance with random values.
 

Detailed Description

Class to manage absolute discounts.

Definition at line 29 of file discount.class.php.

Constructor & Destructor Documentation

◆ __construct()

DiscountAbsolute::__construct ( $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 119 of file discount.class.php.

Member Function Documentation

◆ create()

DiscountAbsolute::create ( $user)

Create a discount into database.

Parameters
User$userUser that create
Returns
int <0 if KO, >0 if OK

Definition at line 227 of file discount.class.php.

References description, dol_now(), dol_syslog(), and price2num().

◆ delete()

DiscountAbsolute::delete ( $user)

Delete object in database.

If fk_facture_source is defined, we delete all familiy with same fk_facture_source. If not, only with id is removed

Parameters
User$userObject of user asking to delete
Returns
int <0 if KO, >0 if OK

Definition at line 302 of file discount.class.php.

References dol_print_error(), dol_syslog(), CommonInvoice\TYPE_CREDIT_NOTE, and CommonInvoice\TYPE_DEPOSIT.

◆ fetch()

DiscountAbsolute::fetch ( $rowid,
$fk_facture_source = 0,
$fk_invoice_supplier_source = 0 )

Load object from database into memory.

Parameters
int$rowidid discount to load
int$fk_facture_sourcefk_facture_source
int$fk_invoice_supplier_sourcefk_invoice_supplier_source
Returns
int <0 if KO, =0 if not found, >0 if OK

Definition at line 133 of file discount.class.php.

References description, and dol_syslog().

◆ getAvailableDiscounts()

DiscountAbsolute::getAvailableDiscounts ( $company = '',
$user = '',
$filter = '',
$maxvalue = 0,
$discount_type = 0,
$multicurrency = 0 )

Return amount (with tax) of discounts currently available for a company, user or other criteria.

Parameters
Societe$companyObject third party for filter
User$userFiltre sur un user auteur des remises
string$filterFilter other. Warning: Do not use a user input value here.
int$maxvalueFilter on max value for discount
int$discount_type0 => customer discount, 1 => supplier discount
int$multicurrencyReturn multicurrency_amount instead of amount
Returns
int <0 if KO, amount otherwise

Definition at line 515 of file discount.class.php.

References dol_syslog(), and price2num().

◆ getNomUrl()

DiscountAbsolute::getNomUrl ( $withpicto,
$option = 'invoice' )

Return clickable ref of object (with picto or not)

Parameters
int$withpicto0=No picto, 1=Include picto into link, 2=Picto only
string$optionWhere to link to ('invoice' or 'discount')
Returns
string String with URL

Definition at line 689 of file discount.class.php.

References dol_escape_htmltag().

◆ getSumCreditNotesUsed()

DiscountAbsolute::getSumCreditNotesUsed ( $invoice,
$multicurrency = 0 )

Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment.

Parameters
CommonInvoice$invoiceObject invoice
int$multicurrency1=Return multicurrency_amount instead of amount. TODO Add a mode multicurrency = -1 to return array with amount + multicurrency amount
Returns
int <0 if KO, Sum of credit notes and excess received amount otherwise

Definition at line 610 of file discount.class.php.

References dol_print_error(), and dol_syslog().

◆ getSumDepositsUsed()

DiscountAbsolute::getSumDepositsUsed ( $invoice,
$multicurrency = 0 )

Return amount (with tax) of all deposits invoices used by invoice as a payment.

Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS or FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended).

Parameters
CommonInvoice$invoiceObject invoice (customer of supplier)
int$multicurrency1=Return multicurrency_amount instead of amount. TODO Add a mode multicurrency = -1 to return array with amount + multicurrency amount
Returns
int <0 if KO, Sum of credit notes and deposits amount otherwise

Definition at line 569 of file discount.class.php.

References dol_print_error(), and dol_syslog().

◆ getSumFromThisCreditNotesNotUsed()

DiscountAbsolute::getSumFromThisCreditNotesNotUsed ( $invoice,
$multicurrency = 0 )
Return amount (with tax) of all converted amount for this credit note
Parameters
CommonInvoice$invoiceObject invoice
int$multicurrencyReturn multicurrency_amount instead of amount. TODO Add a mode multicurrency = -1 to return array with amount + multicurrency amount
Returns
int <0 if KO, Sum of credit notes and deposits amount otherwise

Definition at line 650 of file discount.class.php.

References dol_print_error(), and dol_syslog().

◆ initAsSpecimen()

DiscountAbsolute::initAsSpecimen ( )

Initialise an instance with random values.

Used to build previews or test instances. id must be 0 if object instance is a specimen.

Returns
void

Definition at line 736 of file discount.class.php.

References description.

◆ link_to_invoice()

DiscountAbsolute::link_to_invoice ( $rowidline,
$rowidinvoice )

Link the discount to a particular invoice line or a particular invoice.

When discount is a global discount used as an invoice line, we link using rowidline. When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice

Parameters
int$rowidlineInvoice line id (To use discount into invoice lines)
int$rowidinvoiceInvoice id (To use discount as a credit note to reduce payment of invoice)
Returns
int <0 if KO, >0 if OK

Definition at line 426 of file discount.class.php.

References dol_syslog().

◆ unlink_invoice()

DiscountAbsolute::unlink_invoice ( )

Link the discount to a particular invoice line or a particular invoice.

Do not call this if discount is linked to a reconcialiated invoice

Returns
int <0 if KO, >0 if OK

Definition at line 482 of file discount.class.php.

References dol_syslog().


The documentation for this class was generated from the following file: