dolibarr  7.0.0-beta
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)
 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, $mode='customer')
 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 and deposits invoices used by invoice as a payment. More...
 
 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 30 of file discount.class.php.

Constructor & Destructor Documentation

DiscountAbsolute::__construct (   $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

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

Member Function Documentation

DiscountAbsolute::create (   $user)

Create a discount into database.

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

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

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

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

References $resql, dol_print_error(), and dol_syslog().

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

Load object from database into memory.

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

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

References $resql, description, and dol_syslog().

DiscountAbsolute::getAvailableDiscounts (   $company = '',
  $user = '',
  $filter = '',
  $maxvalue = 0,
  $mode = 'customer' 
)

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$filterFiltre autre
int$maxvalueFilter on max value for discount
string$mode'customer' = discounts the customer has, 'supplier' = discount i have at this supplier
Returns
int <0 if KO, amount otherwise

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

References $resql, and dol_syslog().

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

References dol_escape_htmltag().

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

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

Parameters
CommonInvoice$invoiceObject invoice
int$multicurrencyReturn multicurrency_amount instead of amount
Returns
int <0 if KO, Sum of credit notes and deposits amount otherwise

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

References $resql, dol_print_error(), and dol_syslog().

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 is on (not recommended).

Parameters
CommonInvoice$invoiceObject invoice (customer of supplier)
int$multicurrencyReturn multicurrency_amount instead of amount
Returns
int <0 if KO, Sum of credit notes and deposits amount otherwise

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

References $resql, dol_print_error(), and dol_syslog().

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

References description.

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 reduc payment of invoice)
Returns
int <0 if KO, >0 if OK

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

References $resql, and dol_syslog().

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

References $resql, and dol_syslog().


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