mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-30 19:42:57 -04:00 
			
		
		
		
	
						commit
						ed30fa31fa
					
				| @ -1 +1 @@ | ||||
| 5.7.47 | ||||
| 5.7.48 | ||||
| @ -50,6 +50,7 @@ class PurchaseOrderFactory | ||||
|         $purchase_order->company_id = $company_id; | ||||
|         $purchase_order->recurring_id = null; | ||||
|         $purchase_order->exchange_rate = 1; | ||||
|         $purchase_order->total_taxes = 0; | ||||
|          | ||||
|         return $purchase_order; | ||||
|     } | ||||
|  | ||||
| @ -69,7 +69,6 @@ class EpcQrGenerator | ||||
|             return ''; | ||||
|         } | ||||
|          | ||||
|         | ||||
|     } | ||||
| 
 | ||||
|     public function encodeMessage() | ||||
| @ -86,7 +85,7 @@ class EpcQrGenerator | ||||
|             $this->sepa['purpose'], | ||||
|             substr($this->invoice->number, 0, 34), | ||||
|             '', | ||||
|             '' | ||||
|             ' ' | ||||
|         ]), "\n"); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -167,11 +167,11 @@ class InvitationController extends Controller | ||||
|     { | ||||
|         set_time_limit(45); | ||||
| 
 | ||||
|         if (Ninja::isHosted()) { | ||||
|         // if (Ninja::isHosted()) {
 | ||||
|             return $this->returnRawPdf($entity, $invitation_key); | ||||
|         } | ||||
|         // }
 | ||||
| 
 | ||||
|         return redirect('client/'.$entity.'/'.$invitation_key.'/download_pdf'); | ||||
|         // return redirect('client/'.$entity.'/'.$invitation_key.'/download_pdf');
 | ||||
|     } | ||||
| 
 | ||||
|     private function returnRawPdf(string $entity, string $invitation_key) | ||||
|  | ||||
| @ -388,6 +388,7 @@ class PreviewController extends BaseController | ||||
|         $design_object = json_decode(json_encode(request()->input('design')), 1); | ||||
| 
 | ||||
|         $ts = (new TemplateService()); | ||||
| 
 | ||||
|         try { | ||||
|             $ts->setCompany($company) | ||||
|                 ->setTemplate($design_object) | ||||
| @ -395,7 +396,6 @@ class PreviewController extends BaseController | ||||
|         } catch(SyntaxError $e) { | ||||
| 
 | ||||
|             // return response()->json(['message' => 'Twig syntax is invalid.', 'errors' => new \stdClass], 422);
 | ||||
| 
 | ||||
|         } | ||||
| 
 | ||||
|         $html = $ts->getHtml(); | ||||
|  | ||||
| @ -54,14 +54,14 @@ class StoreTaskRequest extends Request | ||||
|             $rules['project_id'] = 'bail|required|exists:projects,id,company_id,'.$user->company()->id.',is_deleted,0'; | ||||
|         } | ||||
| 
 | ||||
