// Fixed #PSTEST-450 : number of digits displayed for prices is now 2

This commit is contained in:
bMancone
2012-01-16 14:27:51 +00:00
parent c89b354c53
commit 13ed870bde
3 changed files with 53 additions and 2 deletions
+21
View File
@@ -466,6 +466,27 @@ class SupplyOrderCore extends ObjectModel
return (new SupplyOrder((int)$id));
}
/**
* @see ObjectModel::hydrate()
*/
public function hydrate(array $data, $id_lang = null)
{
$this->id_lang = $id_lang;
if (isset($data[$this->def['primary']]))
$this->id = $data[$this->def['primary']];
foreach ($data as $key => $value)
{
if (array_key_exists($key, $this))
{
// formats prices and floats
if ($this->def['fields'][$key]['validate'] == 'isFloat' ||
$this->def['fields'][$key]['validate'] == 'isPrice')
$value = number_format($value, 2);
$this->$key = $value;
}
}
}
/*********************************\
*
* Webservices Specific Methods
+23 -1
View File
@@ -313,4 +313,26 @@ class SupplyOrderDetailCore extends ObjectModel
return $errors;
}
}
/**
* @see ObjectModel::hydrate()
*/
public function hydrate(array $data, $id_lang = null)
{
$this->id_lang = $id_lang;
if (isset($data[$this->def['primary']]))
$this->id = $data[$this->def['primary']];
foreach ($data as $key => $value)
{
if (array_key_exists($key, $this))
{
// formats prices and floats
if ($this->def['fields'][$key]['validate'] == 'isFloat' ||
$this->def['fields'][$key]['validate'] == 'isPrice')
$value = number_format($value, 2);
$this->$key = $value;
}
}
}
}
@@ -1148,10 +1148,18 @@ class AdminSupplyOrdersControllerCore extends AdminController
'price_with_order_discount_te', 'id_supply_order');
echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $keys)));
// overrides keys (in order to add FORMAT calls)
$keys = array('sod.id_product', 'sod.id_product_attribute', 'sod.reference', 'sod.supplier_reference', 'sod.ean13',
'sod.upc', 'sod.name',
'FORMAT(sod.unit_price_te, 2)', 'sod.quantity_expected', 'sod.quantity_received', 'FORMAT(sod.price_te, 2)',
'FORMAT(sod.discount_rate, 2)', 'FORMAT(sod.discount_value_te, 2)',
'FORMAT(sod.price_with_discount_te, 2)', 'FORMAT(sod.tax_rate, 2)', 'FORMAT(sod.tax_value, 2)',
'FORMAT(sod.price_ti, 2)', 'FORMAT(sod.tax_value_with_order_discount, 2)',
'FORMAT(sod.price_with_order_discount_te, 2)', 'sod.id_supply_order');
foreach ($ids as $id)
{
$query = new DbQuery();
$query->select(implode(', sod.', $keys));
$query->select(implode(', ', $keys));
$query->from('supply_order_detail', 'sod');
$query->leftJoin('supply_order', 'so', 'so.id_supply_order = sod.id_supply_order');
$id_warehouse = $this->getCurrentWarehouse();