dolibarr  17.0.4
Public Member Functions | List of all members
DiscountAbsolute Class Reference

Class to manage absolute discounts. More...

Public Member Functions

 __construct ($db)
 Constructor. More...
 
 fetch ($rowid, $fk_facture_source=0, $fk_invoice_supplier_source=0)
 Load object from database into memory. More...
 
 create ($user)
 Create a discount into database. More...
 
 delete ($user)
 Delete object in database. More...
 
 link_to_invoice ($rowidline, $rowidinvoice)
 Link the discount to a particular invoice line or a particular invoice. More...
 
 unlink_invoice ()
 Link the discount to a particular invoice line or a particular invoice. More...
 
 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. More...
 
 getSumDepositsUsed ($invoice, $multicurrency=0)
 Return amount (with tax) of all deposits invoices used by invoice as a payment. More...
 
 getSumCreditNotesUsed ($invoice, $multicurrency=0)
 Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment. More...
 
 getSumFromThisCreditNotesNotUsed ($invoice, $multicurrency=0)
 
 getNomUrl ($withpicto, $option='invoice')
 Return clickable ref of object (with picto or not) More...
 
 initAsSpecimen ()
 Initialise an instance with random values. More...
 

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.

References db.

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.

◆ 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.

◆ 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.

◆ 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 514 of file discount.class.php.

◆ 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 688 of file discount.class.php.

◆ 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 609 of file discount.class.php.

◆ 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 568 of file discount.class.php.

◆ 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 649 of file discount.class.php.

◆ 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 735 of file discount.class.php.

◆ 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 425 of file discount.class.php.

◆ 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 481 of file discount.class.php.


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