mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge for templates
This commit is contained in:
commit
f8cab32e53
@ -56,7 +56,10 @@ class StoreTaskRequest extends Request
|
||||
|
||||
$rules['time_log'] = ['bail',function ($attribute, $values, $fail) {
|
||||
|
||||
if(!is_array(json_decode($values, true))) {
|
||||
if(is_string($values))
|
||||
$values = json_decode($values, true);
|
||||
|
||||
if(!is_array($values)) {
|
||||
$fail('The '.$attribute.' must be a valid array.');
|
||||
return;
|
||||
}
|
||||
|
@ -38,9 +38,6 @@ class UpdateTaskRequest extends Request
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->can('edit', $this->task);
|
||||
}
|
||||
|
||||
@ -65,7 +62,11 @@ class UpdateTaskRequest extends Request
|
||||
|
||||
$rules['time_log'] = ['bail', function ($attribute, $values, $fail) {
|
||||
|
||||
if(!is_array(json_decode($values, true))) {
|
||||
if(is_string($values)) {
|
||||
$values = json_decode($values, true);
|
||||
}
|
||||
|
||||
if(!is_array($values)) {
|
||||
$fail('The '.$attribute.' must be a valid array.');
|
||||
return;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ use App\Models\Quote;
|
||||
use App\Utils\Number;
|
||||
use Twig\Error\Error;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Design;
|
||||
use App\Models\Vendor;
|
||||
@ -40,17 +41,12 @@ use App\Utils\PaymentHtmlEngine;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Utils\Traits\Pdf\PdfMaker;
|
||||
use App\Utils\VendorHtmlEngine;
|
||||
use League\Fractal\Manager;
|
||||
use League\Fractal\Serializer\ArraySerializer;
|
||||
use Twig\Environment;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
use Twig\Error\Error;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Extension\DebugExtension;
|
||||
use Twig\Extension\StringLoaderExtension;
|
||||
use Twig\Extra\Intl\IntlExtension;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
use Twig\Sandbox\SecurityError;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
@ -78,7 +74,7 @@ class TemplateService
|
||||
|
||||
private \DomDocument $document;
|
||||
|
||||
public Environment $twig;
|
||||
public \Twig\Environment $twig;
|
||||
|
||||
private string $compiled_html = '';
|
||||
|
||||
@ -122,8 +118,7 @@ class TemplateService
|
||||
$this->twig = new Environment($loader, [
|
||||
'debug' => true,
|
||||
]);
|
||||
|
||||
$string_extension = new StringLoaderExtension();
|
||||
$string_extension = new \Twig\Extension\StringLoaderExtension();
|
||||
$this->twig->addExtension($string_extension);
|
||||
$this->twig->addExtension(new IntlExtension());
|
||||
$this->twig->addExtension(new DebugExtension());
|
||||
@ -133,7 +128,7 @@ class TemplateService
|
||||
});
|
||||
$this->twig->addFunction($function);
|
||||
|
||||
$filter = new TwigFilter('sum', function (array $array, string $column) {
|
||||
$filter = new \Twig\TwigFilter('sum', function (array $array, string $column) {
|
||||
return array_sum(array_column($array, $column));
|
||||
});
|
||||
|
||||
@ -292,7 +287,7 @@ class TemplateService
|
||||
>>>>>>> support_for_custom_statement_designs
|
||||
} catch(SecurityError $e) {
|
||||
nlog("security = " . $e->getMessage());
|
||||
continue;
|
||||
throw ($e);
|
||||
}
|
||||
|
||||
$template = $template->render($this->data);
|
||||
@ -630,11 +625,7 @@ class TemplateService
|
||||
*/
|
||||
public function padLineItems(array $items, Vendor | Client $client_or_vendor): array
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
return collect($items)->map(function ($item) use ($client) {
|
||||
=======
|
||||
return collect($items)->map(function ($item) use ($client_or_vendor) {
|
||||
>>>>>>> support_for_custom_statement_designs
|
||||
|
||||
$item->cost_raw = $item->cost ?? 0;
|
||||
$item->discount_raw = $item->discount ?? 0;
|
||||
@ -643,18 +634,6 @@ class TemplateService
|
||||
$item->tax_amount_raw = $item->tax_amount ?? 0;
|
||||
$item->product_cost_raw = $item->product_cost ?? 0;
|
||||
|
||||
<<<<<<< HEAD
|
||||
$item->cost = Number::formatMoney($item->cost_raw, $client);
|
||||
|
||||
if($item->is_amount_discount) {
|
||||
$item->discount = Number::formatMoney($item->discount_raw, $client);
|
||||
}
|
||||
|
||||
$item->line_total = Number::formatMoney($item->line_total_raw, $client);
|
||||
$item->gross_line_total = Number::formatMoney($item->gross_line_total_raw, $client);
|
||||
$item->tax_amount = Number::formatMoney($item->tax_amount_raw, $client);
|
||||
$item->product_cost = Number::formatMoney($item->product_cost_raw, $client);
|
||||
=======
|
||||
$item->cost = Number::formatMoney($item->cost_raw, $client_or_vendor);
|
||||
|
||||
if($item->is_amount_discount) {
|
||||
@ -665,7 +644,6 @@ class TemplateService
|
||||
$item->gross_line_total = Number::formatMoney($item->gross_line_total_raw, $client_or_vendor);
|
||||
$item->tax_amount = Number::formatMoney($item->tax_amount_raw, $client_or_vendor);
|
||||
$item->product_cost = Number::formatMoney($item->product_cost_raw, $client_or_vendor);
|
||||
>>>>>>> support_for_custom_statement_designs
|
||||
|
||||
return $item;
|
||||
|
||||
@ -732,7 +710,7 @@ class TemplateService
|
||||
'balance_raw' => ($payment->amount - $payment->refunded - $payment->applied),
|
||||
'date' => $this->translateDate($payment->date, $payment->client->date_format(), $payment->client->locale()),
|
||||
'method' => $payment->translatedType(),
|
||||
'currency' => $payment->currency->code ?? $payment->company->currency()->code,
|
||||
'currency' => $payment->currency->code,
|
||||
'exchange_rate' => $payment->exchange_rate,
|
||||
'transaction_reference' => $payment->transaction_reference,
|
||||
'is_manual' => $payment->is_manual,
|
||||
@ -888,7 +866,8 @@ class TemplateService
|
||||
$credits = collect($credits)
|
||||
->map(function ($credit) {
|
||||
|
||||
<<<<<<< HEAD
|
||||
$this->entity = $credit;
|
||||
|
||||
return [
|
||||
'amount' => Number::formatMoney($credit->amount, $credit->client),
|
||||
'balance' => Number::formatMoney($credit->balance, $credit->client),
|
||||
|
Loading…
x
Reference in New Issue
Block a user