|         $rules['time_log'] = ['bail', function ($attribute, $values, $fail) { | ||||
|         $rules['time_log'] = ['bail',function ($attribute, $values, $fail) { | ||||
|              | ||||
|             if(is_string($values)) { | ||||
|                 $values = json_decode($values, 1); | ||||
|             } | ||||
|             if(is_string($values)) | ||||
|                 $values = json_decode($values, true); | ||||
| 
 | ||||
|             if(!is_array($values)) { | ||||
|                 return $fail('The '.$attribute.' is invalid. Must be an array.'); | ||||
|                 $fail('The '.$attribute.' must be a valid array.'); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             foreach ($values as $k) { | ||||
| @ -119,6 +119,10 @@ class StoreTaskRequest extends Request | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if(!isset($input['time_log']) || empty($input['time_log']) || $input['time_log'] == '{}'){ | ||||
|             $input['time_log'] = json_encode([]); | ||||
|         } | ||||
| 
 | ||||
|         $this->replace($input); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -43,7 +43,6 @@ class UpdateTaskRequest extends Request | ||||
| 
 | ||||
|     public function rules() | ||||
|     { | ||||
| 
 | ||||
|         /** @var \App\Models\User $user */ | ||||
|         $user = auth()->user(); | ||||
| 
 | ||||
| @ -61,14 +60,15 @@ class UpdateTaskRequest extends Request | ||||
|             $rules['project_id'] = 'bail|required|exists:projects,id,company_id,'.$user->company()->id.',is_deleted,0'; | ||||
|         } | ||||
| 
 | ||||
|         $rules['time_log'] = ['bail',function ($attribute, $values, $fail) { | ||||
|         $rules['time_log'] = ['bail', function ($attribute, $values, $fail) { | ||||
| 
 | ||||
|             if(is_string($values)) { | ||||
|                 $values = json_decode($values, 1); | ||||
|                 $values = json_decode($values, true); | ||||
|             } | ||||
| 
 | ||||
|             if(!is_array($values)) { | ||||
|                 return $fail('The '.$attribute.' is invalid. Must be an array.'); | ||||
|                 $fail('The '.$attribute.' must be a valid array.'); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             foreach ($values as $k) { | ||||
| @ -129,6 +129,10 @@ class UpdateTaskRequest extends Request | ||||
| 
 | ||||
|         } | ||||
| 
 | ||||
|         if(!isset($input['time_log']) || empty($input['time_log']) || $input['time_log'] == '{}') { | ||||
|             $input['time_log'] = json_encode([]); | ||||
|         } | ||||
| 
 | ||||
|         $this->replace($input); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -19,6 +19,7 @@ use Illuminate\Contracts\Validation\Rule; | ||||
| class BlackListRule implements Rule | ||||
| { | ||||
|     private array $blacklist = [ | ||||
|         'ckptr.com', | ||||
|         'pretreer.com', | ||||
|         'candassociates.com', | ||||
|         'vusra.com', | ||||
|  | ||||
| @ -31,6 +31,8 @@ class AdjustProductInventory implements ShouldQueue | ||||
| { | ||||
|     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, UserNotifies; | ||||
| 
 | ||||
|     private array $notified_products = []; | ||||
| 
 | ||||
|     public function __construct(public Company $company, public Invoice $invoice, public $old_invoice = []) | ||||
|     { | ||||
|     } | ||||
| @ -56,18 +58,6 @@ class AdjustProductInventory implements ShouldQueue | ||||
|     { | ||||
|         MultiDB::setDb($this->company->db); | ||||
| 
 | ||||
|         // foreach ($this->invoice->line_items as $item) {
 | ||||
|         //     $p = Product::where('product_key', $item->product_key)->where('company_id', $this->company->id)->first();
 | ||||
| 
 | ||||
|         //     if (! $p) {
 | ||||
|         //         continue;
 | ||||
|         //     }
 | ||||
| 
 | ||||
|         //     $p->in_stock_quantity += $item->quantity;
 | ||||
| 
 | ||||
|         //     $p->saveQuietly();
 | ||||
|         // }
 | ||||
| 
 | ||||
|         collect($this->invoice->line_items)->filter(function ($item) { | ||||
|             return $item->type_id == '1'; | ||||
|         })->each(function ($i) { | ||||
| @ -147,11 +137,15 @@ class AdjustProductInventory implements ShouldQueue | ||||
|         $nmo->company = $this->company; | ||||
|         $nmo->settings = $this->company->settings; | ||||
| 
 | ||||
|          | ||||
|         $this->company->company_users->each(function ($cu) use ($product, $nmo, $notification_level) { | ||||
|             if ($this->checkNotificationExists($cu, $product, ['inventory_all', 'inventory_user', 'inventory_threshold_all', 'inventory_threshold_user'])) { | ||||
|          | ||||
|             /** @var \App\Models\CompanyUser $cu */ | ||||
|             if ($this->checkNotificationExists($cu, $product, ['inventory_all', 'inventory_user', 'inventory_threshold_all', 'inventory_threshold_user']) && (! in_array($product->id, $this->notified_products))) { | ||||
|                 $nmo->mailable = new NinjaMailer((new InventoryNotificationObject($product, $notification_level, $cu->portalType()))->build()); | ||||
|                 $nmo->to_user = $cu->user; | ||||
|                 NinjaMailerJob::dispatch($nmo); | ||||
|                 $this->notified_products[] = $product->id; | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
| @ -69,7 +69,7 @@ class InventoryNotificationObject | ||||
|                 ] | ||||
|             ), | ||||
|             'url' => $this->product->portalUrl($this->use_react_url), | ||||
|             'button' => $this->use_react_url ? ctrans('texts.product_library') : ctrans('ninja.app_url'), | ||||
|             'button' => ctrans('texts.view'), | ||||
|             'signature' => $this->product->company->settings->email_signature, | ||||
|             'logo' => $this->product->company->present()->logo(), | ||||
|             'settings' => $this->product->company->settings, | ||||
|  | ||||
| @ -211,7 +211,7 @@ class Document extends BaseModel | ||||
|         $image = $this->getFile(); | ||||
|         $catch_image = $image; | ||||
| 
 | ||||
|         if(extension_loaded('imagick')) | ||||
|         if(!extension_loaded('imagick')) | ||||
|             return $catch_image; | ||||
| 
 | ||||
|         try { | ||||
|  | ||||
| @ -268,7 +268,8 @@ class PurchaseOrder extends BaseModel | ||||
|     { | ||||
|         return $this->belongsTo(Client::class)->withTrashed(); | ||||
|     } | ||||
|     public function markInvitationsSent() | ||||
| 
 | ||||
|     public function markInvitationsSent(): void | ||||
|     { | ||||
|         $this->invitations->each(function ($invitation) { | ||||
|             if (! isset($invitation->sent_date)) { | ||||
|  | ||||
| @ -239,4 +239,23 @@ class Task extends BaseModel | ||||
| 
 | ||||
|         return $this->company->settings->default_task_rate ?? 0; | ||||
|     } | ||||
| 
 | ||||
|     public function processLogs() | ||||
|     { | ||||
|         return  | ||||
|         collect($this->time_log)->map(function ($log){ | ||||
| 
 | ||||
|             $parent_entity = $this->client ?? $this->company; | ||||
| 
 | ||||
|             if($log[0]) | ||||
|                 $log[0] = Carbon::createFromTimestamp($log[0])->format($parent_entity->date_format()); | ||||
| 
 | ||||
|             if($log[1] && $log[1] != 0) | ||||
|                 $log[1] = Carbon::createFromTimestamp($log[1])->format($parent_entity->date_format()); | ||||
|             else      | ||||
|                 $log[1] = ctrans('texts.running'); | ||||
| 
 | ||||
|             return $log; | ||||
|         })->toArray(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -69,7 +69,7 @@ class PayFastPaymentDriver extends BaseDriver | ||||
|     public function init() | ||||
|     { | ||||
|         try { | ||||
|             $this->payfast = new \PayFast\PayFastPayment( | ||||
|             $this->payfast = new \Payfast\PayFastPayment( | ||||
|                 [ | ||||
|                     'merchantId' => $this->company_gateway->getConfigField('merchantId'), | ||||
|                     'merchantKey' => $this->company_gateway->getConfigField('merchantKey'), | ||||
|  | ||||
| @ -37,7 +37,8 @@ class ClientService | ||||
| 
 | ||||
|     public function calculateBalance(?Invoice $invoice = null) | ||||
|     { | ||||
|         $balance = Invoice::where('client_id', $this->client->id) | ||||
|         $balance = Invoice::withTrashed() | ||||
|                           ->where('client_id', $this->client->id) | ||||
|                           ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) | ||||
|                           ->where('is_deleted', false) | ||||
|                           ->sum('balance'); | ||||
|  | ||||
| @ -273,7 +273,6 @@ class EmailDefaults | ||||
|         return $this; | ||||
|         // return $this->email->email_object->cc;
 | ||||
|         // return [
 | ||||
| 
 | ||||
|         // ];
 | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -633,9 +633,7 @@ class PdfBuilder | ||||
|                         $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => 'product_table-product.tax2-td']]; | ||||
|                     } elseif ($cell == '$product.tax_rate3') { | ||||
|                         $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => 'product_table-product.tax3-td']]; | ||||
|                     }  | ||||
|                      | ||||
|                     elseif ($cell == '$task.discount' && !$this->service->company->enable_product_discount) { | ||||
|                     } elseif ($cell == '$task.discount' && !$this->service->company->enable_product_discount) { | ||||
|                         $element['elements'][] = ['element' => 'td', 'content' => $row['$task.discount'], 'properties' => ['data-ref' => 'task_table-task.discount-td', 'style' => 'display: none;']]; | ||||
|                     } elseif ($cell == '$task.tax_rate1') { | ||||
|                         $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => 'task_table-task.tax1-td']]; | ||||
| @ -643,10 +641,7 @@ class PdfBuilder | ||||
|                         $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => 'task_table-task.tax2-td']]; | ||||
|                     } elseif ($cell == '$task.tax_rate3') { | ||||
|                         $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => 'task_table-task.tax3-td']]; | ||||
|                     }  | ||||
|                      | ||||
|                      | ||||
|                     elseif ($cell == '$product.unit_cost' || $cell == '$task.rate') { | ||||
|                     } elseif ($cell == '$product.unit_cost' || $cell == '$task.rate') { | ||||
|                         $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['style' => 'white-space: nowrap;', 'data-ref' => "{$_type}_table-" . substr($cell, 1) . '-td']]; | ||||
|                     } else { | ||||
|                         $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => "{$_type}_table-" . substr($cell, 1) . '-td']]; | ||||
| @ -677,7 +672,7 @@ class PdfBuilder | ||||
|         $locale_info = localeconv(); | ||||
|          | ||||
|         foreach ($items as $key => $item) { | ||||
|         /** @var \App\DataMapper\InvoiceItem $item */ | ||||
|             /** @var \App\DataMapper\InvoiceItem $item */ | ||||
| 
 | ||||
|             if ($table_type == '$product' && $item->type_id != 1) { | ||||
|                 if ($item->type_id != 4 && $item->type_id != 6 && $item->type_id != 5) { | ||||
| @ -712,9 +707,9 @@ class PdfBuilder | ||||
|             $data[$key][$table_type.".{$_table_type}4"] = strlen($item->custom_value4) >= 1 ? $helpers->formatCustomFieldValue($this->service->company->custom_fields, "{$_table_type}4", $item->custom_value4, $this->service->config->currency_entity) : ''; | ||||
| 
 | ||||
|             if ($item->quantity > 0 || $item->cost > 0) { | ||||
|                 $data[$key][$table_type.'.quantity'] = $item->quantity; | ||||
|                 $data[$key][$table_type.'.quantity'] = $this->service->config->formatValueNoTrailingZeroes($item->quantity); | ||||
| 
 | ||||
|                 $data[$key][$table_type.'.unit_cost'] = $this->service->config->formatMoney($item->cost); | ||||
|                 $data[$key][$table_type.'.unit_cost'] = $this->service->config->formatMoneyNoRounding($item->cost); | ||||
| 
 | ||||
|                 $data[$key][$table_type.'.cost'] = $this->service->config->formatMoney($item->cost); | ||||
| 
 | ||||
| @ -820,9 +815,7 @@ class PdfBuilder | ||||
|                 $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['data-ref' => "{$type}_table-product.tax2-th", 'hidden' => $this->service->config->settings->hide_empty_columns_on_pdf]]; | ||||
|             } elseif ($column == '$product.tax_rate3') { | ||||
|                 $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['data-ref' => "{$type}_table-product.tax3-th", 'hidden' => $this->service->config->settings->hide_empty_columns_on_pdf]]; | ||||
|             } | ||||
|              | ||||
|             elseif ($column == '$task.discount' && !$this->service->company->enable_product_discount) { | ||||
|             } elseif ($column == '$task.discount' && !$this->service->company->enable_product_discount) { | ||||
|                 $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['data-ref' => "{$type}_table-" . substr($column, 1) . '-th', 'style' => 'display: none;']]; | ||||
|             } elseif ($column == '$task.tax_rate1') { | ||||
|                 $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['data-ref' => "{$type}_table-task.tax1-th", 'hidden' => $this->service->config->settings->hide_empty_columns_on_pdf]]; | ||||
| @ -830,9 +823,7 @@ class PdfBuilder | ||||
|                 $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['data-ref' => "{$type}_table-task.tax2-th", 'hidden' => $this->service->config->settings->hide_empty_columns_on_pdf]]; | ||||
|             } elseif ($column == '$task.tax_rate3') { | ||||
|                 $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['data-ref' => "{$type}_table-task.tax3-th", 'hidden' => $this->service->config->settings->hide_empty_columns_on_pdf]]; | ||||
|             } | ||||
|              | ||||
|             else { | ||||
|             } else { | ||||
|                 $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['data-ref' => "{$type}_table-" . substr($column, 1) . '-th', 'hidden' => $this->service->config->settings->hide_empty_columns_on_pdf]]; | ||||
|             } | ||||
|         } | ||||
| @ -1166,8 +1157,7 @@ class PdfBuilder | ||||
|             } elseif (Str::startsWith($variable, '$custom_surcharge')) { | ||||
|                 $_variable = ltrim($variable, '$'); // $custom_surcharge1 -> custom_surcharge1
 | ||||
| 
 | ||||
|                 // $visible = intval($this->service->config->entity->{$_variable}) != 0;
 | ||||
|                 $visible = intval(str_replace(['0','.'], '', $this->service->config->entity->{$_variable})) != 0; | ||||
|                 $visible = intval(str_replace(['0','.'], '', ($this->service->config->entity->{$_variable} ?? ''))) != 0; | ||||
| 
 | ||||
|                 $elements[1]['elements'][] = ['element' => 'div', 'elements' => [ | ||||
|                     ['element' => 'span', 'content' => $variable . '_label', 'properties' => ['hidden' => !$visible, 'data-ref' => 'totals_table-' . substr($variable, 1) . '-label']], | ||||
| @ -1622,12 +1612,6 @@ class PdfBuilder | ||||
|     // Dom Traversal
 | ||||
|     ///////////////////////////////////////
 | ||||
| 
 | ||||
| 
 | ||||
|     public function getSectionNode(string $selector) | ||||
|     { | ||||
|         return $this->document->getElementById($selector); | ||||
|     } | ||||
| 
 | ||||
|     public function updateElementProperties() :self | ||||
|     { | ||||
|         foreach ($this->sections as $element) { | ||||
| @ -1679,7 +1663,7 @@ class PdfBuilder | ||||
| 
 | ||||
|             if ($child['element'] !== 'script') { | ||||
|                 if ($this->service->company->markdown_enabled && array_key_exists('content', $child)) { | ||||
|                     $child['content'] = str_replace('<br>', "\r", $child['content']); | ||||
|                     $child['content'] = str_replace('<br>', "\r", ($child['content'] ?? '')); | ||||
|                     $child['content'] = $this->commonmark->convert($child['content'] ?? ''); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @ -12,6 +12,7 @@ | ||||
| namespace App\Services\Pdf; | ||||
| 
 | ||||
| use App\DataMapper\CompanySettings; | ||||
| use App\Libraries\MultiDB; | ||||
| use App\Models\Client; | ||||
| use App\Models\ClientContact; | ||||
| use App\Models\Country; | ||||
| @ -94,6 +95,8 @@ class PdfConfiguration | ||||
|      */ | ||||
|     public function init(): self | ||||
|     { | ||||
|         MultiDB::setDb($this->service->company->db); | ||||
| 
 | ||||
|         $this->setEntityType() | ||||
|              ->setDateFormat() | ||||
|              ->setPdfVariables() | ||||
| @ -271,9 +274,9 @@ class PdfConfiguration | ||||
|      */ | ||||
|     private function setDesign(): self | ||||
|     { | ||||
|         $design_id = $this->entity->design_id ? : $this->decodePrimaryKey($this->settings_object->getSetting($this->entity_design_id)); | ||||
|         $design_id = $this->entity->design_id ?: $this->decodePrimaryKey($this->settings_object->getSetting($this->entity_design_id)); | ||||
| 
 | ||||
|         $this->design = Design::withTrashed()->find($design_id ?: 2); | ||||
|         $this->design = Design::withTrashed()->find($design_id ?? 2); | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| @ -327,6 +330,125 @@ class PdfConfiguration | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     /**  | ||||
|      * Formats a given value based on the clients currency. | ||||
|      * | ||||
|      * @param  float  $value    The number to be formatted | ||||
|      * | ||||
|      * @return string           The formatted value | ||||
|      */ | ||||
|     public function formatValueNoTrailingZeroes($value) :string | ||||
|     { | ||||
|         $value = floatval($value); | ||||
| 
 | ||||
|         $thousand = $this->currency->thousand_separator; | ||||
|         $decimal = $this->currency->decimal_separator; | ||||
|          | ||||
|         /* Country settings override client settings */ | ||||
|         if (isset($this->country->thousand_separator) && strlen($this->country->thousand_separator) >= 1) { | ||||
|             $thousand = $this->country->thousand_separator; | ||||
|         } | ||||
| 
 | ||||
|         if (isset($this->country->decimal_separator) && strlen($this->country->decimal_separator) >= 1) { | ||||
|             $decimal = $this->country->decimal_separator; | ||||
|         } | ||||
| 
 | ||||
|         $precision = 10; | ||||
| 
 | ||||
|         return rtrim(rtrim(number_format($value, $precision, $decimal, $thousand), '0'), $decimal); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Formats a given value based on the clients currency AND country. | ||||
|      * | ||||
|      * @param float $value The number to be formatted | ||||
|      * @return string           The formatted value | ||||
|      */ | ||||
|     public function formatMoneyNoRounding($value) :string | ||||
|     { | ||||
|          | ||||
|         $_value = $value; | ||||
| 
 | ||||
|         $thousand = $this->currency->thousand_separator; | ||||
|         $decimal = $this->currency->decimal_separator; | ||||
|         $precision = $this->currency->precision; | ||||
|         $code = $this->currency->code; | ||||
|         $swapSymbol = $this->currency->swap_currency_symbol; | ||||
| 
 | ||||
|         /* Country settings override client settings */ | ||||
|         if (isset($this->country->thousand_separator) && strlen($this->country->thousand_separator) >= 1) { | ||||
|             $thousand = $this->country->thousand_separator; | ||||
|         } | ||||
| 
 | ||||
|         if (isset($this->country->decimal_separator) && strlen($this->country->decimal_separator) >= 1) { | ||||
|             $decimal = $this->country->decimal_separator; | ||||
|         } | ||||
| 
 | ||||
|         if (isset($this->country->swap_currency_symbol) && strlen($this->country->swap_currency_symbol) >= 1) { | ||||
|             $swapSymbol = $this->country->swap_currency_symbol; | ||||
|         } | ||||
| 
 | ||||
|         /* 08-01-2022 allow increased precision for unit price*/ | ||||
|         $v = rtrim(sprintf('%f', $value), '0'); | ||||
|         $parts = explode('.', $v); | ||||
| 
 | ||||
|         /* 08-02-2023 special if block to render $0.5 to $0.50*/ | ||||
|         if ($v < 1 && strlen($v) == 3) { | ||||
|             $precision = 2; | ||||
|         } elseif ($v < 1) { | ||||
|             $precision = strlen($v) - strrpos($v, '.') - 1; | ||||
|         } | ||||
|          | ||||
|         if (is_array($parts) && $parts[0] != 0) { | ||||
|             $precision = 2; | ||||
|         } | ||||
| 
 | ||||
|         //04-04-2023 if currency = JPY override precision to 0
 | ||||
|         if($this->currency->code == 'JPY') { | ||||
|             $precision = 0; | ||||
|         } | ||||
| 
 | ||||
|         $value = number_format($v, $precision, $decimal, $thousand); | ||||
|         $symbol = $this->currency->symbol; | ||||
| 
 | ||||
|         if ($this->settings->show_currency_code === true && $this->currency->code == 'CHF') { | ||||
|             return "{$code} {$value}"; | ||||
|         } elseif ($this->settings->show_currency_code === true) { | ||||
|             return "{$value} {$code}"; | ||||
|         } elseif ($swapSymbol) { | ||||
|             return "{$value} ".trim($symbol); | ||||
|         } elseif ($this->settings->show_currency_code === false) { | ||||
|             if ($_value < 0) { | ||||
|                 $value = substr($value, 1); | ||||
|                 $symbol = "-{$symbol}"; | ||||
|             } | ||||
| 
 | ||||
|             return "{$symbol}{$value}"; | ||||
|         } else { | ||||
|             return $this->formatValue($value); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Formats a given value based on the clients currency. | ||||
|      * | ||||
|      * @param  float  $value    The number to be formatted | ||||
|      * | ||||
|      * @return string           The formatted value | ||||
|      */ | ||||
|     public function formatValue($value) :string | ||||
|     { | ||||
|         $value = floatval($value); | ||||
| 
 | ||||
|         $thousand = $this->currency->thousand_separator; | ||||
|         $decimal = $this->currency->decimal_separator; | ||||
|         $precision = $this->currency->precision; | ||||
| 
 | ||||
|         return number_format($value, $precision, $decimal, $thousand); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * date_format | ||||
|      * | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										204
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										204
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							| @ -485,16 +485,16 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "aws/aws-sdk-php", | ||||
|             "version": "3.285.3", | ||||
|             "version": "3.285.4", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/aws/aws-sdk-php.git", | ||||
|                 "reference": "afa1e722f1b2c95644f375dc1a19072e4daf67be" | ||||
|                 "reference": "c462af819d81cba49939949032b20799f5ef0fff" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/afa1e722f1b2c95644f375dc1a19072e4daf67be", | ||||
|                 "reference": "afa1e722f1b2c95644f375dc1a19072e4daf67be", | ||||
|                 "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/c462af819d81cba49939949032b20799f5ef0fff", | ||||
|                 "reference": "c462af819d81cba49939949032b20799f5ef0fff", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -574,9 +574,9 @@ | ||||
|             "support": { | ||||
|                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", | ||||
|                 "issues": "https://github.com/aws/aws-sdk-php/issues", | ||||
|                 "source": "https://github.com/aws/aws-sdk-php/tree/3.285.3" | ||||
|                 "source": "https://github.com/aws/aws-sdk-php/tree/3.285.4" | ||||
|             }, | ||||
|             "time": "2023-11-09T19:07:19+00:00" | ||||
|             "time": "2023-11-10T19:25:49+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "bacon/bacon-qr-code", | ||||
| @ -790,16 +790,16 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "checkout/checkout-sdk-php", | ||||
|             "version": "3.0.17", | ||||
|             "version": "3.0.18", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/checkout/checkout-sdk-php.git", | ||||
|                 "reference": "dabb6dd37ad80aaa9c34e60f48f9bf8b651bdc27" | ||||
|                 "reference": "9e606ac8ad5371cfb571050e7ea2c0c05b2b3070" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/checkout/checkout-sdk-php/zipball/dabb6dd37ad80aaa9c34e60f48f9bf8b651bdc27", | ||||
|                 "reference": "dabb6dd37ad80aaa9c34e60f48f9bf8b651bdc27", | ||||
|                 "url": "https://api.github.com/repos/checkout/checkout-sdk-php/zipball/9e606ac8ad5371cfb571050e7ea2c0c05b2b3070", | ||||
|                 "reference": "9e606ac8ad5371cfb571050e7ea2c0c05b2b3070", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -852,9 +852,9 @@ | ||||
|             ], | ||||
|             "support": { | ||||
|                 "issues": "https://github.com/checkout/checkout-sdk-php/issues", | ||||
|                 "source": "https://github.com/checkout/checkout-sdk-php/tree/3.0.17" | ||||
|                 "source": "https://github.com/checkout/checkout-sdk-php/tree/3.0.18" | ||||
|             }, | ||||
|             "time": "2023-10-20T22:35:30+00:00" | ||||
|             "time": "2023-11-10T09:12:20+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "cleverit/ubl_invoice", | ||||
| @ -2487,16 +2487,16 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "google/apiclient-services", | ||||
|             "version": "v0.323.0", | ||||
|             "version": "v0.324.0", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/googleapis/google-api-php-client-services.git", | ||||
|                 "reference": "d5497d30ddfafe7592102ca48bedaf222a4ca7a6" | ||||
|                 "reference": "585cc823c3d59788e4a0829d5b7e41c76950d801" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/d5497d30ddfafe7592102ca48bedaf222a4ca7a6", | ||||
|                 "reference": "d5497d30ddfafe7592102ca48bedaf222a4ca7a6", | ||||
|                 "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/585cc823c3d59788e4a0829d5b7e41c76950d801", | ||||
|                 "reference": "585cc823c3d59788e4a0829d5b7e41c76950d801", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -2525,9 +2525,9 @@ | ||||
|             ], | ||||
|             "support": { | ||||
|                 "issues": "https://github.com/googleapis/google-api-php-client-services/issues", | ||||
|                 "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.323.0" | ||||
|                 "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.324.0" | ||||
|             }, | ||||
|             "time": "2023-11-06T01:08:38+00:00" | ||||
|             "time": "2023-11-13T01:06:14+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "google/auth", | ||||
| @ -2589,24 +2589,24 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "graham-campbell/result-type", | ||||
|             "version": "v1.1.1", | ||||
|             "version": "v1.1.2", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/GrahamCampbell/Result-Type.git", | ||||
|                 "reference": "672eff8cf1d6fe1ef09ca0f89c4b287d6a3eb831" | ||||
|                 "reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/672eff8cf1d6fe1ef09ca0f89c4b287d6a3eb831", | ||||
|                 "reference": "672eff8cf1d6fe1ef09ca0f89c4b287d6a3eb831", | ||||
|                 "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/fbd48bce38f73f8a4ec8583362e732e4095e5862", | ||||
|                 "reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
|                 "php": "^7.2.5 || ^8.0", | ||||
|                 "phpoption/phpoption": "^1.9.1" | ||||
|                 "phpoption/phpoption": "^1.9.2" | ||||
|             }, | ||||
|             "require-dev": { | ||||
|                 "phpunit/phpunit": "^8.5.32 || ^9.6.3 || ^10.0.12" | ||||
|                 "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" | ||||
|             }, | ||||
|             "type": "library", | ||||
|             "autoload": { | ||||
| @ -2635,7 +2635,7 @@ | ||||
|             ], | ||||
|             "support": { | ||||
|                 "issues": "https://github.com/GrahamCampbell/Result-Type/issues", | ||||
|                 "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.1" | ||||
|                 "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.2" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -2647,7 +2647,7 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-02-25T20:23:15+00:00" | ||||
|             "time": "2023-11-12T22:16:48+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "graylog2/gelf-php", | ||||
| @ -7832,16 +7832,16 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "phpoption/phpoption", | ||||
|             "version": "1.9.1", | ||||
|             "version": "1.9.2", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/schmittjoh/php-option.git", | ||||
|                 "reference": "dd3a383e599f49777d8b628dadbb90cae435b87e" | ||||
|                 "reference": "80735db690fe4fc5c76dfa7f9b770634285fa820" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/dd3a383e599f49777d8b628dadbb90cae435b87e", | ||||
|                 "reference": "dd3a383e599f49777d8b628dadbb90cae435b87e", | ||||
|                 "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/80735db690fe4fc5c76dfa7f9b770634285fa820", | ||||
|                 "reference": "80735db690fe4fc5c76dfa7f9b770634285fa820", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -7849,7 +7849,7 @@ | ||||
|             }, | ||||
|             "require-dev": { | ||||
|                 "bamarni/composer-bin-plugin": "^1.8.2", | ||||
|                 "phpunit/phpunit": "^8.5.32 || ^9.6.3 || ^10.0.12" | ||||
|                 "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" | ||||
|             }, | ||||
|             "type": "library", | ||||
|             "extra": { | ||||
| @ -7891,7 +7891,7 @@ | ||||
|             ], | ||||
|             "support": { | ||||
|                 "issues": "https://github.com/schmittjoh/php-option/issues", | ||||
|                 "source": "https://github.com/schmittjoh/php-option/tree/1.9.1" | ||||
|                 "source": "https://github.com/schmittjoh/php-option/tree/1.9.2" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -7903,7 +7903,7 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-02-25T19:38:58+00:00" | ||||
|             "time": "2023-11-12T21:59:55+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "phpseclib/phpseclib", | ||||
| @ -10288,16 +10288,16 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/console", | ||||
|             "version": "v6.3.4", | ||||
|             "version": "v6.3.8", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/symfony/console.git", | ||||
|                 "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6" | ||||
|                 "reference": "0d14a9f6d04d4ac38a8cea1171f4554e325dae92" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/symfony/console/zipball/eca495f2ee845130855ddf1cf18460c38966c8b6", | ||||
|                 "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6", | ||||
|                 "url": "https://api.github.com/repos/symfony/console/zipball/0d14a9f6d04d4ac38a8cea1171f4554e325dae92", | ||||
|                 "reference": "0d14a9f6d04d4ac38a8cea1171f4554e325dae92", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -10358,7 +10358,7 @@ | ||||
|                 "terminal" | ||||
|             ], | ||||
|             "support": { | ||||
|                 "source": "https://github.com/symfony/console/tree/v6.3.4" | ||||
|                 "source": "https://github.com/symfony/console/tree/v6.3.8" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -10374,7 +10374,7 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-08-16T10:10:12+00:00" | ||||
|             "time": "2023-10-31T08:09:35+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/css-selector", | ||||
| @ -10867,16 +10867,16 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/http-client", | ||||
|             "version": "v6.3.7", | ||||
|             "version": "v6.3.8", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/symfony/http-client.git", | ||||
|                 "reference": "cd67fcaf4524ec6ae5d9b2d9497682d7ad3ce57d" | ||||
|                 "reference": "0314e2d49939a9831929d6fc81c01c6df137fd0a" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/symfony/http-client/zipball/cd67fcaf4524ec6ae5d9b2d9497682d7ad3ce57d", | ||||
|                 "reference": "cd67fcaf4524ec6ae5d9b2d9497682d7ad3ce57d", | ||||
|                 "url": "https://api.github.com/repos/symfony/http-client/zipball/0314e2d49939a9831929d6fc81c01c6df137fd0a", | ||||
|                 "reference": "0314e2d49939a9831929d6fc81c01c6df137fd0a", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -10939,7 +10939,7 @@ | ||||
|                 "http" | ||||
|             ], | ||||
|             "support": { | ||||
|                 "source": "https://github.com/symfony/http-client/tree/v6.3.7" | ||||
|                 "source": "https://github.com/symfony/http-client/tree/v6.3.8" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -10955,7 +10955,7 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-10-29T12:41:36+00:00" | ||||
|             "time": "2023-11-06T18:31:59+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/http-client-contracts", | ||||
| @ -11037,16 +11037,16 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/http-foundation", | ||||
|             "version": "v6.3.7", | ||||
|             "version": "v6.3.8", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/symfony/http-foundation.git", | ||||
|                 "reference": "59d1837d5d992d16c2628cd0d6b76acf8d69b33e" | ||||
|                 "reference": "ce332676de1912c4389222987193c3ef38033df6" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/symfony/http-foundation/zipball/59d1837d5d992d16c2628cd0d6b76acf8d69b33e", | ||||
|                 "reference": "59d1837d5d992d16c2628cd0d6b76acf8d69b33e", | ||||
|                 "url": "https://api.github.com/repos/symfony/http-foundation/zipball/ce332676de1912c4389222987193c3ef38033df6", | ||||
|                 "reference": "ce332676de1912c4389222987193c3ef38033df6", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -11094,7 +11094,7 @@ | ||||
|             "description": "Defines an object-oriented layer for the HTTP specification", | ||||
|             "homepage": "https://symfony.com", | ||||
|             "support": { | ||||
|                 "source": "https://github.com/symfony/http-foundation/tree/v6.3.7" | ||||
|                 "source": "https://github.com/symfony/http-foundation/tree/v6.3.8" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -11110,20 +11110,20 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-10-28T23:55:27+00:00" | ||||
|             "time": "2023-11-07T10:17:15+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/http-kernel", | ||||
|             "version": "v6.3.7", | ||||
|             "version": "v6.3.8", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/symfony/http-kernel.git", | ||||
|                 "reference": "6d4098095f93279d9536a0e9124439560cc764d0" | ||||
|                 "reference": "929202375ccf44a309c34aeca8305408442ebcc1" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/symfony/http-kernel/zipball/6d4098095f93279d9536a0e9124439560cc764d0", | ||||
|                 "reference": "6d4098095f93279d9536a0e9124439560cc764d0", | ||||
|                 "url": "https://api.github.com/repos/symfony/http-kernel/zipball/929202375ccf44a309c34aeca8305408442ebcc1", | ||||
|                 "reference": "929202375ccf44a309c34aeca8305408442ebcc1", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -11207,7 +11207,7 @@ | ||||
|             "description": "Provides a structured process for converting a Request into a Response", | ||||
|             "homepage": "https://symfony.com", | ||||
|             "support": { | ||||
|                 "source": "https://github.com/symfony/http-kernel/tree/v6.3.7" | ||||
|                 "source": "https://github.com/symfony/http-kernel/tree/v6.3.8" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -11223,7 +11223,7 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-10-29T14:31:45+00:00" | ||||
|             "time": "2023-11-10T13:47:32+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/intl", | ||||
| @ -12819,16 +12819,16 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/string", | ||||
|             "version": "v6.3.5", | ||||
|             "version": "v6.3.8", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/symfony/string.git", | ||||
|                 "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339" | ||||
|                 "reference": "13880a87790c76ef994c91e87efb96134522577a" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339", | ||||
|                 "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339", | ||||
|                 "url": "https://api.github.com/repos/symfony/string/zipball/13880a87790c76ef994c91e87efb96134522577a", | ||||
|                 "reference": "13880a87790c76ef994c91e87efb96134522577a", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -12885,7 +12885,7 @@ | ||||
|                 "utf8" | ||||
|             ], | ||||
|             "support": { | ||||
|                 "source": "https://github.com/symfony/string/tree/v6.3.5" | ||||
|                 "source": "https://github.com/symfony/string/tree/v6.3.8" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -12901,7 +12901,7 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-09-18T10:38:32+00:00" | ||||
|             "time": "2023-11-09T08:28:21+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/translation", | ||||
| @ -13078,16 +13078,16 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/uid", | ||||
|             "version": "v6.3.0", | ||||
|             "version": "v6.3.8", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/symfony/uid.git", | ||||
|                 "reference": "01b0f20b1351d997711c56f1638f7a8c3061e384" | ||||
|                 "reference": "819fa5ac210fb7ddda4752b91a82f50be7493dd9" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/symfony/uid/zipball/01b0f20b1351d997711c56f1638f7a8c3061e384", | ||||
|                 "reference": "01b0f20b1351d997711c56f1638f7a8c3061e384", | ||||
|                 "url": "https://api.github.com/repos/symfony/uid/zipball/819fa5ac210fb7ddda4752b91a82f50be7493dd9", | ||||
|                 "reference": "819fa5ac210fb7ddda4752b91a82f50be7493dd9", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -13132,7 +13132,7 @@ | ||||
|                 "uuid" | ||||
|             ], | ||||
|             "support": { | ||||
|                 "source": "https://github.com/symfony/uid/tree/v6.3.0" | ||||
|                 "source": "https://github.com/symfony/uid/tree/v6.3.8" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -13148,20 +13148,20 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-04-08T07:25:02+00:00" | ||||
|             "time": "2023-10-31T08:07:48+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/validator", | ||||
|             "version": "v6.3.7", | ||||
|             "version": "v6.3.8", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/symfony/validator.git", | ||||
|                 "reference": "9cc736663fa5839b9710ac2c303bb0b951014fc1" | ||||
|                 "reference": "f75b40e088d095db1e788b81605a76f4563cb80e" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/symfony/validator/zipball/9cc736663fa5839b9710ac2c303bb0b951014fc1", | ||||
|                 "reference": "9cc736663fa5839b9710ac2c303bb0b951014fc1", | ||||
|                 "url": "https://api.github.com/repos/symfony/validator/zipball/f75b40e088d095db1e788b81605a76f4563cb80e", | ||||
|                 "reference": "f75b40e088d095db1e788b81605a76f4563cb80e", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -13228,7 +13228,7 @@ | ||||
|             "description": "Provides tools to validate values", | ||||
|             "homepage": "https://symfony.com", | ||||
|             "support": { | ||||
|                 "source": "https://github.com/symfony/validator/tree/v6.3.7" | ||||
|                 "source": "https://github.com/symfony/validator/tree/v6.3.8" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -13244,20 +13244,20 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-10-28T23:11:45+00:00" | ||||
|             "time": "2023-11-07T10:17:15+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/var-dumper", | ||||
|             "version": "v6.3.6", | ||||
|             "version": "v6.3.8", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/symfony/var-dumper.git", | ||||
|                 "reference": "999ede244507c32b8e43aebaa10e9fce20de7c97" | ||||
|                 "reference": "81acabba9046550e89634876ca64bfcd3c06aa0a" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/symfony/var-dumper/zipball/999ede244507c32b8e43aebaa10e9fce20de7c97", | ||||
|                 "reference": "999ede244507c32b8e43aebaa10e9fce20de7c97", | ||||
|                 "url": "https://api.github.com/repos/symfony/var-dumper/zipball/81acabba9046550e89634876ca64bfcd3c06aa0a", | ||||
|                 "reference": "81acabba9046550e89634876ca64bfcd3c06aa0a", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -13312,7 +13312,7 @@ | ||||
|                 "dump" | ||||
|             ], | ||||
|             "support": { | ||||
|                 "source": "https://github.com/symfony/var-dumper/tree/v6.3.6" | ||||
|                 "source": "https://github.com/symfony/var-dumper/tree/v6.3.8" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -13328,20 +13328,20 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-10-12T18:45:56+00:00" | ||||
|             "time": "2023-11-08T10:42:36+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "symfony/yaml", | ||||
|             "version": "v6.3.7", | ||||
|             "version": "v6.3.8", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/symfony/yaml.git", | ||||
|                 "reference": "9758b6c69d179936435d0ffb577c3708d57e38a8" | ||||
|                 "reference": "3493af8a8dad7fa91c77fa473ba23ecd95334a92" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/symfony/yaml/zipball/9758b6c69d179936435d0ffb577c3708d57e38a8", | ||||
|                 "reference": "9758b6c69d179936435d0ffb577c3708d57e38a8", | ||||
|                 "url": "https://api.github.com/repos/symfony/yaml/zipball/3493af8a8dad7fa91c77fa473ba23ecd95334a92", | ||||
|                 "reference": "3493af8a8dad7fa91c77fa473ba23ecd95334a92", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -13384,7 +13384,7 @@ | ||||
|             "description": "Loads and dumps YAML files", | ||||
|             "homepage": "https://symfony.com", | ||||
|             "support": { | ||||
|                 "source": "https://github.com/symfony/yaml/tree/v6.3.7" | ||||
|                 "source": "https://github.com/symfony/yaml/tree/v6.3.8" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -13400,7 +13400,7 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2023-10-28T23:31:00+00:00" | ||||
|             "time": "2023-11-06T10:58:05+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "tijsverkoyen/css-to-inline-styles", | ||||
| @ -13703,31 +13703,31 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "vlucas/phpdotenv", | ||||
|             "version": "v5.5.0", | ||||
|             "version": "v5.6.0", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/vlucas/phpdotenv.git", | ||||
|                 "reference": "1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7" | ||||
|                 "reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7", | ||||
|                 "reference": "1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7", | ||||
|                 "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4", | ||||
|                 "reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
|                 "ext-pcre": "*", | ||||
|                 "graham-campbell/result-type": "^1.0.2", | ||||
|                 "php": "^7.1.3 || ^8.0", | ||||
|                 "phpoption/phpoption": "^1.8", | ||||
|                 "symfony/polyfill-ctype": "^1.23", | ||||
|                 "symfony/polyfill-mbstring": "^1.23.1", | ||||
|                 "symfony/polyfill-php80": "^1.23.1" | ||||
|                 "graham-campbell/result-type": "^1.1.2", | ||||
|                 "php": "^7.2.5 || ^8.0", | ||||
|                 "phpoption/phpoption": "^1.9.2", | ||||
|                 "symfony/polyfill-ctype": "^1.24", | ||||
|                 "symfony/polyfill-mbstring": "^1.24", | ||||
|                 "symfony/polyfill-php80": "^1.24" | ||||
|             }, | ||||
|             "require-dev": { | ||||
|                 "bamarni/composer-bin-plugin": "^1.4.1", | ||||
|                 "bamarni/composer-bin-plugin": "^1.8.2", | ||||
|                 "ext-filter": "*", | ||||
|                 "phpunit/phpunit": "^7.5.20 || ^8.5.30 || ^9.5.25" | ||||
|                 "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" | ||||
|             }, | ||||
|             "suggest": { | ||||
|                 "ext-filter": "Required to use the boolean validator." | ||||
| @ -13739,7 +13739,7 @@ | ||||
|                     "forward-command": true | ||||
|                 }, | ||||
|                 "branch-alias": { | ||||
|                     "dev-master": "5.5-dev" | ||||
|                     "dev-master": "5.6-dev" | ||||
|                 } | ||||
|             }, | ||||
|             "autoload": { | ||||
| @ -13771,7 +13771,7 @@ | ||||
|             ], | ||||
|             "support": { | ||||
|                 "issues": "https://github.com/vlucas/phpdotenv/issues", | ||||
|                 "source": "https://github.com/vlucas/phpdotenv/tree/v5.5.0" | ||||
|                 "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.0" | ||||
|             }, | ||||
|             "funding": [ | ||||
|                 { | ||||
| @ -13783,7 +13783,7 @@ | ||||
|                     "type": "tidelift" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2022-10-16T01:01:54+00:00" | ||||
|             "time": "2023-11-12T22:43:29+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "voku/portable-ascii", | ||||
|  | ||||
| @ -15,8 +15,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.47'), | ||||
|     'app_tag' => env('APP_TAG','5.7.47'), | ||||
|     'app_version' => env('APP_VERSION','5.7.48'), | ||||
|     'app_tag' => env('APP_TAG','5.7.48'), | ||||
|     'minimum_client_version' => '5.0.16', | ||||
|     'terms_version' => '1.0.1', | ||||
|     'api_secret' => env('API_SECRET', false), | ||||
|  | ||||
| @ -125,12 +125,12 @@ Route::group(['middleware' => ['invite_db'], 'prefix' => 'client', 'as' => 'clie | ||||
|     Route::get('invoice/{invitation_key}', [App\Http\Controllers\ClientPortal\InvitationController::class, 'invoiceRouter']); | ||||
|     Route::get('quote/{invitation_key}', [App\Http\Controllers\ClientPortal\InvitationController::class, 'quoteRouter']); | ||||
|     Route::get('credit/{invitation_key}', [App\Http\Controllers\ClientPortal\InvitationController::class, 'creditRouter']); | ||||
|     Route::get('recurring_invoice/{invitation_key}/download_pdf', [RecurringInvoiceController::class, 'downloadPdf'])->name('recurring_invoice.download_invitation_key');//->middleware('token_auth');
 | ||||
|     Route::get('invoice/{invitation_key}/download_pdf', [InvoiceController::class, 'downloadPdf'])->name('invoice.download_invitation_key');//->middleware('token_auth');
 | ||||
|     Route::get('invoice/{invitation_key}/download_e_invoice', [InvoiceController::class, 'downloadEInvoice'])->name('invoice.download_e_invoice');//->middleware('token_auth');
 | ||||
|     Route::get('quote/{invitation_key}/download_pdf', [QuoteController::class, 'downloadPdf'])->name('quote.download_invitation_key');//->middleware('token_auth');
 | ||||
|     Route::get('credit/{invitation_key}/download_pdf', [CreditController::class, 'downloadPdf'])->name('credit.download_invitation_key');//->middleware('token_auth');
 | ||||
|     Route::get('{entity}/{invitation_key}/download', [App\Http\Controllers\ClientPortal\InvitationController::class, 'routerForDownload']);//->middleware('token_auth');
 | ||||
|     Route::get('recurring_invoice/{invitation_key}/download_pdf', [RecurringInvoiceController::class, 'downloadPdf'])->name('recurring_invoice.download_invitation_key')->middleware('token_auth'); | ||||
|     Route::get('invoice/{invitation_key}/download_pdf', [InvoiceController::class, 'downloadPdf'])->name('invoice.download_invitation_key')->middleware('token_auth'); | ||||
|     Route::get('invoice/{invitation_key}/download_e_invoice', [InvoiceController::class, 'downloadEInvoice'])->name('invoice.download_e_invoice')->middleware('token_auth'); | ||||
|     Route::get('quote/{invitation_key}/download_pdf', [QuoteController::class, 'downloadPdf'])->name('quote.download_invitation_key')->middleware('token_auth'); | ||||
|     Route::get('credit/{invitation_key}/download_pdf', [CreditController::class, 'downloadPdf'])->name('credit.download_invitation_key')->middleware('token_auth'); | ||||
|     Route::get('{entity}/{invitation_key}/download', [App\Http\Controllers\ClientPortal\InvitationController::class, 'routerForDownload'])->middleware('token_auth'); | ||||
|     Route::get('pay/{invitation_key}', [App\Http\Controllers\ClientPortal\InvitationController::class, 'payInvoice'])->name('pay.invoice'); | ||||
| 
 | ||||
|     Route::get('unsubscribe/{entity}/{invitation_key}', [App\Http\Controllers\ClientPortal\InvitationController::class, 'unsubscribe'])->name('unsubscribe'); | ||||
|  | ||||
| @ -47,7 +47,7 @@ class FacturaeTest extends TestCase | ||||
| 
 | ||||
|         $this->assertNotNull($f->run()); | ||||
|          | ||||
|         nlog($f->run()); | ||||
|         // nlog($f->run());
 | ||||
| 
 | ||||
|         // $this->assertTrue($this->validateInvoiceXML($path));
 | ||||
|     } | ||||
|  | ||||
| @ -104,6 +104,90 @@ class TaskApiTest extends TestCase | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public function testEmptyTimeLogArray() | ||||
|     { | ||||
|          | ||||
|         $data = [ | ||||
|             'client_id' => $this->client->id, | ||||
|             'user_id' => $this->user->id, | ||||
|             'company_id' => $this->company->id, | ||||
|             'description' => 'Test Task', | ||||
|             'time_log' => null, | ||||
|         ]; | ||||
| 
 | ||||
|         $response = $this->withHeaders([ | ||||
|             'X-API-SECRET' => config('ninja.api_secret'), | ||||
|             'X-API-TOKEN' => $this->token, | ||||
|         ])->postJson("/api/v1/tasks", $data); | ||||
| 
 | ||||
|         $response->assertStatus(200); | ||||
| 
 | ||||
|         $data = [ | ||||
|             'client_id' => $this->client->id, | ||||
|             'user_id' => $this->user->id, | ||||
|             'company_id' => $this->company->id, | ||||
|             'description' => 'Test Task', | ||||
|             'time_log' => '', | ||||
|         ]; | ||||
| 
 | ||||
|         $response = $this->withHeaders([ | ||||
|             'X-API-SECRET' => config('ninja.api_secret'), | ||||
|             'X-API-TOKEN' => $this->token, | ||||
|         ])->postJson("/api/v1/tasks", $data); | ||||
| 
 | ||||
|         $response->assertStatus(200); | ||||
| 
 | ||||
|         $data = [ | ||||
|            'client_id' => $this->client->id, | ||||
|            'user_id' => $this->user->id, | ||||
|            'company_id' => $this->company->id, | ||||
|            'description' => 'Test Task', | ||||
|            'time_log' => '[]', | ||||
|        ]; | ||||
| 
 | ||||
|         $response = $this->withHeaders([ | ||||
|             'X-API-SECRET' => config('ninja.api_secret'), | ||||
|             'X-API-TOKEN' => $this->token, | ||||
|         ])->postJson("/api/v1/tasks", $data); | ||||
| 
 | ||||
|         $response->assertStatus(200); | ||||
| 
 | ||||
|         $data = [ | ||||
|             'client_id' => $this->client->id, | ||||
|             'user_id' => $this->user->id, | ||||
|             'company_id' => $this->company->id, | ||||
|             'description' => 'Test Task', | ||||
|             'time_log' => '{}', | ||||
|         ]; | ||||
| 
 | ||||
|         $response = $this->withHeaders([ | ||||
|             'X-API-SECRET' => config('ninja.api_secret'), | ||||
|             'X-API-TOKEN' => $this->token, | ||||
|         ])->postJson("/api/v1/tasks", $data); | ||||
| 
 | ||||
|         $response->assertStatus(200); | ||||
|     } | ||||
| 
 | ||||
|     public function testFaultyTimeLogArray() | ||||
|     { | ||||
|          | ||||
|         $data = [ | ||||
|             'client_id' => $this->client->id, | ||||
|             'user_id' => $this->user->id, | ||||
|             'company_id' => $this->company->id, | ||||
|             'description' => 'Test Task', | ||||
|             'time_log' => 'ABBA is the best band in the world', | ||||
|         ]; | ||||
| 
 | ||||
|         $response = $this->withHeaders([ | ||||
|             'X-API-SECRET' => config('ninja.api_secret'), | ||||
|             'X-API-TOKEN' => $this->token, | ||||
|         ])->postJson("/api/v1/tasks", $data); | ||||
| 
 | ||||
|         $response->assertStatus(422); | ||||
|      | ||||
|     } | ||||
| 
 | ||||
|     public function testTaskClientRateSet() | ||||
|     { | ||||
|         $settings = ClientSettings::defaults(); | ||||
| @ -282,6 +366,45 @@ class TaskApiTest extends TestCase | ||||
| 
 | ||||
|         $response->assertStatus(200); | ||||
| 
 | ||||
|         $task->time_log = 'A very strange place'; | ||||
| 
 | ||||
|         $response = $this->withHeaders([ | ||||
|             'X-API-SECRET' => config('ninja.api_secret'), | ||||
|             'X-API-TOKEN' => $this->token, | ||||
|         ])->putJson("/api/v1/tasks/{$task->hashed_id}?stop=true", $task->toArray()); | ||||
| 
 | ||||
|         $response->assertStatus(422); | ||||
| 
 | ||||
|         $task->time_log = null; | ||||
| 
 | ||||
|         $response = $this->withHeaders([ | ||||
|             'X-API-SECRET' => config('ninja.api_secret'), | ||||
|             'X-API-TOKEN' => $this->token, | ||||
|         ])->putJson("/api/v1/tasks/{$task->hashed_id}?stop=true", $task->toArray()); | ||||
| 
 | ||||
|         $response->assertStatus(200); | ||||
| 
 | ||||
|         $task->time_log = ''; | ||||
| 
 | ||||
|         $response = $this->withHeaders([ | ||||
|             'X-API-SECRET' => config('ninja.api_secret'), | ||||
|             'X-API-TOKEN' => $this->token, | ||||
|         ])->putJson("/api/v1/tasks/{$task->hashed_id}?stop=true", $task->toArray()); | ||||
| 
 | ||||
|         $response->assertStatus(200); | ||||
| 
 | ||||
| 
 | ||||
|         $task->time_log = '{}'; | ||||
| 
 | ||||
|         $response = $this->withHeaders([ | ||||
|             'X-API-SECRET' => config('ninja.api_secret'), | ||||
|             'X-API-TOKEN' => $this->token, | ||||
|         ])->putJson("/api/v1/tasks/{$task->hashed_id}?stop=true", $task->toArray()); | ||||
| 
 | ||||
|         $response->assertStatus(200); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public function testStoppingTaskWithDescription() | ||||
|  | ||||
| @ -18,12 +18,14 @@ use App\Models\Credit; | ||||
| use App\Models\Design; | ||||
| use App\Models\Invoice; | ||||
| use App\Models\Payment; | ||||
| use App\Models\Project; | ||||
| use App\Utils\HtmlEngine; | ||||
| use Tests\MockAccountData; | ||||
| use App\Utils\Traits\MakesDates; | ||||
| use App\Jobs\Entity\CreateRawPdf; | ||||
| use App\Services\PdfMaker\PdfMaker; | ||||
| use Illuminate\Support\Facades\App; | ||||
| use App\Services\Template\TemplateMock; | ||||
| use App\Services\Template\TemplateService; | ||||
| use App\Services\PdfMaker\Design as PdfDesignModel; | ||||
| use App\Services\PdfMaker\Design as PdfMakerDesign; | ||||
| @ -165,6 +167,8 @@ class TemplateTest extends TestCase | ||||
|             </ninja> | ||||
|         '; | ||||
| 
 | ||||
|     private string $stack = '<html><div id="company-details" labels="true"></div></html>'; | ||||
| 
 | ||||
|     protected function setUp() :void | ||||
|     { | ||||
|         parent::setUp(); | ||||
| @ -177,6 +181,136 @@ class TemplateTest extends TestCase | ||||
|          | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     public function testPurchaseOrderDataParse() | ||||
|     { | ||||
|         $data = []; | ||||
|          | ||||
|         $p = \App\Models\PurchaseOrder::factory()->create([ | ||||
|             'user_id' => $this->user->id, | ||||
|             'company_id' => $this->company->id, | ||||
|             'vendor_id' => $this->vendor->id, | ||||
|         ]); | ||||
| 
 | ||||
|         $data['purchase_orders'][] = $p; | ||||
| 
 | ||||
|         $ts = new TemplateService(); | ||||
|         $ts->processData($data); | ||||
| 
 | ||||
|         $this->assertNotNull($ts); | ||||
|         $this->assertIsArray($ts->getData()); | ||||
|     } | ||||
| 
 | ||||
|     public function testTaskDataParse() | ||||
|     { | ||||
|         $data = []; | ||||
|          | ||||
|         $p = \App\Models\Task::factory()->create([ | ||||
|             'user_id' => $this->user->id, | ||||
|             'company_id' => $this->company->id, | ||||
|             'client_id' => $this->client->id, | ||||
|         ]); | ||||
| 
 | ||||
|         $data['tasks'][] = $p; | ||||
| 
 | ||||
|         $ts = new TemplateService(); | ||||
|         $ts->processData($data); | ||||
| 
 | ||||
|         $this->assertNotNull($ts); | ||||
|         $this->assertIsArray($ts->getData()); | ||||
|     } | ||||
| 
 | ||||
|     public function testQuoteDataParse() | ||||
|     { | ||||
|         $data = []; | ||||
|          | ||||
|         $p = \App\Models\Quote::factory()->create([ | ||||
|             'user_id' => $this->user->id, | ||||
|             'company_id' => $this->company->id, | ||||
|             'client_id' => $this->client->id, | ||||
|         ]); | ||||
| 
 | ||||
|         $data['quotes'][] = $p; | ||||
| 
 | ||||
|         $ts = new TemplateService(); | ||||
|         $ts->processData($data); | ||||
| 
 | ||||
|         $this->assertNotNull($ts); | ||||
|         $this->assertIsArray($ts->getData()); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public function testProjectDataParse() | ||||
|     { | ||||
|         $data = []; | ||||
|          | ||||
|         $p = Project::factory()->create([ | ||||
|             'user_id' => $this->user->id, | ||||
|             'company_id' => $this->company->id, | ||||
|             'client_id' => $this->client->id, | ||||
|         ]); | ||||
| 
 | ||||
|         $data['projects'][] = $p; | ||||
| 
 | ||||
|         $ts = new TemplateService(); | ||||
|         $ts->processData($data); | ||||
| 
 | ||||
|         $this->assertNotNull($ts); | ||||
|         $this->assertIsArray($ts->getData()); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public function testNegativeDivAttribute() | ||||
|     { | ||||
|        $dom = new \DOMDocument(); | ||||
|         @$dom->loadHTML(mb_convert_encoding($this->stack, 'HTML-ENTITIES', 'UTF-8')); | ||||
| 
 | ||||
|         $node = $dom->getElementById('company-details'); | ||||
|         $x = $node->getAttribute('nonexistentattribute'); | ||||
| 
 | ||||
|         $this->assertEquals('', $x); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public function testStackResolutionWithLabels() | ||||
|     { | ||||
| 
 | ||||
|         $dom = new \DOMDocument(); | ||||
|         @$dom->loadHTML(mb_convert_encoding($this->stack, 'HTML-ENTITIES', 'UTF-8')); | ||||
| 
 | ||||
|         $node = $dom->getElementById('company-details'); | ||||
|         $x = $node->getAttribute('labels'); | ||||
| 
 | ||||
|         $this->assertEquals('true', $x); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     public function testStackResolution() | ||||
|     { | ||||
| 
 | ||||
|         $partials['design']['includes'] = ''; | ||||
|         $partials['design']['header'] = ''; | ||||
|         $partials['design']['body'] = $this->stack; | ||||
|         $partials['design']['footer'] = ''; | ||||
| 
 | ||||
|         $tm = new TemplateMock($this->company); | ||||
|         $tm->init(); | ||||
| 
 | ||||
|         $variables = $tm->variables[0]; | ||||
|          | ||||
|         $ts = new TemplateService(); | ||||
|         $x = $ts->setTemplate($partials) | ||||
|             ->setCompany($this->company) | ||||
|             ->overrideVariables($variables) | ||||
|             ->parseGlobalStacks() | ||||
|             ->parseVariables() | ||||
|             ->getHtml(); | ||||
| 
 | ||||
|         $this->assertIsString($x); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public function testDataMaps() | ||||
|     { | ||||
|         $start = microtime(true); | ||||
| @ -319,19 +453,8 @@ class TemplateTest extends TestCase | ||||
|             ]; | ||||
|         }); | ||||
| 
 | ||||
|         $queries = \DB::getQueryLog(); | ||||
|         $count = count($queries); | ||||
| 
 | ||||
|         nlog("query count = {$count}"); | ||||
|         $x = $invoices->toArray(); | ||||
|         // nlog(json_encode($x));
 | ||||
|         // nlog(json_encode(htmlspecialchars(json_encode($x), ENT_QUOTES, 'UTF-8')));
 | ||||
|         // nlog($invoices->toJson());
 | ||||
| 
 | ||||
|         $this->assertIsArray($invoices->toArray()); | ||||
| 
 | ||||
|         nlog("end invoices = " . microtime(true) - $start); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private function transformPayment(Payment $payment): array | ||||
| @ -466,8 +589,6 @@ class TemplateTest extends TestCase | ||||
|             $data['invoices'] = $invoices; | ||||
|             $ts = $replicated_design->service()->build($data); | ||||
|          | ||||
|             // nlog("results = ");
 | ||||
|             // nlog($ts->getHtml());
 | ||||
|             $this->assertNotNull($ts->getHtml()); | ||||
| 
 | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user