Parse floats to user formatted versions in exports
This commit is contained in:
parent
299b1fe1cb
commit
b589dda5c4
|
|
@ -1632,4 +1632,18 @@ class BaseExport
|
||||||
{
|
{
|
||||||
return \Illuminate\Support\Facades\Schema::hasColumn($table, $column);
|
return \Illuminate\Support\Facades\Schema::hasColumn($table, $column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function convertFloats(iterable $entity): iterable
|
||||||
|
{
|
||||||
|
$currency = $this->company->currency();
|
||||||
|
|
||||||
|
foreach ($entity as $key => $value) {
|
||||||
|
if (is_float($value)) {
|
||||||
|
$entity[$key] = \App\Utils\Number::formatValue($value, $currency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $entity;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,8 @@ class ClientExport extends BaseExport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->decorateAdvancedFields($client, $entity);
|
$entity = $this->decorateAdvancedFields($client, $entity);
|
||||||
|
$this->convertFloats($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processMetaData(array $row, $resource): array
|
public function processMetaData(array $row, $resource): array
|
||||||
|
|
|
||||||
|
|
@ -167,16 +167,13 @@ class CreditExport extends BaseExport
|
||||||
} elseif(isset($transformed_credit[$searched_credit_key])) {
|
} elseif(isset($transformed_credit[$searched_credit_key])) {
|
||||||
$entity[$keyval] = $transformed_credit[$searched_credit_key];
|
$entity[$keyval] = $transformed_credit[$searched_credit_key];
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// nlog($key);
|
|
||||||
$entity[$key] = $this->decorator->transform($key, $credit);
|
$entity[$key] = $this->decorator->transform($key, $credit);
|
||||||
// $entity[$key] = '';
|
|
||||||
// $entity[$keyval] = $this->resolveKey($keyval, $credit, $this->credit_transformer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->decorateAdvancedFields($credit, $entity);
|
$entity = $this->decorateAdvancedFields($credit, $entity);
|
||||||
|
return $this->convertFloats($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addCreditStatusFilter($query, $status): Builder
|
public function addCreditStatusFilter($query, $status): Builder
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,8 @@ class ExpenseExport extends BaseExport
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->decorateAdvancedFields($expense, $entity);
|
$entity = $this->decorateAdvancedFields($expense, $entity);
|
||||||
|
return $this->convertFloats($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addExpenseStatusFilter($query, $status): Builder
|
protected function addExpenseStatusFilter($query, $status): Builder
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,8 @@ class InvoiceExport extends BaseExport
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->decorateAdvancedFields($invoice, $entity);
|
$entity = $this->decorateAdvancedFields($invoice, $entity);
|
||||||
|
return $this->convertFloats($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decorateAdvancedFields(Invoice $invoice, array $entity): array
|
private function decorateAdvancedFields(Invoice $invoice, array $entity): array
|
||||||
|
|
|
||||||
|
|
@ -213,14 +213,12 @@ class InvoiceItemExport extends BaseExport
|
||||||
} elseif (array_key_exists($key, $transformed_invoice)) {
|
} elseif (array_key_exists($key, $transformed_invoice)) {
|
||||||
$entity[$key] = $transformed_invoice[$key];
|
$entity[$key] = $transformed_invoice[$key];
|
||||||
} else {
|
} else {
|
||||||
// nlog($key);
|
|
||||||
$entity[$key] = $this->decorator->transform($key, $invoice);
|
$entity[$key] = $this->decorator->transform($key, $invoice);
|
||||||
// $entity[$key] = '';
|
|
||||||
// $entity[$key] = $this->resolveKey($key, $invoice, $this->invoice_transformer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return $entity;
|
|
||||||
return $this->decorateAdvancedFields($invoice, $entity);
|
$entity = $this->decorateAdvancedFields($invoice, $entity);
|
||||||
|
return $this->convertFloats($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decorateAdvancedFields(Invoice $invoice, array $entity): array
|
private function decorateAdvancedFields(Invoice $invoice, array $entity): array
|
||||||
|
|
|
||||||
|
|
@ -137,63 +137,17 @@ class PaymentExport extends BaseExport
|
||||||
} elseif (array_key_exists($key, $transformed_entity)) {
|
} elseif (array_key_exists($key, $transformed_entity)) {
|
||||||
$entity[$key] = $transformed_entity[$key];
|
$entity[$key] = $transformed_entity[$key];
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// nlog($key);
|
|
||||||
$entity[$key] = $this->decorator->transform($key, $payment);
|
$entity[$key] = $this->decorator->transform($key, $payment);
|
||||||
// $entity[$key] = $this->resolveKey($key, $payment, $this->entity_transformer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return $entity;
|
$entity = $this->decorateAdvancedFields($payment, $entity);
|
||||||
return $this->decorateAdvancedFields($payment, $entity);
|
return $this->convertFloats($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decorateAdvancedFields(Payment $payment, array $entity): array
|
private function decorateAdvancedFields(Payment $payment, array $entity): array
|
||||||
{
|
{
|
||||||
// if (in_array('status_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['status'] = $payment->stringStatus($payment->status_id);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('vendor_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['vendor'] = $payment->vendor()->exists() ? $payment->vendor->name : '';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('project_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['project'] = $payment->project()->exists() ? $payment->project->name : '';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('currency_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['currency'] = $payment->currency()->exists() ? $payment->currency->code : '';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('payment.currency', $this->input['report_keys'])) {
|
|
||||||
// $entity['payment.currency'] = $payment->currency()->exists() ? $payment->currency->code : '';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('exchange_currency_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['exchange_currency'] = $payment->exchange_currency()->exists() ? $payment->exchange_currency->code : '';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('client_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['client'] = $payment->client->present()->name();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('type_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['type'] = $payment->translatedType();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('payment.method', $this->input['report_keys'])) {
|
|
||||||
// $entity['payment.method'] = $payment->translatedType();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('payment.status', $this->input['report_keys'])) {
|
|
||||||
// $entity['payment.status'] = $payment->stringStatus($payment->status_id);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('gateway_type_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['gateway'] = $payment->gateway_type ? $payment->gateway_type->name : 'Unknown Type';
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (in_array('payment.assigned_user_id', $this->input['report_keys'])) {
|
if (in_array('payment.assigned_user_id', $this->input['report_keys'])) {
|
||||||
$entity['payment.assigned_user_id'] = $payment->assigned_user ? $payment->assigned_user->present()->name() : '';
|
$entity['payment.assigned_user_id'] = $payment->assigned_user ? $payment->assigned_user->present()->name() : '';
|
||||||
|
|
@ -203,8 +157,6 @@ class PaymentExport extends BaseExport
|
||||||
$entity['payment.user_id'] = $payment->user ? $payment->user->present()->name() : '';
|
$entity['payment.user_id'] = $payment->user ? $payment->user->present()->name() : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// $entity['invoices'] = $payment->invoices()->exists() ? $payment->invoices->pluck('number')->implode(',') : '';
|
|
||||||
|
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,27 +125,11 @@ class ProductExport 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];
|
||||||
} else {
|
} else {
|
||||||
// nlog($key);
|
|
||||||
$entity[$key] = $this->decorator->transform($key, $product);
|
$entity[$key] = $this->decorator->transform($key, $product);
|
||||||
// $entity[$key] = '';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entity;
|
return $this->convertFloats($entity);
|
||||||
// return $this->decorateAdvancedFields($product, $entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private function decorateAdvancedFields(Product $product, array $entity): array
|
|
||||||
// {
|
|
||||||
// if (in_array('vendor_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['vendor'] = $product->vendor()->exists() ? $product->vendor->name : '';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // if (array_key_exists('project_id', $this->input['report_keys'])) {
|
|
||||||
// // $entity['project'] = $product->project()->exists() ? $product->project->name : '';
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// return $entity;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,12 +66,6 @@ class ProductSalesExport extends BaseExport
|
||||||
'custom_value4' => 'custom_value4',
|
'custom_value4' => 'custom_value4',
|
||||||
];
|
];
|
||||||
|
|
||||||
// private array $decorate_keys = [
|
|
||||||
// 'client',
|
|
||||||
// 'currency',
|
|
||||||
// 'date',
|
|
||||||
// ];
|
|
||||||
|
|
||||||
public function __construct(Company $company, array $input)
|
public function __construct(Company $company, array $input)
|
||||||
{
|
{
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
|
|
@ -233,6 +227,8 @@ class ProductSalesExport extends BaseExport
|
||||||
}
|
}
|
||||||
$entity = $this->decorateAdvancedFields($invoice, $entity);
|
$entity = $this->decorateAdvancedFields($invoice, $entity);
|
||||||
|
|
||||||
|
$entity = $this->convertFloats($entity);
|
||||||
|
|
||||||
$this->sales->push($entity);
|
$this->sales->push($entity);
|
||||||
|
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|
|
||||||
|
|
@ -142,17 +142,16 @@ class PurchaseOrderExport extends BaseExport
|
||||||
if (is_array($parts) && $parts[0] == 'purchase_order' && array_key_exists($parts[1], $transformed_purchase_order)) {
|
if (is_array($parts) && $parts[0] == 'purchase_order' && array_key_exists($parts[1], $transformed_purchase_order)) {
|
||||||
$entity[$key] = $transformed_purchase_order[$parts[1]];
|
$entity[$key] = $transformed_purchase_order[$parts[1]];
|
||||||
} else {
|
} else {
|
||||||
nlog($key);
|
|
||||||
$entity[$key] = $this->decorator->transform($key, $purchase_order);
|
$entity[$key] = $this->decorator->transform($key, $purchase_order);
|
||||||
// $entity[$key] = '';
|
|
||||||
|
|
||||||
// $entity[$key] = $this->resolveKey($key, $purchase_order, $this->purchase_order_transformer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// return $entity;
|
|
||||||
return $this->decorateAdvancedFields($purchase_order, $entity);
|
$entity = $this->decorateAdvancedFields($purchase_order, $entity);
|
||||||
|
|
||||||
|
return $this->convertFloats($entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity): array
|
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity): array
|
||||||
|
|
|
||||||
|
|
@ -197,32 +197,18 @@ class PurchaseOrderItemExport extends BaseExport
|
||||||
} elseif (array_key_exists($key, $transformed_purchase_order)) {
|
} elseif (array_key_exists($key, $transformed_purchase_order)) {
|
||||||
$entity[$key] = $transformed_purchase_order[$key];
|
$entity[$key] = $transformed_purchase_order[$key];
|
||||||
} else {
|
} else {
|
||||||
// nlog($key);
|
|
||||||
$entity[$key] = $this->decorator->transform($key, $purchase_order);
|
$entity[$key] = $this->decorator->transform($key, $purchase_order);
|
||||||
// $entity[$key] = '';
|
|
||||||
// $entity[$key] = $this->resolveKey($key, $purchase_order, $this->purchase_order_transformer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->decorateAdvancedFields($purchase_order, $entity);
|
$entity = $this->decorateAdvancedFields($purchase_order, $entity);
|
||||||
|
$entity = $this->convertFloats($entity);
|
||||||
|
return $entity;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity): array
|
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity): array
|
||||||
{
|
{
|
||||||
// if (in_array('currency_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['currency'] = $purchase_order->vendor->currency() ? $purchase_order->vendor->currency()->code : $purchase_order->company->currency()->code;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(array_key_exists('tax_category', $entity)) {
|
|
||||||
// $entity['tax_category'] = $purchase_order->taxTypeString($entity['tax_category']);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if($this->force_keys) {
|
|
||||||
// $entity['vendor'] = $purchase_order->vendor->present()->name();
|
|
||||||
// $entity['vendor_id_number'] = $purchase_order->vendor->id_number;
|
|
||||||
// $entity['vendor_number'] = $purchase_order->vendor->number;
|
|
||||||
// $entity['status'] = $purchase_order->stringStatus($purchase_order->status_id);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (in_array('purchase_order.currency_id', $this->input['report_keys'])) {
|
if (in_array('purchase_order.currency_id', $this->input['report_keys'])) {
|
||||||
$entity['purchase_order.currency_id'] = $purchase_order->vendor->currency() ? $purchase_order->vendor->currency()->code : $purchase_order->company->currency()->code;
|
$entity['purchase_order.currency_id'] = $purchase_order->vendor->currency() ? $purchase_order->vendor->currency()->code : $purchase_order->company->currency()->code;
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,6 @@ class QuoteExport extends BaseExport
|
||||||
|
|
||||||
private Decorator $decorator;
|
private Decorator $decorator;
|
||||||
|
|
||||||
// private array $decorate_keys = [
|
|
||||||
// 'client',
|
|
||||||
// 'currency',
|
|
||||||
// 'invoice',
|
|
||||||
// ];
|
|
||||||
|
|
||||||
public function __construct(Company $company, array $input)
|
public function __construct(Company $company, array $input)
|
||||||
{
|
{
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
|
|
@ -148,15 +142,15 @@ class QuoteExport extends BaseExport
|
||||||
if (is_array($parts) && $parts[0] == 'quote' && array_key_exists($parts[1], $transformed_invoice)) {
|
if (is_array($parts) && $parts[0] == 'quote' && array_key_exists($parts[1], $transformed_invoice)) {
|
||||||
$entity[$key] = $transformed_invoice[$parts[1]];
|
$entity[$key] = $transformed_invoice[$parts[1]];
|
||||||
} else {
|
} else {
|
||||||
// nlog($key);
|
|
||||||
$entity[$key] = $this->decorator->transform($key, $quote);
|
$entity[$key] = $this->decorator->transform($key, $quote);
|
||||||
// $entity[$key] = '';
|
|
||||||
// $entity[$key] = $this->resolveKey($key, $quote, $this->quote_transformer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// return $entity;
|
|
||||||
return $this->decorateAdvancedFields($quote, $entity);
|
$entity = $this->decorateAdvancedFields($quote, $entity);
|
||||||
|
return $this->convertFloats($entity);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decorateAdvancedFields(Quote $quote, array $entity): array
|
private function decorateAdvancedFields(Quote $quote, array $entity): array
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,7 @@ class QuoteItemExport extends BaseExport
|
||||||
$transformed_quote = $this->buildRow($quote);
|
$transformed_quote = $this->buildRow($quote);
|
||||||
|
|
||||||
$transformed_items = [];
|
$transformed_items = [];
|
||||||
|
$currency = $this->company->currency();
|
||||||
|
|
||||||
foreach ($quote->line_items as $item) {
|
foreach ($quote->line_items as $item) {
|
||||||
$item_array = [];
|
$item_array = [];
|
||||||
|
|
@ -181,6 +182,7 @@ class QuoteItemExport extends BaseExport
|
||||||
$transformed_items = array_merge($transformed_quote, $item_array);
|
$transformed_items = array_merge($transformed_quote, $item_array);
|
||||||
$entity = $this->decorateAdvancedFields($quote, $transformed_items);
|
$entity = $this->decorateAdvancedFields($quote, $transformed_items);
|
||||||
$entity = array_merge(array_flip(array_values($this->input['report_keys'])), $entity);
|
$entity = array_merge(array_flip(array_values($this->input['report_keys'])), $entity);
|
||||||
|
$entity = $this->convertFloats($entity, $currency);
|
||||||
|
|
||||||
$this->storage_array[] = $entity;
|
$this->storage_array[] = $entity;
|
||||||
}
|
}
|
||||||
|
|
@ -211,22 +213,12 @@ class QuoteItemExport extends BaseExport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return $entity;
|
$entity = $this->decorateAdvancedFields($quote, $entity);
|
||||||
return $this->decorateAdvancedFields($quote, $entity);
|
return $this->convertFloats($entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
private function decorateAdvancedFields(Quote $quote, array $entity): array
|
private function decorateAdvancedFields(Quote $quote, array $entity): array
|
||||||
{
|
{
|
||||||
// if (in_array('currency_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['currency'] = $quote->client->currency() ? $quote->client->currency()->code : $quote->company->currency()->code;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('client_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['client'] = $quote->client->present()->name();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('status_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['status'] = $quote->stringStatus($quote->status_id);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (in_array('quote.assigned_user_id', $this->input['report_keys'])) {
|
if (in_array('quote.assigned_user_id', $this->input['report_keys'])) {
|
||||||
$entity['quote.assigned_user_id'] = $quote->assigned_user ? $quote->assigned_user->present()->name() : '';
|
$entity['quote.assigned_user_id'] = $quote->assigned_user ? $quote->assigned_user->present()->name() : '';
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ class RecurringInvoiceExport extends BaseExport
|
||||||
$transformed_invoice = $this->invoice_transformer->transform($invoice);
|
$transformed_invoice = $this->invoice_transformer->transform($invoice);
|
||||||
|
|
||||||
$entity = [];
|
$entity = [];
|
||||||
|
$currency = $this->company->currency();
|
||||||
|
|
||||||
foreach (array_values($this->input['report_keys']) as $key) {
|
foreach (array_values($this->input['report_keys']) as $key) {
|
||||||
|
|
||||||
|
|
@ -139,12 +140,12 @@ class RecurringInvoiceExport extends BaseExport
|
||||||
} elseif($parts[0] == 'item') {
|
} elseif($parts[0] == 'item') {
|
||||||
$entity[$key] = '';
|
$entity[$key] = '';
|
||||||
} else {
|
} else {
|
||||||
// nlog($key);
|
|
||||||
$entity[$key] = $this->decorator->transform($key, $invoice);
|
$entity[$key] = $this->decorator->transform($key, $invoice);
|
||||||
// $entity[$key] = '';
|
|
||||||
// $entity[$key] = $this->resolveKey($key, $invoice, $this->invoice_transformer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_float($entity[$key]))
|
||||||
|
$entity[$key] = \App\Utils\Number::formatValue($entity[$key], $currency);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return $entity;
|
// return $entity;
|
||||||
|
|
@ -153,29 +154,6 @@ class RecurringInvoiceExport extends BaseExport
|
||||||
|
|
||||||
private function decorateAdvancedFields(RecurringInvoice $invoice, array $entity): array
|
private function decorateAdvancedFields(RecurringInvoice $invoice, array $entity): array
|
||||||
{
|
{
|
||||||
// if (in_array('country_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['country'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : '';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('currency_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['currency'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('client_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['client'] = $invoice->client->present()->name();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('recurring_invoice.status', $this->input['report_keys'])) {
|
|
||||||
// $entity['recurring_invoice.status'] = $invoice->stringStatus($invoice->status_id);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('project_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['project'] = $invoice->project ? $invoice->project->name : '';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (in_array('vendor_id', $this->input['report_keys'])) {
|
|
||||||
// $entity['vendor'] = $invoice->vendor ? $invoice->vendor->name : '';
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (in_array('recurring_invoice.frequency_id', $this->input['report_keys']) || in_array('frequency_id', $this->input['report_keys'])) {
|
if (in_array('recurring_invoice.frequency_id', $this->input['report_keys']) || in_array('frequency_id', $this->input['report_keys'])) {
|
||||||
$entity['recurring_invoice.frequency_id'] = $invoice->frequencyForKey($invoice->frequency_id);
|
$entity['recurring_invoice.frequency_id'] = $invoice->frequencyForKey($invoice->frequency_id);
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,8 @@ class TaskExport extends BaseExport
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entity = $this->convertFloats($entity);
|
||||||
|
|
||||||
if (is_null($task->time_log) || (is_array(json_decode($task->time_log, true)) && count(json_decode($task->time_log, true)) == 0)) {
|
if (is_null($task->time_log) || (is_array(json_decode($task->time_log, true)) && count(json_decode($task->time_log, true)) == 0)) {
|
||||||
$this->storage_array[] = $entity;
|
$this->storage_array[] = $entity;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,8 @@ class ARDetailReport extends BaseExport
|
||||||
$client->number,
|
$client->number,
|
||||||
$client->id_number,
|
$client->id_number,
|
||||||
intval(abs(Carbon::parse($invoice->due_date)->diffInDays(now()))),
|
intval(abs(Carbon::parse($invoice->due_date)->diffInDays(now()))),
|
||||||
Number::formatMoney($invoice->amount, $client),
|
Number::formatMoney($invoice->amount, $this->company),
|
||||||
Number::formatMoney($invoice->balance, $client),
|
Number::formatMoney($invoice->balance, $this->company),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ class ARSummaryReport extends BaseExport
|
||||||
$this->getAgingAmount('90'),
|
$this->getAgingAmount('90'),
|
||||||
$this->getAgingAmount('120'),
|
$this->getAgingAmount('120'),
|
||||||
$this->getAgingAmount('120+'),
|
$this->getAgingAmount('120+'),
|
||||||
Number::formatMoney($this->total, $this->client),
|
Number::formatMoney($this->total, $this->company),
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->total = 0;
|
$this->total = 0;
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,16 @@
|
||||||
|
|
||||||
namespace App\Services\Report;
|
namespace App\Services\Report;
|
||||||
|
|
||||||
use App\Export\CSV\BaseExport;
|
use App\Utils\Ninja;
|
||||||
use App\Libraries\MultiDB;
|
use App\Utils\Number;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use League\Csv\Writer;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Utils\Ninja;
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Export\CSV\BaseExport;
|
||||||
use App\Utils\Traits\MakesDates;
|
use App\Utils\Traits\MakesDates;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use League\Csv\Writer;
|
|
||||||
|
|
||||||
class ClientBalanceReport extends BaseExport
|
class ClientBalanceReport extends BaseExport
|
||||||
{
|
{
|
||||||
|
|
@ -119,8 +120,8 @@ class ClientBalanceReport extends BaseExport
|
||||||
$client->id_number,
|
$client->id_number,
|
||||||
$query->count(),
|
$query->count(),
|
||||||
$query->sum('balance'),
|
$query->sum('balance'),
|
||||||
$client->credit_balance,
|
Number::formatMoney($client->credit_balance, $this->company),
|
||||||
$client->payment_balance,
|
Number::formatMoney($client->payment_balance, $this->company),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,10 +114,10 @@ class ClientSalesReport extends BaseExport
|
||||||
$client->number,
|
$client->number,
|
||||||
$client->id_number,
|
$client->id_number,
|
||||||
$query->count(),
|
$query->count(),
|
||||||
Number::formatMoney($amount, $client),
|
Number::formatMoney($amount, $this->company),
|
||||||
Number::formatMoney($balance, $client),
|
Number::formatMoney($balance, $this->company),
|
||||||
Number::formatMoney($query->sum('total_taxes'), $client),
|
Number::formatMoney($query->sum('total_taxes'), $this->company),
|
||||||
Number::formatMoney($amount - $balance, $client),
|
Number::formatMoney($amount - $balance, $this->company),
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue