Class InvoiceEntry
Represents invoice entries and lets you create new or modify existing invoice entries
Syntax
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
Constructors
InvoiceEntry()
Initializes a new instance of the InvoiceEntry class.
Declaration
InvoiceEntry
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
Methods
getDiscount()
Gets the discount of the current InvoiceEntry object in percent.
Declaration
String getDiscount()
Returns
Type | Description |
---|---|
String | The discount in percent as a String-representation of a number with 2 decimals accuracy. |
Remarks
The save-function calculates the discount in percent and money. So if the discount is set in money (setDiscountMoney(Float)), you have to save the entry before getting the corresponding value in percent.
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
getDiscountMoney()
Gets the discount of the current InvoiceEntry object in money.
Declaration
String getDiscountMoney()
Returns
Type | Description |
---|---|
String | The discount in money as a String-representation of a number with 2 decimals accuracy. |
Remarks
The save-function calculates the discount in percent and money. So if the discount is set in percent (setDiscount()), you have to save the entry before getting the corresponding value in money with this function.
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
getPricePrUnit()
Returns the price per unit of the current InvoiceEntry object.
Declaration
String getPricePrUnit()
Returns
Type | Description |
---|---|
String | Price per unit as a String-representation of a number with 2 decimals accuracy. |
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
getValue(String)
Gets the value of the specified field.
Declaration
String getValue(String field)
Parameters
Type | Name | Description |
---|---|---|
String | field | Name of the field which contains the value. |
Returns
Type | Description |
---|---|
String | The value of the field. |
Remarks
Available fields:
- messageId the id which this invoice entry is connected to
- description the descriptive text of this invoice entry
- type ID of the type for this invoice entry
- quantity the number of units invoiced
- pricePrUnit price per unit (precision 2)
- discount discount in percentage for this invoice entry (precision 2)
- discountMoney discount in money (precision 2)
- date the date for this invoice entry
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
load(Integer)
Loads an existing InvoiceEntry object.
Declaration
Bool load(Integer id)
Parameters
Type | Name | Description |
---|---|---|
Integer | id | The ID of the invoice entry to be loaded. |
Returns
Type | Description |
---|---|
Bool |
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
save()
Saves the existing InvoiceEntry object and returns the ID.
Declaration
Integer save()
Returns
Type | Description |
---|---|
Integer | The ID of the saved InvoiceEntry object. |
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
setDiscount(Float)
Sets the discount of the current InvoiceEntry object with the given percent.
Declaration
Void setDiscount(Float percent)
Parameters
Type | Name | Description |
---|---|---|
Float | percent | The discount in percent. |
Returns
Type | Description |
---|---|
Void |
Remarks
If discount is set in both percent and money, the save-function use the money-version.
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
setDiscountMoney(Float)
Sets the discount of the current InvoiceEntry object with the given money.
Declaration
Void setDiscountMoney(Float money)
Parameters
Type | Name | Description |
---|---|---|
Float | money | The discount in money. |
Returns
Type | Description |
---|---|
Void |
Remarks
If both setDiscount() and this function has been used, the save-function uses the discount in money.
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
setPricePrUnit(Float)
Sets the price per unit for the current InvoiceEntry object with the given price.
Declaration
Void SetPricePrUnit(Float price)
Parameters
Type | Name | Description |
---|---|---|
Float | price | The price per unit. |
Returns
Type | Description |
---|---|
Void |
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());
setValue(String,String)
Sets a field of the current InvoiceEntry object with the given value.
Declaration
Void setValue(String field, String value)
Parameters
Type | Name | Description |
---|---|---|
String | field | The field to set, see list |
String | value | The value of the specified field. |
Returns
Type | Description |
---|---|
Void |
Remarks
Available fields:
- messageId the ID of the message which this invoice entry is connected to
- description a description of the invoice entry
- type the ID of the type which this invoice entry will be saved as
- quantity number of invoiced unites (this can be a float value)
- pricePrUnit price pr. unit (this can be a float value of precision 2)
- discount discount given in percentage (float value of precision 2). If discountMoney is also specified, this field will be ignored
- discountMoney discount in money
- date the date of the invoice entry
Examples
InvoiceEntry i;
i.setValue("description", "test");
i.setValue("quantity", "1");
i.setValue("pricePrUnit", "700");
i.setValue("discount", "0.2");
Date d; // Default value for date is today
i.setValue("date", d.toString());