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/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/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/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