[-] PDF : Canadian taxes
This commit is contained in:
+14
-2
@@ -989,11 +989,23 @@ class CarrierCore extends ObjectModel
|
||||
*/
|
||||
public function getTaxesRate(Address $address)
|
||||
{
|
||||
$tax_manager = TaxManagerFactory::getManager($address, $this->getIdTaxRulesGroup());
|
||||
$tax_calculator = $tax_manager->getTaxCalculator();
|
||||
$tax_calculator = $this->getTaxCalculator($address);
|
||||
return $tax_calculator->getTotalRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the taxes calculator associated to the carrier
|
||||
*
|
||||
* @since 1.5
|
||||
* @param Address $address
|
||||
* @return
|
||||
*/
|
||||
public function getTaxCalculator(Address $address)
|
||||
{
|
||||
$tax_manager = TaxManagerFactory::getManager($address, $this->getIdTaxRulesGroup());
|
||||
return $tax_manager->getTaxCalculator();
|
||||
}
|
||||
|
||||
/**
|
||||
* This tricky method generates a sql clause to check if ranged data are overloaded by multishop
|
||||
*
|
||||
|
||||
@@ -1104,10 +1104,14 @@ class OrderCore extends ObjectModel
|
||||
$order_invoice->number = Configuration::get('PS_INVOICE_START_NUMBER');
|
||||
// If invoice start number has been set, you clean the value of this configuration
|
||||
if ($order_invoice->number)
|
||||
Configuration::updateValue('PS_INVOICE_START_NUMBER', false);
|
||||
Configuration::updateValue('PS_INVOICE_START_NUMBER', false );
|
||||
else
|
||||
$order_invoice->number = Order::getLastInvoiceNumber() + 1;
|
||||
|
||||
$invoice_address = new Address((int)$this->id_address_invoice);
|
||||
$carrier = new Carrier((int)$this->id_carrier);
|
||||
$tax_calculator = $carrier->getTaxCalculator($invoice_address);
|
||||
|
||||
$order_invoice->total_discount_tax_excl = $this->total_discounts_tax_excl;
|
||||
$order_invoice->total_discount_tax_incl = $this->total_discounts_tax_incl;
|
||||
$order_invoice->total_paid_tax_excl = $this->total_paid_tax_excl;
|
||||
@@ -1116,12 +1120,15 @@ class OrderCore extends ObjectModel
|
||||
$order_invoice->total_products_wt = $this->total_products_wt;
|
||||
$order_invoice->total_shipping_tax_excl = $this->total_shipping_tax_excl;
|
||||
$order_invoice->total_shipping_tax_incl = $this->total_shipping_tax_incl;
|
||||
$order_invoice->shipping_tax_computation_method = $tax_calculator->computation_method;
|
||||
$order_invoice->total_wrapping_tax_excl = $this->total_wrapping_tax_excl;
|
||||
$order_invoice->total_wrapping_tax_incl = $this->total_wrapping_tax_incl;
|
||||
|
||||
// Save Order invoice
|
||||
$order_invoice->add();
|
||||
|
||||
$order_invoice->saveCarrierTaxCalculator($tax_calculator->getTaxesAmount($order_invoice->total_shipping_tax_excl));
|
||||
|
||||
// Update order_carrier
|
||||
$id_order_carrier = Db::getInstance()->getValue('
|
||||
SELECT `id_order_carrier`
|
||||
|
||||
@@ -132,6 +132,9 @@ class OrderDetailCore extends ObjectModel
|
||||
/** @var float $tax_rate **/
|
||||
public $tax_rate;
|
||||
|
||||
/** @var float $tax_computation_method **/
|
||||
public $tax_computation_method;
|
||||
|
||||
/** @var int Id warehouse */
|
||||
public $id_warehouse;
|
||||
|
||||
@@ -176,6 +179,7 @@ class OrderDetailCore extends ObjectModel
|
||||
'product_weight' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
'tax_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
|
||||
'tax_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
'tax_computation_method' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'ecotax' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
'ecotax_tax_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
'discount_quantity_applied' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
||||
@@ -403,13 +407,14 @@ class OrderDetailCore extends ObjectModel
|
||||
|
||||
$tax_manager = TaxManagerFactory::getManager($this->vat_address, $id_tax_rules);
|
||||
$this->tax_calculator = $tax_manager->getTaxCalculator();
|
||||
$this->tax_computation_method = (int)$this->tax_calculator->computation_method;
|
||||
}
|
||||
|
||||
$this->ecotax_tax_rate = 0;
|
||||
if (!empty($product['ecotax']))
|
||||
$this->ecotax_tax_rate = Tax::getProductEcotaxRate($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
$this->tax_computation_method = (int)$this->tax_calculator->computation_method;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -132,7 +132,7 @@ class TaxCalculatorCore
|
||||
if ($this->computation_method == TaxCalculator::ONE_AFTER_ANOTHER_METHOD)
|
||||
{
|
||||
$taxes_amounts[$tax->id] = $price_te * (abs($tax->rate) / 100);
|
||||
$price_te = $price_te + $taxes_amounts[$tax->rate];
|
||||
$price_te = $price_te + $taxes_amounts[$tax->id];
|
||||
}
|
||||
else
|
||||
$taxes_amounts[$tax->id] = ($price_te * (abs($tax->rate) / 100));
|
||||
|
||||
Reference in New Issue
Block a user