mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 13:54:34 -04:00
Template service client variables:
This commit is contained in:
parent
0d4a1b9043
commit
3e79df8809
@ -557,15 +557,7 @@ class TemplateService
|
|||||||
'reminder_last_sent' => $this->translateDate($invoice->reminder_last_sent, $invoice->client->date_format(), $invoice->client->locale()),
|
'reminder_last_sent' => $this->translateDate($invoice->reminder_last_sent, $invoice->client->date_format(), $invoice->client->locale()),
|
||||||
'paid_to_date' => Number::formatMoney($invoice->paid_to_date, $invoice->client),
|
'paid_to_date' => Number::formatMoney($invoice->paid_to_date, $invoice->client),
|
||||||
'auto_bill_enabled' => (bool) $invoice->auto_bill_enabled,
|
'auto_bill_enabled' => (bool) $invoice->auto_bill_enabled,
|
||||||
'client' => [
|
'client' => $this->getClient($invoice),
|
||||||
'name' => $invoice->client->present()->name(),
|
|
||||||
'balance' => $invoice->client->balance,
|
|
||||||
'payment_balance' => $invoice->client->payment_balance,
|
|
||||||
'credit_balance' => $invoice->client->credit_balance,
|
|
||||||
'vat_number' => $invoice->client->vat_number ?? '',
|
|
||||||
'currency' => $invoice->client->currency()->code ?? 'USD',
|
|
||||||
'locale' => substr($invoice->client->locale(), 0, 2),
|
|
||||||
],
|
|
||||||
'payments' => $payments,
|
'payments' => $payments,
|
||||||
'total_tax_map' => $invoice->calc()->getTotalTaxMap(),
|
'total_tax_map' => $invoice->calc()->getTotalTaxMap(),
|
||||||
'line_tax_map' => $invoice->calc()->getTaxMap(),
|
'line_tax_map' => $invoice->calc()->getTaxMap(),
|
||||||
@ -680,14 +672,7 @@ class TemplateService
|
|||||||
'custom_value4' => $payment->custom_value4 ?? '',
|
'custom_value4' => $payment->custom_value4 ?? '',
|
||||||
'created_at' => $this->translateDate($payment->created_at, $payment->client->date_format(), $payment->client->locale()),
|
'created_at' => $this->translateDate($payment->created_at, $payment->client->date_format(), $payment->client->locale()),
|
||||||
'updated_at' => $this->translateDate($payment->updated_at, $payment->client->date_format(), $payment->client->locale()),
|
'updated_at' => $this->translateDate($payment->updated_at, $payment->client->date_format(), $payment->client->locale()),
|
||||||
'client' => [
|
'client' => $this->getClient($payment),
|
||||||
'name' => $payment->client->present()->name(),
|
|
||||||
'balance' => $payment->client->balance,
|
|
||||||
'payment_balance' => $payment->client->payment_balance,
|
|
||||||
'credit_balance' => $payment->client->credit_balance,
|
|
||||||
'vat_number' => $payment->client->vat_number ?? '',
|
|
||||||
'currency' => $payment->client->currency()->code ?? 'USD',
|
|
||||||
],
|
|
||||||
'paymentables' => $pivot,
|
'paymentables' => $pivot,
|
||||||
'refund_activity' => $this->getPaymentRefundActivity($payment),
|
'refund_activity' => $this->getPaymentRefundActivity($payment),
|
||||||
];
|
];
|
||||||
@ -760,14 +745,7 @@ class TemplateService
|
|||||||
'amount' => Number::formatMoney($quote->amount, $quote->client),
|
'amount' => Number::formatMoney($quote->amount, $quote->client),
|
||||||
'balance' => Number::formatMoney($quote->balance, $quote->client),
|
'balance' => Number::formatMoney($quote->balance, $quote->client),
|
||||||
'balance_raw' => (float) $quote->balance,
|
'balance_raw' => (float) $quote->balance,
|
||||||
'client' => [
|
'client' => $this->getClient($quote),
|
||||||
'name' => $quote->client->present()->name(),
|
|
||||||
'balance' => $quote->client->balance,
|
|
||||||
'payment_balance' => $quote->client->payment_balance,
|
|
||||||
'credit_balance' => $quote->client->credit_balance,
|
|
||||||
'vat_number' => $quote->client->vat_number ?? '',
|
|
||||||
'currency' => $quote->client->currency()->code ?? 'USD',
|
|
||||||
],
|
|
||||||
'status_id' => $quote->status_id,
|
'status_id' => $quote->status_id,
|
||||||
'status' => Quote::stringStatus($quote->status_id),
|
'status' => Quote::stringStatus($quote->status_id),
|
||||||
'number' => $quote->number ?: '',
|
'number' => $quote->number ?: '',
|
||||||
@ -888,14 +866,7 @@ class TemplateService
|
|||||||
'reminder_last_sent' => $this->translateDate($credit->reminder_last_sent, $credit->client->date_format(), $credit->client->locale()),
|
'reminder_last_sent' => $this->translateDate($credit->reminder_last_sent, $credit->client->date_format(), $credit->client->locale()),
|
||||||
'paid_to_date' => Number::formatMoney($credit->paid_to_date, $credit->client),
|
'paid_to_date' => Number::formatMoney($credit->paid_to_date, $credit->client),
|
||||||
'auto_bill_enabled' => (bool) $credit->auto_bill_enabled,
|
'auto_bill_enabled' => (bool) $credit->auto_bill_enabled,
|
||||||
'client' => [
|
'client' => $this->getClient($credit),
|
||||||
'name' => $credit->client->present()->name(),
|
|
||||||
'balance' => $credit->client->balance,
|
|
||||||
'payment_balance' => $credit->client->payment_balance,
|
|
||||||
'credit_balance' => $credit->client->credit_balance,
|
|
||||||
'vat_number' => $credit->client->vat_number ?? '',
|
|
||||||
'currency' => $credit->client->currency()->code ?? 'USD',
|
|
||||||
],
|
|
||||||
'payments' => $payments,
|
'payments' => $payments,
|
||||||
'total_tax_map' => $credit->calc()->getTotalTaxMap(),
|
'total_tax_map' => $credit->calc()->getTotalTaxMap(),
|
||||||
'line_tax_map' => $credit->calc()->getTaxMap(),
|
'line_tax_map' => $credit->calc()->getTaxMap(),
|
||||||
@ -924,6 +895,25 @@ class TemplateService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getClient($entity): array
|
||||||
|
{
|
||||||
|
|
||||||
|
return $entity->client ? [
|
||||||
|
'name' => $entity->client->present()->name(),
|
||||||
|
'balance' => $entity->client->balance,
|
||||||
|
'payment_balance' => $entity->client->payment_balance,
|
||||||
|
'credit_balance' => $entity->client->credit_balance,
|
||||||
|
'vat_number' => $entity->client->vat_number ?? '',
|
||||||
|
'currency' => $entity->client->currency()->code ?? 'USD',
|
||||||
|
'custom_value1' => $entity->client->custom_value1 ?? '',
|
||||||
|
'custom_value2' => $entity->client->custom_value2 ?? '',
|
||||||
|
'custom_value3' => $entity->client->custom_value3 ?? '',
|
||||||
|
'custom_value4' => $entity->client->custom_value4 ?? '',
|
||||||
|
'address' => $entity->client->present()->address(),
|
||||||
|
'shipping_address' => $entity->client->present()->shipping_address(),
|
||||||
|
'locale' => substr($entity->client->locale(), 0, 2),
|
||||||
|
] : [];
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @todo refactor
|
* @todo refactor
|
||||||
*
|
*
|
||||||
@ -953,14 +943,7 @@ class TemplateService
|
|||||||
'custom_value4' => $task->custom_value4 ?: '',
|
'custom_value4' => $task->custom_value4 ?: '',
|
||||||
'status' => $task->status ? $task->status->name : '',
|
'status' => $task->status ? $task->status->name : '',
|
||||||
'user' => $this->userInfo($task->user),
|
'user' => $this->userInfo($task->user),
|
||||||
'client' => $task->client ? [
|
'client' => $this->getClient($task),
|
||||||
'name' => $task->client->present()->name(),
|
|
||||||
'balance' => $task->client->balance,
|
|
||||||
'payment_balance' => $task->client->payment_balance,
|
|
||||||
'credit_balance' => $task->client->credit_balance,
|
|
||||||
'vat_number' => $task->client->vat_number ?? '',
|
|
||||||
'currency' => $task->client->currency()->code ?? 'USD',
|
|
||||||
] : [],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -1015,14 +998,7 @@ class TemplateService
|
|||||||
'color' => (string) $project->color ?: '',
|
'color' => (string) $project->color ?: '',
|
||||||
'current_hours' => (int) $project->current_hours ?: 0,
|
'current_hours' => (int) $project->current_hours ?: 0,
|
||||||
'tasks' => ($project->tasks && !$nested) ? $this->processTasks($project->tasks, true) : [], //@phpstan-ignore-line
|
'tasks' => ($project->tasks && !$nested) ? $this->processTasks($project->tasks, true) : [], //@phpstan-ignore-line
|
||||||
'client' => $project->client ? [
|
'client' => $this->getClient($project),
|
||||||
'name' => $project->client->present()->name(),
|
|
||||||
'balance' => $project->client->balance,
|
|
||||||
'payment_balance' => $project->client->payment_balance,
|
|
||||||
'credit_balance' => $project->client->credit_balance,
|
|
||||||
'vat_number' => $project->client->vat_number ?? '',
|
|
||||||
'currency' => $project->client->currency()->code ?? 'USD',
|
|
||||||
] : [],
|
|
||||||
'user' => $this->userInfo($project->user),
|
'user' => $this->userInfo($project->user),
|
||||||
'invoices' => $this->processInvoices($project->invoices)
|
'invoices' => $this->processInvoices($project->invoices)
|
||||||
];
|
];
|
||||||
@ -1047,16 +1023,7 @@ class TemplateService
|
|||||||
] : [],
|
] : [],
|
||||||
'amount' => (float)$purchase_order->amount,
|
'amount' => (float)$purchase_order->amount,
|
||||||
'balance' => (float)$purchase_order->balance,
|
'balance' => (float)$purchase_order->balance,
|
||||||
'client' => $purchase_order->client ? [
|
'client' => $this->getClient($purchase_order),
|
||||||
'name' => $purchase_order->client->present()->name(),
|
|
||||||
'balance' => $purchase_order->client->balance,
|
|
||||||
'payment_balance' => $purchase_order->client->payment_balance,
|
|
||||||
'credit_balance' => $purchase_order->client->credit_balance,
|
|
||||||
'vat_number' => $purchase_order->client->vat_number ?? '',
|
|
||||||
'address' => $purchase_order->client->present()->address(),
|
|
||||||
'shipping_address' => $purchase_order->client->present()->shipping_address(),
|
|
||||||
'currency' => $purchase_order->client->currency()->code ?? 'USD',
|
|
||||||
] : [],
|
|
||||||
'status_id' => (string)($purchase_order->status_id ?: 1),
|
'status_id' => (string)($purchase_order->status_id ?: 1),
|
||||||
'status' => PurchaseOrder::stringStatus($purchase_order->status_id ?? 1),
|
'status' => PurchaseOrder::stringStatus($purchase_order->status_id ?? 1),
|
||||||
'is_deleted' => (bool)$purchase_order->is_deleted,
|
'is_deleted' => (bool)$purchase_order->is_deleted,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user