1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00

Merge pull request #9037 from turbo124/v5-develop

v5.7.62
This commit is contained in:
David Bomba 2023-12-12 17:28:28 +11:00 committed by GitHub
commit 63c1bfbf80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 350 additions and 221 deletions

View File

@ -1 +1 @@
5.7.61
5.7.62

View File

@ -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}") ?? '';

View File

@ -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;
}
}

View File

@ -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(): '';

View File

@ -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 : '';

View File

@ -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');

View File

@ -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(): '';

View File

@ -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() : '';

View File

@ -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;
}
}

View File

@ -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;
}

View File

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

View File

@ -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(): '';

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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();

View File

@ -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;

View File

@ -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,
];

View File

@ -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);

View File

@ -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 ?: '',

View File

@ -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),

View File

@ -28,4 +28,5 @@ parameters:
- '#Array has 2 duplicate keys with value#'
- '#Call to an undefined method#'
- '#makeHidden#'
- '#Socialite#'
- '#Socialite#'
- '#Access to protected property#'

View File

@ -28,13 +28,13 @@
@endsection
@push('footer')
<script src="https://www.paypal.com/sdk/js?enable-funding={!! $funding_options !!}&disable-funding=credit&components=buttons,hosted-fields,funding-eligibility&intent=capture&client-id={!! $client_id !!}" data-client-token="{!! $token !!}">
<script src="https://www.paypal.com/sdk/js?enable-funding={!! $funding_options !!}&disable-funding=credit&components=buttons,hosted-fields,funding-eligibility&intent=capture&client-id={!! $client_id !!}&buyer-country=US&currency=USD" data-client-token="{!! $token !!}">
</script>
<script>
paypal.Buttons({
fundingSource: "{{ $funding_options }}",
env: "{{ $gateway->company_gateway->getConfigField('testMode') ? 'sandbox' : 'production' }}",
client: {
@if($gateway->company_gateway->getConfigField('testMode'))
@ -60,7 +60,12 @@
console.log(err);
}
}).render('#paypal-button-container');
}).render('#paypal-button-container').catch(function(err) {
document.getElementById('errors').textContent = err;
document.getElementById('errors').hidden = false;
})

View File

@ -30,7 +30,7 @@
@push('footer')
<script src="https://www.paypal.com/sdk/js?client-id={!! $client_id !!}&currency={!! $currency !!}&merchant-id={!! $merchantId !!}&components=buttons,funding-eligibility&intent=capture" data-partner-attribution-id="invoiceninja_SP_PPCP"></script>
<script src="https://www.paypal.com/sdk/js?client-id={!! $client_id !!}&currency={!! $currency !!}&merchant-id={!! $merchantId !!}&components=buttons,funding-eligibility&intent=capture&enable-funding={!! $funding_source !!}" data-partner-attribution-id="invoiceninja_SP_PPCP"></script>
<div id="paypal-button-container"></div>
<script>
@ -67,7 +67,13 @@
document.getElementById("server_response").submit();
}
}).render('#paypal-button-container');
}).render('#paypal-button-container').catch(function(err) {
document.getElementById('errors').textContent = err;
document.getElementById('errors').hidden = false;
});
</script>
@endpush

View File

@ -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,