diff --git a/VERSION.txt b/VERSION.txt index 5fd68abd0349..432493c23c5a 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.7.61 \ No newline at end of file +5.7.62 \ No newline at end of file diff --git a/app/Export/CSV/ClientExport.php b/app/Export/CSV/ClientExport.php index 7f71304cb99b..501b01ab59fc 100644 --- a/app/Export/CSV/ClientExport.php +++ b/app/Export/CSV/ClientExport.php @@ -181,9 +181,9 @@ class ClientExport extends BaseExport } } - return $entity; + // return $entity; - // return $this->decorateAdvancedFields($client, $entity); + return $this->decorateAdvancedFields($client, $entity); } public function processMetaData(array $row, $resource): array @@ -221,21 +221,21 @@ class ClientExport extends BaseExport $entity['client.assigned_user'] = $client->assigned_user ? $client->user->present()->name() : ''; } - if (in_array('client.country_id', $this->input['report_keys'])) { - $entity['client.country_id'] = $client->country ? ctrans("texts.country_{$client->country->name}") : ''; - } + // if (in_array('client.country_id', $this->input['report_keys'])) { + // $entity['client.country_id'] = $client->country ? ctrans("texts.country_{$client->country->name}") : ''; + // } - if (in_array('client.shipping_country_id', $this->input['report_keys'])) { - $entity['client.shipping_country_id'] = $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : ''; - } + // if (in_array('client.shipping_country_id', $this->input['report_keys'])) { + // $entity['client.shipping_country_id'] = $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : ''; + // } - if (in_array('client.currency_id', $this->input['report_keys'])) { - $entity['client.currency_id'] = $client->currency() ? $client->currency()->code : $client->company->currency()->code; - } + // if (in_array('client.currency_id', $this->input['report_keys'])) { + // $entity['client.currency_id'] = $client->currency() ? $client->currency()->code : $client->company->currency()->code; + // } - if (in_array('client.industry_id', $this->input['report_keys'])) { - $entity['industry_id'] = $client->industry ? ctrans("texts.industry_{$client->industry->name}") : ''; - } + // if (in_array('client.industry_id', $this->input['report_keys'])) { + // $entity['industry_id'] = $client->industry ? ctrans("texts.industry_{$client->industry->name}") : ''; + // } if (in_array('client.classification', $this->input['report_keys']) && isset($client->classification)) { $entity['client.classification'] = ctrans("texts.{$client->classification}") ?? ''; diff --git a/app/Export/CSV/ContactExport.php b/app/Export/CSV/ContactExport.php index 1bb0a8b9fd02..ddd6ad078ef6 100644 --- a/app/Export/CSV/ContactExport.php +++ b/app/Export/CSV/ContactExport.php @@ -129,8 +129,8 @@ class ContactExport extends BaseExport } } - return $entity; - // return $this->decorateAdvancedFields($contact->client, $entity); + // return $entity; + return $this->decorateAdvancedFields($contact->client, $entity); } private function decorateAdvancedFields(Client $client, array $entity) :array @@ -151,6 +151,15 @@ class ContactExport extends BaseExport $entity['industry_id'] = $client->industry ? ctrans("texts.industry_{$client->industry->name}") : ''; } + if (in_array('client.user_id', $this->input['report_keys'])) { + $entity['client.user_id'] = $client->user ? $client->user->present()->name() : ''; + } + + if (in_array('client.assigned_user_id', $this->input['report_keys'])) { + $entity['client.assigned_user_id'] = $client->assigned_user ? $client->assigned_user->present()->name() : ''; + } + + return $entity; } } diff --git a/app/Export/CSV/CreditExport.php b/app/Export/CSV/CreditExport.php index dcc9290d9510..e13a91e7a8ed 100644 --- a/app/Export/CSV/CreditExport.php +++ b/app/Export/CSV/CreditExport.php @@ -161,29 +161,29 @@ class CreditExport extends BaseExport private function decorateAdvancedFields(Credit $credit, array $entity) :array { - if (in_array('country_id', $this->input['report_keys'])) { - $entity['country'] = $credit->client->country ? ctrans("texts.country_{$credit->client->country->name}") : ''; - } + // if (in_array('country_id', $this->input['report_keys'])) { + // $entity['country'] = $credit->client->country ? ctrans("texts.country_{$credit->client->country->name}") : ''; + // } - if (in_array('currency_id', $this->input['report_keys'])) { - $entity['currency_id'] = $credit->client->currency() ? $credit->client->currency()->code : $credit->company->currency()->code; - } + // if (in_array('currency_id', $this->input['report_keys'])) { + // $entity['currency_id'] = $credit->client->currency() ? $credit->client->currency()->code : $credit->company->currency()->code; + // } - if (in_array('invoice_id', $this->input['report_keys'])) { - $entity['invoice'] = $credit->invoice ? $credit->invoice->number : ''; - } + // if (in_array('invoice_id', $this->input['report_keys'])) { + // $entity['invoice'] = $credit->invoice ? $credit->invoice->number : ''; + // } - if (in_array('client_id', $this->input['report_keys'])) { - $entity['client'] = $credit->client->present()->name(); - } + // if (in_array('client_id', $this->input['report_keys'])) { + // $entity['client'] = $credit->client->present()->name(); + // } - if (in_array('status_id', $this->input['report_keys'])) { - $entity['status'] = $credit->stringStatus($credit->status_id); - } + // if (in_array('status_id', $this->input['report_keys'])) { + // $entity['status'] = $credit->stringStatus($credit->status_id); + // } - if(in_array('credit.status', $this->input['report_keys'])) { - $entity['credit.status'] = $credit->stringStatus($credit->status_id); - } + // if(in_array('credit.status', $this->input['report_keys'])) { + // $entity['credit.status'] = $credit->stringStatus($credit->status_id); + // } if (in_array('credit.assigned_user_id', $this->input['report_keys'])) { $entity['credit.assigned_user_id'] = $credit->assigned_user ? $credit->assigned_user->present()->name(): ''; diff --git a/app/Export/CSV/ExpenseExport.php b/app/Export/CSV/ExpenseExport.php index a2f48805acb3..ecf5e7a89b4b 100644 --- a/app/Export/CSV/ExpenseExport.php +++ b/app/Export/CSV/ExpenseExport.php @@ -126,35 +126,35 @@ class ExpenseExport extends BaseExport } - return $entity; - // return $this->decorateAdvancedFields($expense, $entity); + // return $entity; + return $this->decorateAdvancedFields($expense, $entity); } private function decorateAdvancedFields(Expense $expense, array $entity) :array { - if (in_array('expense.currency_id', $this->input['report_keys'])) { - $entity['expense.currency_id'] = $expense->currency ? $expense->currency->code : ''; - } + // if (in_array('expense.currency_id', $this->input['report_keys'])) { + // $entity['expense.currency_id'] = $expense->currency ? $expense->currency->code : ''; + // } - if (in_array('expense.client_id', $this->input['report_keys'])) { - $entity['expense.client'] = $expense->client ? $expense->client->present()->name() : ''; - } + // if (in_array('expense.client_id', $this->input['report_keys'])) { + // $entity['expense.client'] = $expense->client ? $expense->client->present()->name() : ''; + // } - if (in_array('expense.invoice_id', $this->input['report_keys'])) { - $entity['expense.invoice_id'] = $expense->invoice ? $expense->invoice->number : ''; - } + // if (in_array('expense.invoice_id', $this->input['report_keys'])) { + // $entity['expense.invoice_id'] = $expense->invoice ? $expense->invoice->number : ''; + // } - if (in_array('expense.category', $this->input['report_keys'])) { - $entity['expense.category'] = $expense->category ? $expense->category->name : ''; - } + // if (in_array('expense.category', $this->input['report_keys'])) { + // $entity['expense.category'] = $expense->category ? $expense->category->name : ''; + // } - if (in_array('expense.vendor_id', $this->input['report_keys'])) { - $entity['expense.vendor'] = $expense->vendor ? $expense->vendor->name : ''; - } + // if (in_array('expense.vendor_id', $this->input['report_keys'])) { + // $entity['expense.vendor'] = $expense->vendor ? $expense->vendor->name : ''; + // } - if (in_array('expense.payment_type_id', $this->input['report_keys'])) { - $entity['expense.payment_type_id'] = $expense->payment_type ? $expense->payment_type->name : ''; - } + // if (in_array('expense.payment_type_id', $this->input['report_keys'])) { + // $entity['expense.payment_type_id'] = $expense->payment_type ? $expense->payment_type->name : ''; + // } if (in_array('expense.project_id', $this->input['report_keys'])) { $entity['expense.project_id'] = $expense->project ? $expense->project->name : ''; diff --git a/app/Export/CSV/InvoiceExport.php b/app/Export/CSV/InvoiceExport.php index 4f28e72fed5d..18b892fafd7d 100644 --- a/app/Export/CSV/InvoiceExport.php +++ b/app/Export/CSV/InvoiceExport.php @@ -128,32 +128,32 @@ class InvoiceExport extends BaseExport } - return $entity; - // return $this->decorateAdvancedFields($invoice, $entity); + // return $entity; + return $this->decorateAdvancedFields($invoice, $entity); } private function decorateAdvancedFields(Invoice $invoice, array $entity) :array { - if (in_array('invoice.country_id', $this->input['report_keys'])) { - $entity['invoice.country_id'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : ''; - } + // if (in_array('invoice.country_id', $this->input['report_keys'])) { + // $entity['invoice.country_id'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : ''; + // } - if (in_array('invoice.currency_id', $this->input['report_keys'])) { - $entity['invoice.currency_id'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code; - } + // if (in_array('invoice.currency_id', $this->input['report_keys'])) { + // $entity['invoice.currency_id'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code; + // } - if (in_array('invoice.client_id', $this->input['report_keys'])) { - $entity['invoice.client_id'] = $invoice->client->present()->name(); - } + // if (in_array('invoice.client_id', $this->input['report_keys'])) { + // $entity['invoice.client_id'] = $invoice->client->present()->name(); + // } - if (in_array('invoice.status', $this->input['report_keys'])) { - $entity['invoice.status'] = $invoice->stringStatus($invoice->status_id); - } + // if (in_array('invoice.status', $this->input['report_keys'])) { + // $entity['invoice.status'] = $invoice->stringStatus($invoice->status_id); + // } - if (in_array('invoice.recurring_id', $this->input['report_keys'])) { - $entity['invoice.recurring_id'] = $invoice->recurring_invoice->number ?? ''; - } + // if (in_array('invoice.recurring_id', $this->input['report_keys'])) { + // $entity['invoice.recurring_id'] = $invoice->recurring_invoice->number ?? ''; + // } if (in_array('invoice.auto_bill_enabled', $this->input['report_keys'])) { $entity['invoice.auto_bill_enabled'] = $invoice->auto_bill_enabled ? ctrans('texts.yes') : ctrans('texts.no'); diff --git a/app/Export/CSV/InvoiceItemExport.php b/app/Export/CSV/InvoiceItemExport.php index 71fac33e9c21..3ffadb076b7c 100644 --- a/app/Export/CSV/InvoiceItemExport.php +++ b/app/Export/CSV/InvoiceItemExport.php @@ -196,43 +196,43 @@ class InvoiceItemExport extends BaseExport // $entity[$key] = $this->resolveKey($key, $invoice, $this->invoice_transformer); } } - return $entity; - // return $this->decorateAdvancedFields($invoice, $entity); + // return $entity; + return $this->decorateAdvancedFields($invoice, $entity); } private function decorateAdvancedFields(Invoice $invoice, array $entity) :array { - 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('currency_id', $this->input['report_keys'])) { + // $entity['currency'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code; + // } - if(array_key_exists('type', $entity)) { - $entity['type'] = $invoice->typeIdString($entity['type']); - } + // if(array_key_exists('type', $entity)) { + // $entity['type'] = $invoice->typeIdString($entity['type']); + // } - if(array_key_exists('tax_category', $entity)) { - $entity['tax_category'] = $invoice->taxTypeString($entity['tax_category']); - } + // if(array_key_exists('tax_category', $entity)) { + // $entity['tax_category'] = $invoice->taxTypeString($entity['tax_category']); + // } - if (in_array('invoice.country_id', $this->input['report_keys'])) { - $entity['invoice.country_id'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : ''; - } + // if (in_array('invoice.country_id', $this->input['report_keys'])) { + // $entity['invoice.country_id'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : ''; + // } - if (in_array('invoice.currency_id', $this->input['report_keys'])) { - $entity['invoice.currency_id'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code; - } + // if (in_array('invoice.currency_id', $this->input['report_keys'])) { + // $entity['invoice.currency_id'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code; + // } - if (in_array('invoice.client_id', $this->input['report_keys'])) { - $entity['invoice.client_id'] = $invoice->client->present()->name(); - } + // if (in_array('invoice.client_id', $this->input['report_keys'])) { + // $entity['invoice.client_id'] = $invoice->client->present()->name(); + // } - if (in_array('invoice.status', $this->input['report_keys'])) { - $entity['invoice.status'] = $invoice->stringStatus($invoice->status_id); - } + // if (in_array('invoice.status', $this->input['report_keys'])) { + // $entity['invoice.status'] = $invoice->stringStatus($invoice->status_id); + // } - if (in_array('invoice.recurring_id', $this->input['report_keys'])) { - $entity['invoice.recurring_id'] = $invoice->recurring_invoice->number ?? ''; - } + // if (in_array('invoice.recurring_id', $this->input['report_keys'])) { + // $entity['invoice.recurring_id'] = $invoice->recurring_invoice->number ?? ''; + // } if (in_array('invoice.assigned_user_id', $this->input['report_keys'])) { $entity['invoice.assigned_user_id'] = $invoice->assigned_user ? $invoice->assigned_user->present()->name(): ''; diff --git a/app/Export/CSV/PaymentExport.php b/app/Export/CSV/PaymentExport.php index 67b8e41abe90..9ddb9de3cddd 100644 --- a/app/Export/CSV/PaymentExport.php +++ b/app/Export/CSV/PaymentExport.php @@ -125,55 +125,55 @@ class PaymentExport extends BaseExport } - return $entity; - // return $this->decorateAdvancedFields($payment, $entity); + // return $entity; + return $this->decorateAdvancedFields($payment, $entity); } 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('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('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('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('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('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('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('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('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.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('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('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'])) { $entity['payment.assigned_user_id'] = $payment->assigned_user ? $payment->assigned_user->present()->name() : ''; diff --git a/app/Export/CSV/PurchaseOrderExport.php b/app/Export/CSV/PurchaseOrderExport.php index ff15cb2abc25..ac63c9b13cb3 100644 --- a/app/Export/CSV/PurchaseOrderExport.php +++ b/app/Export/CSV/PurchaseOrderExport.php @@ -173,8 +173,8 @@ class PurchaseOrderExport extends BaseExport } - return $entity; - // return $this->decorateAdvancedFields($purchase_order, $entity); + // return $entity; + return $this->decorateAdvancedFields($purchase_order, $entity); } private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity) :array @@ -195,6 +195,15 @@ class PurchaseOrderExport extends BaseExport $entity['purchase_order.status'] = $purchase_order->stringStatus($purchase_order->status_id); } + if (in_array('purchase_order.user_id', $this->input['report_keys'])) { + $entity['purchase_order.user_id'] = $purchase_order->user ? $purchase_order->user->present()->name() : ''; + } + + if (in_array('purchase_order.assigned_user_id', $this->input['report_keys'])) { + $entity['purchase_order.assigned_user_id'] = $purchase_order->assigned_user ? $purchase_order->assigned_user->present()->name() : ''; + } + + return $entity; } } diff --git a/app/Export/CSV/PurchaseOrderItemExport.php b/app/Export/CSV/PurchaseOrderItemExport.php index 1d8fce10582c..320d068ef147 100644 --- a/app/Export/CSV/PurchaseOrderItemExport.php +++ b/app/Export/CSV/PurchaseOrderItemExport.php @@ -206,6 +206,16 @@ class PurchaseOrderItemExport extends BaseExport $entity['status'] = $purchase_order->stringStatus($purchase_order->status_id); } + if (in_array('purchase_order.user_id', $this->input['report_keys'])) { + $entity['purchase_order.user_id'] = $purchase_order->user ? $purchase_order->user->present()->name() : ''; + } + + if (in_array('purchase_order.assigned_user_id', $this->input['report_keys'])) { + $entity['purchase_order.assigned_user_id'] = $purchase_order->assigned_user ? $purchase_order->assigned_user->present()->name() : ''; + } + + + return $entity; } diff --git a/app/Export/CSV/QuoteExport.php b/app/Export/CSV/QuoteExport.php index 5ae717df51c0..5da64b61509e 100644 --- a/app/Export/CSV/QuoteExport.php +++ b/app/Export/CSV/QuoteExport.php @@ -133,8 +133,8 @@ class QuoteExport extends BaseExport } } - return $entity; - // return $this->decorateAdvancedFields($quote, $entity); + // return $entity; + return $this->decorateAdvancedFields($quote, $entity); } private function decorateAdvancedFields(Quote $quote, array $entity) :array diff --git a/app/Export/CSV/QuoteItemExport.php b/app/Export/CSV/QuoteItemExport.php index eafbda850103..df6ebc8cd670 100644 --- a/app/Export/CSV/QuoteItemExport.php +++ b/app/Export/CSV/QuoteItemExport.php @@ -189,22 +189,22 @@ class QuoteItemExport extends BaseExport } } - return $entity; - // return $this->decorateAdvancedFields($quote, $entity); + // return $entity; + return $this->decorateAdvancedFields($quote, $entity); } 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('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('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('status_id', $this->input['report_keys'])) { + // $entity['status'] = $quote->stringStatus($quote->status_id); + // } if (in_array('quote.assigned_user_id', $this->input['report_keys'])) { $entity['quote.assigned_user_id'] = $quote->assigned_user ? $quote->assigned_user->present()->name(): ''; diff --git a/app/Export/CSV/RecurringInvoiceExport.php b/app/Export/CSV/RecurringInvoiceExport.php index 4e1d3945421b..486ab77abcd6 100644 --- a/app/Export/CSV/RecurringInvoiceExport.php +++ b/app/Export/CSV/RecurringInvoiceExport.php @@ -109,8 +109,6 @@ class RecurringInvoiceExport extends BaseExport private function buildRow(RecurringInvoice $invoice) :array { $transformed_invoice = $this->invoice_transformer->transform($invoice); - $transformed_invoice['frequency_id'] = $invoice->frequencyForKey($invoice->frequency_id); //need to inject this here because it is also a valid key -// nlog($transformed_invoice); $entity = []; @@ -131,36 +129,36 @@ class RecurringInvoiceExport extends BaseExport } } -// nlog($entity); - return $entity; - // return $this->decorateAdvancedFields($invoice, $entity); + + // return $entity; + return $this->decorateAdvancedFields($invoice, $entity); } 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('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('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('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('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('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('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'])) { $entity['recurring_invoice.frequency_id'] = $invoice->frequencyForKey($invoice->frequency_id); diff --git a/app/Export/CSV/TaskExport.php b/app/Export/CSV/TaskExport.php index 332c9d8807d9..757dda2c4f72 100644 --- a/app/Export/CSV/TaskExport.php +++ b/app/Export/CSV/TaskExport.php @@ -197,7 +197,7 @@ class TaskExport extends BaseExport $entity['task.duration'] = $task->calcDuration(); } - // $entity = $this->decorateAdvancedFields($task, $entity); + $entity = $this->decorateAdvancedFields($task, $entity); $this->storage_array[] = $entity; @@ -218,6 +218,15 @@ class TaskExport extends BaseExport $entity['task.project_id'] = $task->project()->exists() ? $task->project->name : ''; } + if (in_array('task.user_id', $this->input['report_keys'])) { + $entity['task.user_id'] = $task->user ? $task->user->present()->name() : ''; + } + + if (in_array('task.assigned_user_id', $this->input['report_keys'])) { + $entity['task.assigned_user_id'] = $task->assigned_user ? $task->assigned_user->present()->name() : ''; + } + + return $entity; } } diff --git a/app/Export/CSV/VendorExport.php b/app/Export/CSV/VendorExport.php index 4279724f9111..567c745f5a55 100644 --- a/app/Export/CSV/VendorExport.php +++ b/app/Export/CSV/VendorExport.php @@ -126,15 +126,14 @@ class VendorExport extends BaseExport } elseif (is_array($parts) && $parts[0] == 'vendor_contact' && isset($transformed_contact[$parts[1]])) { $entity[$key] = $transformed_contact[$parts[1]]; } else { - // nlog($key); + $entity[$key] = $this->decorator->transform($key, $vendor); - // $entity[$key] = $this->resolveKey($key, $vendor, $this->vendor_transformer); } } - return $entity; - // return $this->decorateAdvancedFields($vendor, $entity); + // return $entity; + return $this->decorateAdvancedFields($vendor, $entity); } private function decorateAdvancedFields(Vendor $vendor, array $entity) :array @@ -151,6 +150,15 @@ class VendorExport extends BaseExport $entity['vendor.classification'] = ctrans("texts.{$vendor->classification}") ?? ''; } + if (in_array('vendor.user_id', $this->input['report_keys'])) { + $entity['vendor.user_id'] = $vendor->user ? $vendor->user->present()->name() : ''; + } + + if (in_array('vendor.assigned_user_id', $this->input['report_keys'])) { + $entity['vendor.assigned_user_id'] = $vendor->assigned_user ? $vendor->assigned_user->present()->name() : ''; + } + + // $entity['status'] = $this->calculateStatus($vendor); return $entity; diff --git a/app/Http/Requests/Import/ImportRequest.php b/app/Http/Requests/Import/ImportRequest.php index 541f4f1c422c..f528452b0708 100644 --- a/app/Http/Requests/Import/ImportRequest.php +++ b/app/Http/Requests/Import/ImportRequest.php @@ -40,4 +40,14 @@ class ImportRequest extends Request 'bank_integration_id' => 'bail|required_with:column_map.bank_transaction|min:2' ]; } + + public function prepareForValidation() + { + $input = $this->all(); + + if(!isset($input['column_map']['bank_transaction']) && array_key_exists('bank_integration_id',$input)) + unset($input['bank_integration_id']); + + $this->replace($input); + } } diff --git a/app/Http/Requests/Product/StoreProductRequest.php b/app/Http/Requests/Product/StoreProductRequest.php index 4dacdbdfca16..285a5f0a6145 100644 --- a/app/Http/Requests/Product/StoreProductRequest.php +++ b/app/Http/Requests/Product/StoreProductRequest.php @@ -23,7 +23,10 @@ class StoreProductRequest extends Request */ public function authorize() : bool { - return auth()->user()->can('create', Product::class); + /** @var \App\Models\User $user */ + $user = auth()->user(); + + return $user->can('create', Product::class); } public function rules() @@ -54,7 +57,7 @@ class StoreProductRequest extends Request { $input = $this->all(); - if (! isset($input['quantity']) || $input['quantity'] < 1) { + if (! isset($input['quantity'])) { $input['quantity'] = 1; } diff --git a/app/Http/Requests/Product/UpdateProductRequest.php b/app/Http/Requests/Product/UpdateProductRequest.php index 36197b90cf4a..11c2449df698 100644 --- a/app/Http/Requests/Product/UpdateProductRequest.php +++ b/app/Http/Requests/Product/UpdateProductRequest.php @@ -56,7 +56,7 @@ class UpdateProductRequest extends Request { $input = $this->all(); - if (! isset($input['quantity']) || $input['quantity'] < 1) { + if (! isset($input['quantity'])) { $input['quantity'] = 1; } diff --git a/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php b/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php index e6e5556174b2..fff0e66c47e5 100644 --- a/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php @@ -49,7 +49,7 @@ class StoreSchedulerRequest extends Request 'parameters.entity_id' => ['bail', 'sometimes', 'string'], 'parameters.report_name' => ['bail','sometimes', 'string', 'required_if:template,email_report','in:ar_detailed,ar_summary,client_balance,tax_summary,profitloss,client_sales,user_sales,product_sales,activity,client,contact,client_contact,credit,document,expense,invoice,invoice_item,quote,quote_item,recurring_invoice,payment,product,task'], 'parameters.date_key' => ['bail','sometimes', 'string'], - 'parameters.status' => ['bail','sometimes', 'string', 'in:all,draft,paid,unpaid,overdue'], + 'parameters.status' => ['bail','sometimes', 'string'], ]; return $rules; @@ -71,6 +71,14 @@ class StoreSchedulerRequest extends Request $input['parameters']['clients'] = []; } + if(isset($input['parameters']['status'])) { + + $input['parameters']['status'] = collect(explode(",", $input['parameters']['status'])) + ->filter(function($status) { + return in_array($status, ['all','draft','paid','unpaid','overdue']); + })->implode(",") ?? ''; + } + $this->replace($input); } } diff --git a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php index 882c5f971271..2b5ffc4ba7fd 100644 --- a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php @@ -46,6 +46,7 @@ class UpdateSchedulerRequest extends Request 'parameters.entity_id' => ['bail', 'sometimes', 'string'], 'parameters.report_name' => ['bail','sometimes', 'string', 'required_if:template,email_report', 'in:ar_detailed,ar_summary,client_balance,tax_summary,profitloss,client_sales,user_sales,product_sales,client,client_contact,credit,document,expense,invoice,invoice_item,quote,quote_item,recurring_invoice,payment,product,task'], 'parameters.date_key' => ['bail','sometimes', 'string'], + 'parameters.status' => ['bail','sometimes', 'string'], ]; return $rules; @@ -67,6 +68,15 @@ class UpdateSchedulerRequest extends Request $input['parameters']['clients'] = []; } + if(isset($input['parameters']['status'])) { + + $input['parameters']['status'] = collect(explode(",", $input['parameters']['status'])) + ->filter(function ($status) { + return in_array($status, ['all','draft','paid','unpaid','overdue']); + })->implode(",") ?? ''; + } + + $this->replace($input); diff --git a/app/Jobs/Company/CreateCompany.php b/app/Jobs/Company/CreateCompany.php index 5ca76e3071ed..d8c493cfedbf 100644 --- a/app/Jobs/Company/CreateCompany.php +++ b/app/Jobs/Company/CreateCompany.php @@ -65,7 +65,7 @@ class CreateCompany $company->settings = $settings; $company->db = config('database.default'); $company->enabled_modules = config('ninja.enabled_modules'); - $company->subdomain = isset($this->request['subdomain']) ? $this->request['subdomain'] : ''; + $company->subdomain = isset($this->request['subdomain']) ? $this->request['subdomain'] : MultiDB::randomSubdomainGenerator(); $company->custom_fields = new \stdClass; $company->default_password_timeout = 1800000; $company->client_registration_fields = ClientRegistrationFields::generate(); diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 8a324094779f..738cd2de1088 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -568,7 +568,8 @@ class BaseDriver extends AbstractPaymentDriver $error = array_key_exists('error', $response) ? $response['error'] : 'Undefined Error'; $error_code = array_key_exists('error_code', $response) ? $response['error_code'] : 'Undefined Error Code'; - $this->unWindGatewayFees($this->payment_hash); + if($this->payment_hash) + $this->unWindGatewayFees($this->payment_hash); $this->sendFailureMail($error); @@ -579,10 +580,6 @@ class BaseDriver extends AbstractPaymentDriver $invoices = Invoice::query()->whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->withTrashed()->get(); - // $invoices->each(function ($invoice) { - // $invoice->service()->deletePdf(); - // }); - $invoices->first()->invitations->each(function ($invitation) use ($nmo) { if (! $invitation->contact->trashed()) { $nmo->to_user = $invitation->contact; diff --git a/app/PaymentDrivers/GoCardless/InstantBankPay.php b/app/PaymentDrivers/GoCardless/InstantBankPay.php index b6d8f31faea1..947e2da33add 100644 --- a/app/PaymentDrivers/GoCardless/InstantBankPay.php +++ b/app/PaymentDrivers/GoCardless/InstantBankPay.php @@ -136,10 +136,10 @@ class InstantBankPay implements MethodInterface public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) { $data = [ - 'payment_method' => $payment->links->mandate, + 'payment_method' => $payment->links->mandate, //@phpstan-ignore tag 'payment_type' => PaymentType::INSTANT_BANK_PAY, 'amount' => $this->go_cardless->payment_hash->data->amount_with_fee, - 'transaction_reference' => $payment->id, + 'transaction_reference' => $payment->id, //@phpstan-ignore tag 'gateway_type_id' => GatewayType::INSTANT_BANK_PAY, ]; diff --git a/app/Transformers/ActivityTransformer.php b/app/Transformers/ActivityTransformer.php index 6d8f465f1e95..84130c74280e 100644 --- a/app/Transformers/ActivityTransformer.php +++ b/app/Transformers/ActivityTransformer.php @@ -98,6 +98,11 @@ class ActivityTransformer extends EntityTransformer public function includeClient(Activity $activity) { + + if (!$activity->client) { + return null; + } + $transformer = new ClientTransformer($this->serializer); return $this->includeItem($activity->client, $transformer, Client::class); @@ -105,6 +110,10 @@ class ActivityTransformer extends EntityTransformer public function includeVendor(Activity $activity) { + if (!$activity->vendor) { + return null; + } + $transformer = new VendorTransformer($this->serializer); return $this->includeItem($activity->vendor, $transformer, Vendor::class); @@ -112,6 +121,11 @@ class ActivityTransformer extends EntityTransformer public function includeContact(Activity $activity) { + + if (!$activity->contact) { + return null; + } + $transformer = new ClientContactTransformer($this->serializer); return $this->includeItem($activity->contact, $transformer, ClientContact::class); @@ -119,6 +133,11 @@ class ActivityTransformer extends EntityTransformer public function includeVendorContact(Activity $activity) { + + if (!$activity->vendor_contact) { + return null; + } + $transformer = new VendorContactTransformer($this->serializer); return $this->includeItem($activity->vendor_contact, $transformer, VendorContact::class); @@ -126,6 +145,11 @@ class ActivityTransformer extends EntityTransformer public function includeRecurringInvoice(Activity $activity) { + + if (!$activity->recurring_invoice) { + return null; + } + $transformer = new RecurringInvoiceTransformer($this->serializer); return $this->includeItem($activity->recurring_invoice, $transformer, RecurringInvoice::class); @@ -133,14 +157,24 @@ class ActivityTransformer extends EntityTransformer public function includePurchaseOrder(Activity $activity) { + + if (!$activity->purchase_order) { + return null; + } + $transformer = new PurchaseOrderTransformer($this->serializer); - return $this->includeItem($activity->purchase_order(), $transformer, PurchaseOrder::class); + return $this->includeItem($activity->purchase_order, $transformer, PurchaseOrder::class); } public function includeQuote(Activity $activity) { + + if (!$activity->quote) { + return null; + } + $transformer = new RecurringInvoiceTransformer($this->serializer); return $this->includeItem($activity->quote, $transformer, Quote::class); @@ -148,6 +182,10 @@ class ActivityTransformer extends EntityTransformer public function includeInvoice(Activity $activity) { + if (!$activity->invoice) { + return null; + } + $transformer = new InvoiceTransformer($this->serializer); return $this->includeItem($activity->invoice, $transformer, Invoice::class); @@ -155,6 +193,10 @@ class ActivityTransformer extends EntityTransformer public function includeCredit(Activity $activity) { + if (!$activity->credit) { + return null; + } + $transformer = new CreditTransformer($this->serializer); return $this->includeItem($activity->credit, $transformer, Credit::class); @@ -162,6 +204,10 @@ class ActivityTransformer extends EntityTransformer public function includePayment(Activity $activity) { + if (!$activity->payment) { + return null; + } + $transformer = new PaymentTransformer($this->serializer); return $this->includeItem($activity->payment, $transformer, Payment::class); @@ -169,6 +215,10 @@ class ActivityTransformer extends EntityTransformer public function includeUser(Activity $activity) { + if (!$activity->user) { + return null; + } + $transformer = new UserTransformer($this->serializer); return $this->includeItem($activity->user, $transformer, User::class); @@ -176,6 +226,10 @@ class ActivityTransformer extends EntityTransformer public function includeExpense(Activity $activity) { + if (!$activity->expense) { + return null; + } + $transformer = new ExpenseTransformer($this->serializer); return $this->includeItem($activity->expense, $transformer, Expense::class); @@ -183,6 +237,10 @@ class ActivityTransformer extends EntityTransformer public function includeTask(Activity $activity) { + if (!$activity->task) { + return null; + } + $transformer = new TaskTransformer($this->serializer); return $this->includeItem($activity->task, $transformer, Task::class); diff --git a/app/Transformers/ProductTransformer.php b/app/Transformers/ProductTransformer.php index cc28edc2ed1d..93b1f98ce050 100644 --- a/app/Transformers/ProductTransformer.php +++ b/app/Transformers/ProductTransformer.php @@ -74,7 +74,7 @@ class ProductTransformer extends EntityTransformer 'notes' => $product->notes ?: '', 'cost' => (float) $product->cost ?: 0, 'price' => (float) $product->price ?: 0, - 'quantity' => (float) $product->quantity ?: 1.0, + 'quantity' => is_numeric($product->quantity) ? (float) $product->quantity : (float) 1.0, 'tax_name1' => $product->tax_name1 ?: '', 'tax_rate1' => (float) $product->tax_rate1 ?: 0, 'tax_name2' => $product->tax_name2 ?: '', diff --git a/config/ninja.php b/config/ninja.php index 9132ad5f793d..6221456e165f 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -17,8 +17,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => env('APP_VERSION', '5.7.61'), - 'app_tag' => env('APP_TAG', '5.7.61'), + 'app_version' => env('APP_VERSION', '5.7.62'), + 'app_tag' => env('APP_TAG', '5.7.62'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false), diff --git a/phpstan.neon b/phpstan.neon index a9ed25ec5812..6f2c4251a087 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -28,4 +28,5 @@ parameters: - '#Array has 2 duplicate keys with value#' - '#Call to an undefined method#' - '#makeHidden#' - - '#Socialite#' \ No newline at end of file + - '#Socialite#' + - '#Access to protected property#' \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php b/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php index c94550d3f331..0828d552a248 100644 --- a/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php @@ -28,13 +28,13 @@ @endsection @push('footer') - +
@endpush \ No newline at end of file diff --git a/tests/Feature/Scheduler/SchedulerTest.php b/tests/Feature/Scheduler/SchedulerTest.php index 56b70ab5c230..861a2111bd19 100644 --- a/tests/Feature/Scheduler/SchedulerTest.php +++ b/tests/Feature/Scheduler/SchedulerTest.php @@ -445,17 +445,11 @@ class SchedulerTest extends TestCase ]; $response = false; - - try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/task_schedulers', $data); - } catch (ValidationException $e) { - $message = json_decode($e->validator->getMessageBag(), 1); - nlog($message); - } - + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/task_schedulers', $data); + $response->assertStatus(200); $data = $response->json(); @@ -509,19 +503,13 @@ class SchedulerTest extends TestCase $response = false; - try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/task_schedulers', $data); - } catch (ValidationException $e) { - $message = json_decode($e->validator->getMessageBag(), 1); - nlog($message); - } - + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/task_schedulers', $data); + $response->assertStatus(200); - - + $data = [ 'name' => 'A single Client', 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY,