VirtueMart  3.2.14.9808
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
calculationHelper Class Reference

Public Member Functions

 setVendorCurrency ($id)
 
 setVendorId ($id)
 
 getCartPrices ()
 
 setCartPrices ($cartPrices)
 
 setCartPricesMerge ($cartPrices)
 
 getCartData ()
 
 getProductPrices (&$product, $variant=0.0, $amount=0)
 
 calculateCostprice ($productId, $data)
 
 setRevert ($revert)
 
 fillVoidPrices (&$prices)
 
 getCheckoutPrices (&$cart)
 
 cartRuleCalculation ($rules, $baseprice, $TaxID=0, $DBTax=false)
 
 executeCalculation ($rules, $baseprice, $relateToBaseAmount=false, $setCartPrices=true)
 
 gatherEffectingRulesForProductPrice ($entrypoint, $id)
 
 gatherEffectingRulesForBill ($entrypoint, $cartVendorId=1)
 
 calculateDisplayedPlugins ($type)
 
 calculateShipmentPrice ()
 
 calculatePaymentPrice ()
 
 calculateCustomPriceWithTax ($price)
 
 writeRulePartEffectingQuery ($data, $field, $setAnd=0)
 
 interpreteMathOp ($rule, $price)
 
 roundInternal ($value, $name=0)
 
 testRulePartEffecting ($rule, $data)
 
 record_sort ($records, $field, $reverse=false)
 

Static Public Member Functions

static getInstance ()
 

Public Attributes

 $_cats
 
 $_deliveryCountry
 
 $_deliveryState
 
 $_currencyDisplay
 
 $_cart = null
 
 $productPrices
 
 $_amount = 1
 
 $_amountCart = 0.0
 
 $productVendorId
 
 $productCurrency
 
 $product_tax_id = 0
 
 $product_discount_id = 0
 
 $product_marge_id = 0
 
 $vendorCurrency = 0
 
 $inCart = FALSE
 
 $allrules = array()
 

Static Public Attributes

static $_instance
 

Protected Member Functions

 setShopperGroupIds ($shopperGroupIds=0, $vendorId=1)
 
 setCountryState ()
 
 getCalcRuleData ($calcRuleID)
 
 couponHandler ($_code)
 

Protected Attributes

 $_db
 
 $_shopperGroupId
 
 $_now
 
 $_nullDate
 
 $_debug
 
 $_manufacturerId
 
 $exchangeRateVendor = 0
 
 $exchangeRateShopper = 0
 
 $_internalDigits = 9
 
 $_revert = false
 

Private Member Functions

 __construct ()
 

Private Attributes

 $checkAutomaticSelected = false
 

Constructor & Destructor Documentation

calculationHelper::__construct ( )
private

Constructor,... sets the actual date and current currency

Author
Max Milbers
Geraint

Member Function Documentation

calculationHelper::calculateCostprice (   $productId,
  $data 
)
calculationHelper::calculateCustomPriceWithTax (   $price)
calculationHelper::calculateDisplayedPlugins (   $type)

New idea, we load for the display all plugins

Parameters
$type
calculationHelper::calculatePaymentPrice ( )

Calculates the effecting Payment prices for the calculation

Author
Max Milbers
Valerie Isaksen
Parameters
$codeThe Id of the paymentmethod
$valueamount of the money to transfere
$value$cartVendorId
Returns
$paymentCosts The amount of money the customer has to pay. Calculated in shop currency
calculationHelper::calculateShipmentPrice ( )

Calculates the effecting Shipment prices for the calculation

Author
Max Milbers
Valerie Isaksen
Parameters
$codeThe Id of the coupon
Returns
$rules ids of the coupons
calculationHelper::cartRuleCalculation (   $rules,
  $baseprice,
  $TaxID = 0,
  $DBTax = false 
)

Function to calculate discount/tax of cart rules.

Author
Max Milbers, Maik Künnemann
Returns
int $price the discount/tax
calculationHelper::couponHandler (   $_code)
protected

Get coupon details and calculate the value

Author
Oscar van Eijk
Parameters
$_codeCoupon code
calculationHelper::executeCalculation (   $rules,
  $baseprice,
  $relateToBaseAmount = false,
  $setCartPrices = true 
)

Function to execute the calculation of the gathered rules Ids.

Author
Max Milbers
Parameters
$rulesThe Ids of the products
$priceThe input price, if no rule is affecting, 0 gets returned
Returns
int $price the endprice
calculationHelper::fillVoidPrices ( $prices)
calculationHelper::gatherEffectingRulesForBill (   $entrypoint,
  $cartVendorId = 1 
)

Gathers the effecting rules for the calculation of the bill

Author
Max Milbers
Parameters
$entrypoint
$cartVendorId
Returns
$rules The rules that effects the Bill as Ids
calculationHelper::gatherEffectingRulesForProductPrice (   $entrypoint,
  $id 
)

Gatheres the rules which affects the product.

Author
Max Milbers
Parameters
$entrypointThe entrypoint how it should behave. Valid values should be Profit (Commission is a profit rule that is shared, maybe we remove shared and make a new entrypoint called profit) DBTax (Discount for wares, coupons) Tax DATax (Discount on money) Duty
Returns
$rules The rules that effects the product as Ids
calculationHelper::getCalcRuleData (   $calcRuleID)
protected

Get the data of the CalcRule ID if it is not there

