ePages 6.10 - DE_EPAGES/Order/API/Object/LineItemContainer.pm

Package DE_EPAGES::Order::API::Object::LineItemContainer

object interface for LineItemContainer.

Base
DE_EPAGES::Object::API::Object::Object

Functions

addLineItemPayment
addLineItemShipping
addLineItemTax
businessContainer
className
container
customer
dbPackage
formatter
insertLineItem
needPayment
needShipping
recalculate
setLineItem
taxRate
user

addLineItemPayment

Adds a payment lineitem, if not exists yet and payment is required.

Syntax
$PaymentLineItem = $Container->addLineItemPayment($LineItems);
Input
$LineItems (ref.array.SalesLineItem + ShippingLineItem)
list of lineitems (optional)
Return
$PaymentLineItem (object)
payment line item

addLineItemShipping

Adds a shipping lineitem, if not exists yet and shipping is required.

Syntax
$ShippingLineItem = $Container->addLineItemShipping($LineItems);
Input
$LineItems (ref.array.SalesLineItem)
list of lineitems (optional)
Return
$ShippingLineItem (object)
shipping line item

addLineItemTax

Adds a tax lineitem for the given tax class, if not exists yet.

Syntax
$TaxLineItem = $Container->addLineItemTax($TaxClass);
Input
$TaxClass (object)
tax class
Return
$TaxLineItem (object)
tax line item

businessContainer

Returns the container it self if container is not child of a lineitem. DE_EPAGES::Order::API::Object::LineItem::container.

Syntax
$Me = $businessContainer->container;
Return
$Me (object)
self (current object)

className

Returns the class name, used for DAL access.

Syntax
$ClassName = $LineItemContainer->className;
Return
$ClassName (String)
class name

container

Returns the container it self. Used for line item method DE_EPAGES::Order::API::Object::LineItem::container.

Syntax
$Me = $Container->container;
Return
$Me (object)
self (current object)

customer

returns customer of this container

Syntax
$Container->customer();
Return
$customer (object)
related customer

dbPackage

Returns the database package, used for DAL access.

Syntax
$DbPackage = $LineItemContainer->dbPackage;
Return
$DbPackage (String)
database package name

formatter

Returns the shop money formatter for the currency of container.

Syntax
$Formatter = $Container->formatter;
Return
$Formatter (object)
money formatter

insertLineItem

Returns the inserted lineitem. Generates the Alias and GUID of new lineitem.

Syntax
$LineItem = $Container->insertLineItem($Class, $hLineItem);
Example
$LineItem = $Container->insertLineItem(LoadClassByAlias('LineItemProduct'), {
        'Quantity'      => 4,
        'Name'          => 'epages merchant 5.0',
        'LineItemPrice' => 20000,
        'TaxRate'       => 0.16,
});
Input
$Class (object)
line item class
$hLineItem (ref.hash)
data
Return
$LineItem (object)
line item

needPayment

Returns true if the container need a payment lineitem (LineItemPrice !=0).

Syntax
$NeedPaymentLineItem = $Container->needPayment( $LineItems );
Input
$LineItems (ref.array.object)
list of lineitems (used attribute LineItemPrice) (optional)
Return
$NeedPaymentLineItem (boolean)
container need a payment lineitem

needShipping

Returns true if the container need a shipping lineitem.

Syntax
$NeedShippingLineItem = $Container->needShipping( $LineItems );
Input
$LineItems (ref.array.object)
list of lineitems (used attribute IsShippingRequired) (optional)
Return
$NeedShippingLineItem (boolean)
container need a shipping lineitem

recalculate

Call this function if lineitem prices has been changed, to recalculate GrandTotal, TotalTax and TotalBeforeTax. Before all lineitems of the container will be recalculated. The hValues will be forwarded to these lineitems.
GrandTotal = SUM (children.LineItemPrice)
TotalTax = SUM (children.TaxAmount)
TotalBeforeTax = GrandTotal - TotalTax

Syntax
$Container->recalculate($hValues);
Input
$hValues (ref.hash)
changed values (optional)

setLineItem

Creates a line item if this line item not exist, all keys of the line item will be compared with existing items.

Syntax
$LineItem = $Container->setLineItem($Class, $hLineItem);
Example
$LineItem = $Container->setLineItem(LoadClassByAlias('LineItemProduct'), {
        'Quantity'      => 4,
        'Name'          => 'epages merchant 5.0',
        'LineItemPrice' => 20000,
        'TaxRate'       => 0.16,
});
Input
$Class (object)
line item class
$hLineItem (ref.hash)
data
Return
$LineItem (object)
line item

taxRate

returns the tax rate for the given class, the area is saved at this container

Syntax
$Rate = $Container->taxRate($TaxClass);
Input
$TaxClass (object)
tax class
Return
$Rate (float)
tax rate

user

returns user of this container

Syntax
$Container->user();
Return
$user (object)
related user