From c67c73ca012a0d22a75604d9cfe48c30d9a44ad7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 5 Oct 2024 15:10:48 +1000 Subject: [PATCH] Fixes for export formats --- app/Export/CSV/ClientExport.php | 2 +- app/Export/CSV/ProductSalesExport.php | 13 +++++-------- app/Export/CSV/QuoteItemExport.php | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/Export/CSV/ClientExport.php b/app/Export/CSV/ClientExport.php index 941f0987eb..65597914da 100644 --- a/app/Export/CSV/ClientExport.php +++ b/app/Export/CSV/ClientExport.php @@ -191,7 +191,7 @@ class ClientExport extends BaseExport } $entity = $this->decorateAdvancedFields($client, $entity); - $this->convertFloats($entity); + return $this->convertFloats($entity); } public function processMetaData(array $row, $resource): array diff --git a/app/Export/CSV/ProductSalesExport.php b/app/Export/CSV/ProductSalesExport.php index 46f980ee2a..664db3b023 100644 --- a/app/Export/CSV/ProductSalesExport.php +++ b/app/Export/CSV/ProductSalesExport.php @@ -143,10 +143,10 @@ class ProductSalesExport extends BaseExport if($product_keys) { if(in_array($item->product_key, $product_keys)) { - $this->csv->insertOne($this->buildRow($invoice, $item)); + $this->csv->insertOne($this->convertFloats($this->buildRow($invoice, $item))); } } else { - $this->csv->insertOne($this->buildRow($invoice, $item)); + $this->csv->insertOne($this->convertFloats($this->buildRow($invoice, $item))); } } @@ -175,7 +175,7 @@ class ProductSalesExport extends BaseExport 'tax_amount3' => $key->sum('tax_amount3'), ]; - return $data; + return $this->convertFloats($data); })->reject(function ($value) { return $value === false; @@ -225,10 +225,9 @@ class ProductSalesExport extends BaseExport $entity[$keyval] = ''; } } + $entity = $this->decorateAdvancedFields($invoice, $entity); - - $entity = $this->convertFloats($entity); - + $this->sales->push($entity); return $entity; @@ -237,8 +236,6 @@ class ProductSalesExport extends BaseExport private function decorateAdvancedFields(Invoice $invoice, $entity): array { - //$product = $this->getProduct($entity['product_key']); - // $entity['cost'] = $product->cost ?? 0; /** @var float $unit_cost */ $unit_cost = $entity['cost'] == 0 ? 1 : $entity['cost']; diff --git a/app/Export/CSV/QuoteItemExport.php b/app/Export/CSV/QuoteItemExport.php index c11135b306..1bdd550d45 100644 --- a/app/Export/CSV/QuoteItemExport.php +++ b/app/Export/CSV/QuoteItemExport.php @@ -182,7 +182,7 @@ class QuoteItemExport extends BaseExport $transformed_items = array_merge($transformed_quote, $item_array); $entity = $this->decorateAdvancedFields($quote, $transformed_items); $entity = array_merge(array_flip(array_values($this->input['report_keys'])), $entity); - $entity = $this->convertFloats($entity, $currency); + $entity = $this->convertFloats($entity); $this->storage_array[] = $entity; }