Author
Maik Kuennemann
Parameters
$VatTaxIDID of the taxe rule
calculationHelper::getCartData ( )
calculationHelper::getCartPrices ( )
calculationHelper::getCheckoutPrices ( $cart)

function to start the calculation, here it is for the invoice in the checkout This function is partly implemented !

The function calls getProductPrices for every product except it is already known (maybe changed and adjusted with product amount value The single prices gets added in an array and already summed up.

Then simular to getProductPrices first the effecting rules are determined and calculated. Ah function to determine the coupon that effects the calculation is already implemented. But not completly in the calculation.

    Subtotal + Tax + Discount = Total
Author
Max Milbers
Parameters
int$productIdsThe Ids of the products
int$cartVendorIdThe Owner of the cart, this can be ignored in vm1.5
Returns
int $prices An array of the prices 'resultWithOutTax' The summed up baseprice of all products 'resultWithTax' The final price of all products with their tax, discount and so on 'discountBeforeTax' discounted price without tax which affects only the checkout (the tax of the products is in it) 'discountWithTax' discounted price taxed 'discountAfterTax' final result
static calculationHelper::getInstance ( )
static
calculationHelper::getProductPrices ( $product,
  $variant = 0.0,
  $amount = 0 
)

function to start the calculation, here it is for the product

The function first gathers the information of the product (maybe better done with using the model) After that the function gatherEffectingRulesForProductPrice writes the queries and gets the ids of the rules which affect the product The function executeCalculation makes the actual calculation according to the rules

Author
Max Milbers
Parameters
int$productThe product
int$catIdsWhen the category is already determined, then it makes sense to pass it, if not the function does it for you
Returns
int $prices An array of the prices 'basePrice' basePrice calculated in the shopcurrency 'basePriceWithTax' basePrice with Tax 'discountedPrice' before Tax 'priceWithoutTax' price Without Tax but with calculated discounts AFTER Tax. So it just shows how much the shopper saves, regardless which kind of tax 'discountAmount' the "you save X money" 'salesPrice' The final price, with all kind of discounts and Tax, except stuff that is only in the checkout
calculationHelper::interpreteMathOp (   $rule,
  $price 
)

This functions interprets the String that is entered in the calc_value_mathop field The first char is the signum of the function. The more this function can be enhanced maybe with function that works like operators, the easier it will be to make more complex disount/commission/profit formulas progressive, nonprogressive and so on.

Author
Max Milbers
Parameters
$mathopString reprasentation of the mathematical operation, valid ('+','-','+','-')
$valuefloat The value that affects the price
$currencyint the currency which should be used
$pricefloat The price to calculate
calculationHelper::record_sort (   $records,
  $field,
  $reverse = false 
)

Sorts indexed 2D array by a specified sub array key

Copyright richard at happymango dot me dot uk

Author
Max Milbers
calculationHelper::roundInternal (   $value,
  $name = 0 
)

Standard round function, we round every number with 6 fractionnumbers We need at least 4 to calculate something like 9.25% => 0.0925 2 digits Should be setable via config (just for the crazy case)

calculationHelper::setCartPrices (   $cartPrices)
calculationHelper::setCartPricesMerge (   $cartPrices)
calculationHelper::setCountryState ( )
protected
calculationHelper::setRevert (   $revert)
calculationHelper::setShopperGroupIds (   $shopperGroupIds = 0,
  $vendorId = 1 
)
protected
calculationHelper::setVendorCurrency (   $id)
calculationHelper::setVendorId (   $id)
calculationHelper::testRulePartEffecting (   $rule,
  $data 
)

Can test the tablefields Category, Country, State If the the data is 0 false is returned

calculationHelper::writeRulePartEffectingQuery (   $data,
  $field,
  $setAnd = 0 
)

This function just writes the query for gatherEffectingRulesForProductPrice When a condition is not set, it is handled like a set condition that affects it. So the users have only to add a value for the conditions they want to (You dont need to enter a start or end date when the rule should count everytime).

Author
Max Milbers
Parameters
$datathe ids of the rule, for exampel the ids of the categories that affect the rule
$fieldthe name of the field in the db, for exampel calc_categories to write a rule that asks for the field calc_categories
Returns
$q The query

Member Data Documentation

calculationHelper::$_amount = 1
calculationHelper::$_amountCart = 0.0
calculationHelper::$_cart = null
calculationHelper::$_cats
calculationHelper::$_currencyDisplay
calculationHelper::$_db
protected
calculationHelper::$_debug
protected
calculationHelper::$_deliveryCountry
calculationHelper::$_deliveryState
calculationHelper::$_instance
static
calculationHelper::$_internalDigits = 9
protected
calculationHelper::$_manufacturerId
protected
calculationHelper::$_now
protected
calculationHelper::$_nullDate
protected
calculationHelper::$_revert = false
protected
calculationHelper::$_shopperGroupId
protected
calculationHelper::$allrules = array()
calculationHelper::$checkAutomaticSelected = false
private
calculationHelper::$exchangeRateShopper = 0
protected
calculationHelper::$exchangeRateVendor = 0
protected
calculationHelper::$inCart = FALSE
calculationHelper::$product_discount_id = 0
calculationHelper::$product_marge_id = 0
calculationHelper::$product_tax_id = 0
calculationHelper::$productCurrency
calculationHelper::$productPrices
calculationHelper::$productVendorId
calculationHelper::$vendorCurrency = 0

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