[-] WS : Add tax for orders inside order_details api entity

This commit is contained in:
aKorczak
2012-02-21 15:05:57 +00:00
parent fcdca88cab
commit 0eae1cd4f5
+17 -4
View File
@@ -196,8 +196,12 @@ class OrderDetailCore extends ObjectModel
'discount_quantity_applied' => array(),
'download_hash' => array(),
'download_deadline' => array()
)
);
),
'associations' => array(
'taxes' => array('resource' => 'tax', 'getter' => 'getWsTaxes', 'setter' => false, 'virtual_entity' => true,
'fields' => array('id' => array()),
),
));
/** @var bool */
protected $outOfStock = false;
@@ -223,7 +227,7 @@ class OrderDetailCore extends ObjectModel
$id_shop = null;
if ($this->context != null && isset($this->context->shop))
$id_shop = $this->context->shop->getID();
return parent::__construct($id, $id_lang, $id_shop);
parent::__construct($id, $id_lang, $id_shop);
}
public static function getDownloadFromHash($hash)
@@ -577,5 +581,14 @@ class OrderDetailCore extends ObjectModel
$this->total_shipping_price_tax_incl = (float)($this->total_shipping_price_tax_excl * (1 + ($tax_rate / 100)));
$this->total_shipping_price_tax_incl = Tools::ps_round($this->total_shipping_price_tax_incl, 2);
}
public function getWsTaxes()
{
$query = new DbQuery();
$query->select('id_tax as id');
$query->from('order_detail_tax', 'tax');
$query->join('LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (tax.`id_order_detail` = od.`id_order_detail`)');
$query->where('od.`id_order_detail` = '.(int)$this->id_order_detail);
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
}
}