mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Updates for product sales to include currency
This commit is contained in:
parent
afd563b6c3
commit
e34d5335ad
@ -37,6 +37,7 @@ class ProductSalesExport extends BaseExport
|
|||||||
'product_key' => 'product_key',
|
'product_key' => 'product_key',
|
||||||
'notes' => 'notes',
|
'notes' => 'notes',
|
||||||
'quantity' => 'quantity',
|
'quantity' => 'quantity',
|
||||||
|
'currency' => 'currency',
|
||||||
'cost' => 'price',
|
'cost' => 'price',
|
||||||
'price' => 'cost',
|
'price' => 'cost',
|
||||||
'markup' => 'markup',
|
'markup' => 'markup',
|
||||||
@ -163,6 +164,7 @@ class ProductSalesExport extends BaseExport
|
|||||||
private function buildRow($invoice, $invoice_item) :array
|
private function buildRow($invoice, $invoice_item) :array
|
||||||
{
|
{
|
||||||
$transformed_entity = (array)$invoice_item;
|
$transformed_entity = (array)$invoice_item;
|
||||||
|
$transformed_entity['price'] = ($invoice_item->product_cost ?? 1 ) * ($invoice->exchange_rate ?? 1) ;
|
||||||
|
|
||||||
$entity = [];
|
$entity = [];
|
||||||
|
|
||||||
@ -171,6 +173,8 @@ class ProductSalesExport extends BaseExport
|
|||||||
|
|
||||||
if (array_key_exists($key, $transformed_entity)) {
|
if (array_key_exists($key, $transformed_entity)) {
|
||||||
$entity[$keyval] = $transformed_entity[$key];
|
$entity[$keyval] = $transformed_entity[$key];
|
||||||
|
} elseif($key == 'currency') {
|
||||||
|
$entity['currency'] = $invoice->client->currency()->code;
|
||||||
} else {
|
} else {
|
||||||
$entity[$keyval] = '';
|
$entity[$keyval] = '';
|
||||||
}
|
}
|
||||||
@ -184,9 +188,9 @@ class ProductSalesExport extends BaseExport
|
|||||||
|
|
||||||
private function decorateAdvancedFields(Invoice $invoice, $entity) :array
|
private function decorateAdvancedFields(Invoice $invoice, $entity) :array
|
||||||
{
|
{
|
||||||
$product = $this->getProduct($entity['product_key']);
|
|
||||||
|
//$product = $this->getProduct($entity['product_key']);
|
||||||
$entity['cost'] = $product->cost ?? 0;
|
// $entity['cost'] = $product->cost ?? 0;
|
||||||
/** @var float $unit_cost */
|
/** @var float $unit_cost */
|
||||||
$unit_cost = $entity['cost'] == 0 ? 1 : $entity['cost'];
|
$unit_cost = $entity['cost'] == 0 ? 1 : $entity['cost'];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user