[-] PDF : Bug Fixed #PSCFV-2735 - Missing tax details in order slip

This commit is contained in:
fBrignoli
2012-07-09 09:35:58 +00:00
parent 3dec1b324e
commit 06bebfe36a
5 changed files with 148 additions and 85 deletions
+2 -1
View File
@@ -321,7 +321,8 @@ class OrderInvoiceCore extends ObjectModel
if ($shipping_tax_amount > 0)
$taxes_breakdown[] = array(
'rate' => $order->carrier_tax_rate,
'total_amount' => $shipping_tax_amount
'total_amount' => $shipping_tax_amount,
'total_tax_excl' => $this->total_shipping_tax_excl
);
return $taxes_breakdown;
+13 -7
View File
@@ -78,14 +78,21 @@ class OrderSlipCore extends ObjectModel
public function addSlipDetail($orderDetailList, $productQtyList)
{
foreach ($orderDetailList as $key => $orderDetail)
foreach ($orderDetailList as $key => $id_order_detail)
{
if ($qty = (int)($productQtyList[$key]))
Db::getInstance()->insert('order_slip_detail', array(
'id_order_slip' => (int)$this->id,
'id_order_detail' => (int)$orderDetail,
'product_quantity' => $qty,
));
{
$order_detail = new OrderDetail((int)$id_order_detail);
if (Validate::isLoadedObject($order_detail))
Db::getInstance()->insert('order_slip_detail', array(
'id_order_slip' => (int)$this->id,
'id_order_detail' => (int)$id_order_detail,
'product_quantity' => $qty,
'amount_tax_excl' => $order_detail->unit_price_tax_excl * $qty,
'amount_tax_incl' => $order_detail->unit_price_tax_incl * $qty
));
}
}
}
@@ -281,6 +288,5 @@ class OrderSlipCore extends ObjectModel
Db::getInstance()->insert('order_slip_detail', $insertOrderSlip);
}
}
}
+101 -1
View File
@@ -82,6 +82,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
SELECT * FROM `'._DB_PREFIX_.'order_slip_detail`
WHERE `id_order_slip` = '.(int)$this->order_slip->id.'
AND `id_order_detail` = '.(int)$product['id_order_detail']);
$product['total_price_tax_excl'] = $order_slip_detail['amount_tax_excl'];
$product['total_price_tax_incl'] = $order_slip_detail['amount_tax_incl'];
}
@@ -107,7 +108,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
'delivery_address' => $formatted_delivery_address,
'invoice_address' => $formatted_invoice_address,
'tax_excluded_display' => Group::getPriceDisplayMethod((int)$customer->id_default_group),
'tax_tab' => '',
'tax_tab' => $this->getTaxTabContent(),
));
return $this->smarty->fetch($this->getTemplate('order-slip'));
@@ -130,5 +131,104 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
{
return 'order-slip-'.sprintf('%06d', $this->order_slip->id).'.pdf';
}
/**
* Returns the tax tab content
*/
public function getTaxTabContent()
{
$invoice_address = new Address((int)$this->order->id_address_invoice);
$tax_exempt = Configuration::get('VATNUMBER_MANAGEMENT')
&& !empty($invoice_address->vat_number)
&& $invoice_address->id_country != Configuration::get('VATNUMBER_COUNTRY');
$this->smarty->assign(array(
'tax_exempt' => $tax_exempt,
'use_one_after_another_method' => $this->order->useOneAfterAnotherTaxComputationMethod(),
'product_tax_breakdown' => $this->getProductTaxesBreakdown(),
'shipping_tax_breakdown' => $this->getShippingTaxesBreakdown(),
'order' => $this->order,
));
return $this->smarty->fetch($this->getTemplate('invoice.tax-tab'));
}
public function getProductTaxesBreakdown()
{
$tmp_tax_infos = array();
foreach ($this->order_slip->getOrdersSlipDetail((int)$this->order_slip->id) as $order_slip_details)
{
$tax_calculator = OrderDetail::getTaxCalculatorStatic((int)$order_slip_details['id_order_detail']);
$tax_amount = $tax_calculator->getTaxesAmount($order_slip_details['amount_tax_excl']);
if ($this->order->useOneAfterAnotherTaxComputationMethod())
{
foreach ($tax_amount as $tax_id => $amount)
{
$tax = new Tax((int)$tax_id);
if (!isset($total_tax_amount[$tax->rate]))
{
$tmp_tax_infos[$tax->rate]['name'] = $tax->name;
$tmp_tax_infos[$tax->rate]['total_price_tax_excl'] = $order_slip_details['amount_tax_excl'];
$tmp_tax_infos[$tax->rate]['total_amount'] = $amount;
}
else
{
$tmp_tax_infos[$tax->rate]['total_price_tax_excl'] += $order_slip_details['amount_tax_excl'];
$tmp_tax_infos[$tax->rate]['total_amount'] += $amount;
}
}
} else {
$infos = array(
'total_price_tax_excl' => 0,
'total_amount' => 0
);
$tax_rate = 0;
foreach ($tax_amount as $tax_id => $amount)
{
$tax = new Tax((int)$tax_id);
$tax_rate += $tax->rate;
$infos['total_price_tax_excl'] += $order_slip_details['amount_tax_excl'];
$infos['total_amount'] += $amount;
}
$tmp_tax_infos[$tax_rate] = $infos;
}
}
return $tmp_tax_infos;
}
public function getShippingTaxesBreakdown()
{
$taxes_breakdown = array();
$tax = new Tax();
$tax->rate = $this->order->carrier_tax_rate;
$tax_calculator = new TaxCalculator(array($tax));
$total_tax_excl = $tax_calculator->removeTaxes($this->order_slip->shipping_cost_amount);
$shipping_tax_amount = $this->order_slip->shipping_cost_amount - $total_tax_excl;
if ($shipping_tax_amount > 0)
$taxes_breakdown[] = array(
'rate' => $this->order->carrier_tax_rate,
'total_amount' => $shipping_tax_amount,
'total_tax_excl' => $total_tax_excl,
);
return $taxes_breakdown;
return array();
}
}
+7 -1
View File
@@ -41,6 +41,7 @@
<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>
{if isset($product_tax_breakdown)}
{foreach $product_tax_breakdown as $rate => $product_tax_infos}
<tr style="line-height:6px;background-color:{cycle values='#FFF,#DDD'};">
<td style="width: 30%">{l s='Products' pdf='true'}</td>
@@ -53,16 +54,20 @@
<td style="width: 20%; text-align: right;">{displayPrice currency=$order->id_currency price=$product_tax_infos.total_amount}</td>
</tr>
{/foreach}
{/if}
{if isset($shipping_tax_breakdown)}
{foreach $shipping_tax_breakdown as $shipping_tax_infos}
<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=$order_invoice->total_shipping_tax_excl}</td>
<td style="width: 20%; text-align: right;">{displayPrice currency=$order->id_currency price=$shipping_tax_infos.total_tax_excl}</td>
<td style="width: 20%; text-align: right;">{displayPrice currency=$order->id_currency price=$shipping_tax_infos.total_amount}</td>
</tr>
{/foreach}
{/if}
{if isset($ecotax_tax_breakdown)}
{foreach $ecotax_tax_breakdown as $ecotax_tax_infos}
{if $ecotax_tax_infos.ecotax_tax_excl > 0}
<tr style="line-height:6px;background-color:{cycle values='#FFF,#DDD'};">
@@ -73,6 +78,7 @@
</tr>
{/if}
{/foreach}
{/if}
</table>
{/if}
</td>
+25 -75
View File
@@ -86,49 +86,25 @@
<td style="width: 85%; text-align: right">
<table style="width: 100%; font-size: 8pt;">
<tr style="line-height:4px;">
<td style="text-align: left; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: 45%">{l s='Product / Reference' pdf='true'}</td>
<td style="text-align: left; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: 60%">{l s='Product / Reference' pdf='true'}</td>
<!-- unit price tax excluded is mandatory -->
{if !$tax_excluded_display}
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 10%">{l s='Unit Price' pdf='true'} <br />{l s='(Tax Excl.)' pdf='true'}</td>
{/if}
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 10%">{l s='Unit Price' pdf='true'}</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%">{if $order_slip->partial eq '1'}{l s='Partial refund' pdf='true'}{else}{l s='Total' pdf='true'}{/if}</td>
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 15%">{l s='Price' pdf='true'}<br />{l s='(Tax Excl.)' pdf='true'}</td>
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 15%">{l s='Price' pdf='true'}<br />{l s='(Tax Incl.)' pdf='true'}</td>
</tr>
{foreach $order_details as $order_detail}
{cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};">
<td style="text-align: left; width: 45%">{$order_detail.product_name}</td>
<!-- unit price tax excluded is mandatory -->
{if !$tax_excluded_display}
<td style="text-align: right; width: 10%">
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl}
</td>
{/if}
<td style="text-align: right; width: 10%">
{if $tax_excluded_display}
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl}
{else}
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_incl}
{/if}
</td>
<td style="text-align: right; width: 10%">
{if (isset($order_detail.reduction_amount) && $order_detail.reduction_amount > 0)}
-{displayPrice currency=$order->id_currency price=$order_detail.reduction_amount}
{else if (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)}
-{$order_detail.reduction_percent}%
{else}
--
{/if}
</td>
<td style="text-align: left; width: 60%">{$order_detail.product_name}</td>
<td style="text-align: center; width: 10%">{$order_detail.product_quantity}</td>
<td style="width: 15%; text-align: right; width: 15%">
{if $tax_excluded_display}
{displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_excl}
{else}
{displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_incl}
{/if}
<td style="text-align: right; width: 15%">
- {displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_excl}
</td>
<td style="text-align: right; width: 15%">
- {displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_incl}
</td>
</tr>
{foreach $order_detail.customizedDatas as $customization}
@@ -155,66 +131,40 @@
</table>
<table style="width: 100%">
{if $order_slip->shipping_cost_amount}
<tr style="line-height:5px;">
<td style="width: 85%; text-align: right; font-weight: bold">{l s='Shipping' pdf='true'}</td>
<td style="width: 15%; text-align: right;">- {displayPrice currency=$order->id_currency price=$order_slip->shipping_cost_amount}</td>
</tr>
{/if}
{if (($order->total_paid_tax_incl - $order->total_paid_tax_excl) > 0)}
<tr style="line-height:5px;">
<td style="width: 85%; text-align: right; font-weight: bold">{l s='Product Total (Tax Excl.)' pdf='true'}</td>
<td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order->total_products}</td>
<td style="width: 15%; text-align: right;">- {displayPrice currency=$order->id_currency price=$order->total_products}</td>
</tr>
<tr style="line-height:5px;">
<td style="width: 85%; text-align: right; font-weight: bold">{l s='Product Total (Tax Incl.)' pdf='true'}</td>
<td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order->total_products_wt}</td>
<td style="width: 15%; text-align: right;">- {displayPrice currency=$order->id_currency price=$order->total_products_wt}</td>
</tr>
{else}
<tr style="line-height:5px;">
<td style="width: 85%; text-align: right; font-weight: bold">{l s='Product Total' pdf='true'}</td>
<td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order->total_products}</td>
</tr>
{/if}
{if $order->total_discounts_tax_incl > 0}
<tr style="line-height:5px;">
<td style="text-align: right; font-weight: bold">{l s='Total Vouchers' pdf='true'}</td>
<td style="width: 15%; text-align: right;">-{displayPrice currency=$order->id_currency price=$order->total_discounts_tax_incl}</td>
</tr>
{/if}
{if $order->total_wrapping_tax_incl > 0}
<tr style="line-height:5px;">
<td style="text-align: right; font-weight: bold">{l s='Wrapping Cost' pdf='true'}</td>
<td style="width: 15%; text-align: right;">
{if $tax_excluded_display}
{displayPrice currency=$order->id_currency price=$order->total_wrapping_tax_excl}
{else}
{displayPrice currency=$order->id_currency price=$order->total_wrapping_tax_incl}
{/if}
</td>
</tr>
{/if}
{if $order->total_shipping_tax_incl > 0}
<tr style="line-height:5px;">
<td style="text-align: right; font-weight: bold">{l s='Shipping Cost' pdf='true'}</td>
<td style="width: 15%; text-align: right;">
{if $tax_excluded_display}
{displayPrice currency=$order->id_currency price=$order->total_shipping_tax_excl}
{else}
{displayPrice currency=$order->id_currency price=$order->total_shipping_tax_incl}
{/if}
</td>
<td style="width: 15%; text-align: right;">- {displayPrice currency=$order->id_currency price=$order->total_products}</td>
</tr>
{/if}
{if ($order->total_paid_tax_incl - $order->total_paid_tax_excl) > 0}
<tr style="line-height:5px;">
<td style="text-align: right; font-weight: bold">{l s='Total Tax' pdf='true'}</td>
<td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=($order->total_paid_tax_incl - $order->total_paid_tax_excl)}</td>
<td style="width: 15%; text-align: right;">- {displayPrice currency=$order->id_currency price=($order->total_paid_tax_incl - $order->total_paid_tax_excl)}</td>
</tr>
{/if}
<tr style="line-height:5px;">
<td style="text-align: right; font-weight: bold">{l s='Total' pdf='true'}</td>
<td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order->total_paid_tax_incl}</td>
<td style="text-align: right; font-weight: bold">{l s='Total ' pdf='true'}</td>
<td style="width: 15%; text-align: right;">- {displayPrice currency=$order->id_currency price=$order->total_paid_tax_incl}</td>
</tr>
</table>