本文整理汇总了PHP中OrderInvoice::saveCarrierTaxCalculator方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderInvoice::saveCarrierTaxCalculator方法的具体用法?PHP OrderInvoice::saveCarrierTaxCalculator怎么用?PHP OrderInvoice::saveCarrierTaxCalculator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderInvoice
的用法示例。
在下文中一共展示了OrderInvoice::saveCarrierTaxCalculator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setInvoice
/**
* This method allows to generate first invoice of the current order
*/
public function setInvoice($use_existing_payment = false)
{
if (!$this->hasInvoice()) {
if ($id = (int) $this->hasDelivery()) {
$order_invoice = new OrderInvoice($id);
} else {
$order_invoice = new OrderInvoice();
}
$order_invoice->id_order = $this->id;
if (!$id) {
$order_invoice->number = 0;
}
$address = new Address((int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$carrier = new Carrier((int) $this->id_carrier);
$tax_calculator = $carrier->getTaxCalculator($address, $this->id, Configuration::get('PS_ATCP_SHIPWRAP'));
$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;
$order_invoice->total_paid_tax_incl = $this->total_paid_tax_incl;
$order_invoice->total_products = $this->total_products;
$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->save();
if (Configuration::get('PS_INVOICE')) {
$this->setLastInvoiceNumber($order_invoice->id, $this->id_shop);
}
if (Configuration::get('PS_ATCP_SHIPWRAP')) {
$wrapping_tax_calculator = Adapter_ServiceLocator::get('AverageTaxOfProductsTaxCalculator')->setIdOrder($this->id);
} else {
$wrapping_tax_manager = TaxManagerFactory::getManager($address, (int) Configuration::get('PS_GIFT_WRAPPING_TAX_RULES_GROUP'));
$wrapping_tax_calculator = $wrapping_tax_manager->getTaxCalculator();
}
$order_invoice->saveCarrierTaxCalculator($tax_calculator->getTaxesAmount($order_invoice->total_shipping_tax_excl, $order_invoice->total_shipping_tax_incl, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode));
$order_invoice->saveWrappingTaxCalculator($wrapping_tax_calculator->getTaxesAmount($order_invoice->total_wrapping_tax_excl, $order_invoice->total_wrapping_tax_incl, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode));
// Update order_carrier
$id_order_carrier = Db::getInstance()->getValue('
SELECT `id_order_carrier`
FROM `' . _DB_PREFIX_ . 'order_carrier`
WHERE `id_order` = ' . (int) $order_invoice->id_order . '
AND (`id_order_invoice` IS NULL OR `id_order_invoice` = 0)');
if ($id_order_carrier) {
$order_carrier = new OrderCarrier($id_order_carrier);
$order_carrier->id_order_invoice = (int) $order_invoice->id;
$order_carrier->update();
}
// Update order detail
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_detail`
SET `id_order_invoice` = ' . (int) $order_invoice->id . '
WHERE `id_order` = ' . (int) $order_invoice->id_order);
// Update order payment
if ($use_existing_payment) {
$id_order_payments = Db::getInstance()->executeS('
SELECT DISTINCT op.id_order_payment
FROM `' . _DB_PREFIX_ . 'order_payment` op
INNER JOIN `' . _DB_PREFIX_ . 'orders` o ON (o.reference = op.order_reference)
LEFT JOIN `' . _DB_PREFIX_ . 'order_invoice_payment` oip ON (oip.id_order_payment = op.id_order_payment)
WHERE (oip.id_order != ' . (int) $order_invoice->id_order . ' OR oip.id_order IS NULL) AND o.id_order = ' . (int) $order_invoice->id_order);
if (count($id_order_payments)) {
foreach ($id_order_payments as $order_payment) {
Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment`
SET
`id_order_invoice` = ' . (int) $order_invoice->id . ',
`id_order_payment` = ' . (int) $order_payment['id_order_payment'] . ',
`id_order` = ' . (int) $order_invoice->id_order);
}
// Clear cache
Cache::clean('order_invoice_paid_*');
}
}
// Update order cart rule
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_cart_rule`
SET `id_order_invoice` = ' . (int) $order_invoice->id . '
WHERE `id_order` = ' . (int) $order_invoice->id_order);
// Keep it for backward compatibility, to remove on 1.6 version
$this->invoice_date = $order_invoice->date_add;
if (Configuration::get('PS_INVOICE')) {
$this->invoice_number = $this->getInvoiceNumber($order_invoice->id);
$invoice_number = Hook::exec('actionSetInvoice', array(get_class($this) => $this, get_class($order_invoice) => $order_invoice, 'use_existing_payment' => (bool) $use_existing_payment));
if (is_numeric($invoice_number)) {
$this->invoice_number = (int) $invoice_number;
} else {
$this->invoice_number = $this->getInvoiceNumber($order_invoice->id);
}
}
$this->update();
}
}
示例2: setInvoice
/**
* This method allows to generate first invoice of the current order
*/
public function setInvoice($use_existing_payment = false)
{
if (Configuration::get('PS_INVOICE') && !$this->hasInvoice()) {
if ($id = (int) $this->hasDelivery()) {
$order_invoice = new OrderInvoice($id);
} else {
$order_invoice = new OrderInvoice();
}
$order_invoice->id_order = $this->id;
if (!$id) {
$order_invoice->number = 0;
}
$address = new Address((int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$carrier = new Carrier((int) $this->id_carrier);
$tax_calculator = $carrier->getTaxCalculator($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;
$order_invoice->total_paid_tax_incl = $this->total_paid_tax_incl;
$order_invoice->total_products = $this->total_products;
$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->save();
$this->setLastInvoiceNumber($order_invoice->id, $this->id_shop);
$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`
FROM `' . _DB_PREFIX_ . 'order_carrier`
WHERE `id_order` = ' . (int) $order_invoice->id_order . '
AND (`id_order_invoice` IS NULL OR `id_order_invoice` = 0)');
if ($id_order_carrier) {
$order_carrier = new OrderCarrier($id_order_carrier);
$order_carrier->id_order_invoice = (int) $order_invoice->id;
$order_carrier->update();
}
// Update order detail
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_detail`
SET `id_order_invoice` = ' . (int) $order_invoice->id . '
WHERE `id_order` = ' . (int) $order_invoice->id_order);
// Update order payment
if ($use_existing_payment) {
$id_order_payments = Db::getInstance()->executeS('
SELECT DISTINCT op.id_order_payment
FROM `' . _DB_PREFIX_ . 'order_payment` op
INNER JOIN `' . _DB_PREFIX_ . 'orders` o ON (o.reference = op.order_reference)
LEFT JOIN `' . _DB_PREFIX_ . 'order_invoice_payment` oip ON (oip.id_order_payment = op.id_order_payment)
WHERE (oip.id_order != ' . (int) $order_invoice->id_order . ' OR oip.id_order IS NULL) AND o.id_order = ' . (int) $order_invoice->id_order);
if (count($id_order_payments)) {
foreach ($id_order_payments as $order_payment) {
Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment`
SET
`id_order_invoice` = ' . (int) $order_invoice->id . ',
`id_order_payment` = ' . (int) $order_payment['id_order_payment'] . ',
`id_order` = ' . (int) $order_invoice->id_order);
}
// Clear cache
Cache::clean('order_invoice_paid_*');
}
}
// Update order cart rule
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_cart_rule`
SET `id_order_invoice` = ' . (int) $order_invoice->id . '
WHERE `id_order` = ' . (int) $order_invoice->id_order);
// Keep it for backward compatibility, to remove on 1.6 version
$this->invoice_date = $order_invoice->date_add;
$this->invoice_number = $this->getInvoiceNumber($order_invoice->id);
$this->update();
}
}
示例3: setInvoice
/**
* This method allows to generate first invoice of the current order
*/
public function setInvoice($use_existing_payment = false)
{
if (!$this->hasInvoice()) {
$order_invoice = new OrderInvoice();
$order_invoice->id_order = $this->id;
$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);
} 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;
$order_invoice->total_paid_tax_incl = $this->total_paid_tax_incl;
$order_invoice->total_products = $this->total_products;
$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`
FROM `' . _DB_PREFIX_ . 'order_carrier`
WHERE `id_order` = ' . (int) $order_invoice->id_order . '
AND (`id_order_invoice` IS NULL OR `id_order_invoice` = 0)');
if ($id_order_carrier) {
$order_carrier = new OrderCarrier($id_order_carrier);
$order_carrier->id_order_invoice = (int) $order_invoice->id;
$order_carrier->update();
}
// Update order detail
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_detail`
SET `id_order_invoice` = ' . (int) $order_invoice->id . '
WHERE `id_order` = ' . (int) $order_invoice->id_order);
// Update order payment
if ($use_existing_payment) {
$id_order_payments = Db::getInstance()->executeS('
SELECT op.id_order_payment
FROM `' . _DB_PREFIX_ . 'order_payment` op
INNER JOIN `' . _DB_PREFIX_ . 'orders` o ON (o.reference = op.order_reference)
LEFT JOIN `' . _DB_PREFIX_ . 'order_invoice_payment` oip ON (oip.id_order_payment = op.id_order_payment)
WHERE oip.id_order_payment IS NULL AND o.id_order = ' . (int) $order_invoice->id_order);
if (count($id_order_payments)) {
foreach ($id_order_payments as $order_payment) {
Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment`
SET
`id_order_invoice` = ' . (int) $order_invoice->id . ',
`id_order_payment` = ' . (int) $order_payment['id_order_payment'] . ',
`id_order` = ' . (int) $order_invoice->id_order);
}
}
}
// Update order cart rule
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_cart_rule`
SET `id_order_invoice` = ' . (int) $order_invoice->id . '
WHERE `id_order` = ' . (int) $order_invoice->id_order);
// Keep it for backward compatibility, to remove on 1.6 version
$this->invoice_date = $order_invoice->date_add;
$this->invoice_number = $order_invoice->number;
$this->update();
}
}