[-] 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));
|
||||
|
||||
@@ -1617,6 +1617,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
else
|
||||
$order_invoice->number = Order::getLastInvoiceNumber() + 1;
|
||||
|
||||
$invoice_address = new Address((int)$order->id_address_invoice);
|
||||
$carrier = new Carrier((int)$order->id_carrier);
|
||||
$tax_calculator = $carrier->getTaxCalculator($invoice_address);
|
||||
|
||||
$order_invoice->total_paid_tax_excl = Tools::ps_round((float)$cart->getOrderTotal(false, $total_method), 2);
|
||||
$order_invoice->total_paid_tax_incl = Tools::ps_round((float)$cart->getOrderTotal($use_taxes, $total_method), 2);
|
||||
$order_invoice->total_products = (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||
@@ -1626,6 +1630,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
$order_invoice->total_wrapping_tax_excl = abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING));
|
||||
$order_invoice->total_wrapping_tax_incl = abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING));
|
||||
$order_invoice->shipping_tax_computation_method = (int)$tax_calculator->computation_method;
|
||||
|
||||
// Update current order field, only shipping because other field is updated later
|
||||
$order->total_shipping += $order_invoice->total_shipping_tax_incl;
|
||||
@@ -1637,6 +1642,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order->total_wrapping_tax_incl += abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING));
|
||||
$order_invoice->add();
|
||||
|
||||
$order_invoice->saveCarrierTaxCalculator($tax_calculator->getTaxesAmount($order_invoice->total_shipping_tax_excl));
|
||||
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int)$order->id;
|
||||
$order_carrier->id_carrier = (int)$order->id_carrier;
|
||||
|
||||
@@ -1098,6 +1098,7 @@ CREATE TABLE `PREFIX_order_invoice` (
|
||||
`total_products_wt` decimal(17,2) NOT NULL DEFAULT '0.00',
|
||||
`total_shipping_tax_excl` decimal(17,2) NOT NULL DEFAULT '0.00',
|
||||
`total_shipping_tax_incl` decimal(17,2) NOT NULL DEFAULT '0.00',
|
||||
`shipping_tax_computation_method` int(10) unsigned NOT NULL,
|
||||
`total_wrapping_tax_excl` decimal(17,2) NOT NULL DEFAULT '0.00',
|
||||
`total_wrapping_tax_incl` decimal(17,2) NOT NULL DEFAULT '0.00',
|
||||
`note` text,
|
||||
@@ -1106,6 +1107,13 @@ CREATE TABLE `PREFIX_order_invoice` (
|
||||
KEY `id_order` (`id_order`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_order_invoice_tax` (
|
||||
`id_order_invoice` int(11) NOT NULL,
|
||||
`type` varchar(15) NOT NULL,
|
||||
`id_tax` int(11) NOT NULL,
|
||||
`amount` decimal(10,6) NOT NULL DEFAULT '0.000000'
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_order_detail` (
|
||||
`id_order_detail` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_order` int(10) unsigned NOT NULL,
|
||||
|
||||
@@ -11,3 +11,12 @@ INSERT INTO `PREFIX_hook_alias` (`name`, `alias`) VALUES ('displayMyAccountBlock
|
||||
|
||||
UPDATE `PREFIX_image_type` SET height = 189, width = 520 WHERE name = 'large_scene';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_order_invoice_tax` (
|
||||
`id_order_invoice` int(11) NOT NULL,
|
||||
`type` varchar(15) NOT NULL,
|
||||
`id_tax` int(11) NOT NULL,
|
||||
`amount` decimal(10,6) NOT NULL DEFAULT '0.000000'
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE `PREFIX_order_invoice`
|
||||
ADD `shipping_tax_computation_method` INT NOT NULL AFTER `total_shipping_tax_incl`;
|
||||
+11
-5
@@ -37,7 +37,9 @@
|
||||
<tr style="line-height:5px;">
|
||||
<td style="text-align: left; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: 30%">{l s='Tax Detail' pdf='true'}</td>
|
||||
<td style="text-align: right; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: 20%">{l s='Tax Rate' pdf='true'}</td>
|
||||
<td style="text-align: right; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: 20%">{l s='Total Tax Excl' pdf='true'}</td>
|
||||
{if !$use_one_after_another_method}
|
||||
<td style="text-align: right; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: 20%">{l s='Total Tax Excl' pdf='true'}</td>
|
||||
{/if}
|
||||
<td style="text-align: right; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: 20%">{l s='Total Tax' pdf='true'}</td>
|
||||
</tr>
|
||||
|
||||
@@ -46,11 +48,11 @@
|
||||
<tr style="line-height:6px;background-color:{cycle values='#FFF,#DDD'};">
|
||||
<td style="width: 30%">{l s='Products' pdf='true'}</td>
|
||||
<td style="width: 20%; text-align: right;">{$rate} %</td>
|
||||
<td style="width: 20%; text-align: right;">
|
||||
{if !$use_one_after_another_method}
|
||||
<td style="width: 20%; text-align: right;">
|
||||
{displayPrice currency=$order->id_currency price=$product_tax_infos.total_price_tax_excl}
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
<td style="width: 20%; text-align: right;">{displayPrice currency=$order->id_currency price=$product_tax_infos.total_amount}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
@@ -61,7 +63,9 @@
|
||||
<tr style="line-height:6px;background-color:{cycle values='#FFF,#DDD'};">
|
||||
<td style="width: 30%">{l s='Shipping' pdf='true'}</td>
|
||||
<td style="width: 20%; text-align: right;">{$shipping_tax_infos.rate} %</td>
|
||||
<td style="width: 20%; text-align: right;">{displayPrice currency=$order->id_currency price=$shipping_tax_infos.total_tax_excl}</td>
|
||||
{if !$use_one_after_another_method}
|
||||
<td style="width: 20%; text-align: right;">{displayPrice currency=$order->id_currency price=$shipping_tax_infos.total_tax_excl}</td>
|
||||
{/if}
|
||||
<td style="width: 20%; text-align: right;">{displayPrice currency=$order->id_currency price=$shipping_tax_infos.total_amount}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
@@ -73,7 +77,9 @@
|
||||
<tr style="line-height:6px;background-color:{cycle values='#FFF,#DDD'};">
|
||||
<td style="width: 30%">{l s='Ecotax' pdf='true'}</td>
|
||||
<td style="width: 20%; text-align: right;">{$ecotax_tax_infos.rate } %</td>
|
||||
<td style="width: 20%; text-align: right;">{displayPrice currency=$order->id_currency price=$ecotax_tax_infos.ecotax_tax_excl}</td>
|
||||
{if !$use_one_after_another_method}
|
||||
<td style="width: 20%; text-align: right;">{displayPrice currency=$order->id_currency price=$ecotax_tax_infos.ecotax_tax_excl}</td>
|
||||
{/if}
|
||||
<td style="width: 20%; text-align: right;">{displayPrice currency=$order->id_currency price=($ecotax_tax_infos.ecotax_tax_incl - $ecotax_tax_infos.ecotax_tax_excl)}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
+2
-2
@@ -113,7 +113,7 @@
|
||||
</td>
|
||||
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 10%">{l s='Discount' pdf='true'}</td>
|
||||
<td style="background-color: #4D4D4D; color: #FFF; text-align: center; font-weight: bold; width: 10%">{l s='Qty' pdf='true'}</td>
|
||||
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 15%">
|
||||
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: {if !$tax_excluded_display}15%{else}25%{/if}">
|
||||
{l s='Total' pdf='true'}
|
||||
{if $tax_excluded_display}
|
||||
{l s='(Tax Excl.)' pdf='true'}
|
||||
@@ -150,7 +150,7 @@
|
||||
{/if}
|
||||
</td>
|
||||
<td style="text-align: center; width: 10%">{$order_detail.product_quantity}</td>
|
||||
<td style="width: 15%; text-align: right; width: 15%">
|
||||
<td style="width: 15%; text-align: right; width: {if !$tax_excluded_display}15%{else}25%{/if}">
|
||||
{if $tax_excluded_display}
|
||||
{displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_excl}
|
||||
{else}
|
||||
|
||||
Reference in New Issue
Block a user