From 851f81e1d68c7cad26064fd9a1fc320f9af1bc75 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 May 2023 18:44:58 +1000 Subject: [PATCH 1/6] Fixes for FACe --- app/Services/Invoice/EInvoice/FacturaEInvoice.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Services/Invoice/EInvoice/FacturaEInvoice.php b/app/Services/Invoice/EInvoice/FacturaEInvoice.php index 79840dad0beb..98802616ac9e 100644 --- a/app/Services/Invoice/EInvoice/FacturaEInvoice.php +++ b/app/Services/Invoice/EInvoice/FacturaEInvoice.php @@ -192,7 +192,7 @@ class FacturaEInvoice extends AbstractService if($this->invoice->client->custom_value1 == 'yes') { - foreach($this->invoice->client->contacts() as $contact) + foreach($this->invoice->client->contacts()->whereNotNull('custom_value1')->whereNull('deleted_at')->cursor() as $contact) { if(in_array($contact->custom_value1, array_keys($this->centre_codes))) @@ -345,12 +345,11 @@ class FacturaEInvoice extends AbstractService "fax" => "", "website" => substr($company->settings->website, 0, 50), "contactPeople" => substr($company->owner()->present()->name(), 0, 40), - 'centres' => $this->setFace(), + // 'centres' => $this->setFace(), // "cnoCnae" => "04647", // Clasif. Nacional de Act. Económicas // "ineTownCode" => "280796" // Cód. de municipio del INE ]); - $this->fac->setSeller($seller); return $this; @@ -375,6 +374,7 @@ class FacturaEInvoice extends AbstractService "fax" => "", "website" => substr($this->invoice->client->present()->website(), 0 ,60), "contactPeople" => substr($this->invoice->client->present()->first_name()." ".$this->invoice->client->present()->last_name(), 0, 40), + 'centres' => $this->setFace(), // "cnoCnae" => "04791", // Clasif. Nacional de Act. Económicas // "ineTownCode" => "280796" // Cód. de municipio del INE ]); From b47253ba45dbb9fc770986e13a86b61d787e64b3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 May 2023 20:17:37 +1000 Subject: [PATCH 2/6] Fixes for custom quote columns --- app/Services/Invoice/TriggeredActions.php | 6 +++++- app/Services/PdfMaker/Design.php | 10 +++++++--- .../PdfMaker/Designs/Utilities/DesignHelpers.php | 11 +++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/Services/Invoice/TriggeredActions.php b/app/Services/Invoice/TriggeredActions.php index d607de6d140b..4fb1342391ae 100644 --- a/app/Services/Invoice/TriggeredActions.php +++ b/app/Services/Invoice/TriggeredActions.php @@ -39,7 +39,11 @@ class TriggeredActions extends AbstractService public function run() { if ($this->request->has('auto_bill') && $this->request->input('auto_bill') == 'true') { - $this->invoice->service()->autoBill(); //update notification sends automatically for this. + try { + $this->invoice->service()->autoBill(); + } catch(\Exception $e) { + + } //update notification sends automatically for this. } if ($this->request->has('paid') && $this->request->input('paid') == 'true') { diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index ccf8694c18d0..71b83284438f 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -743,8 +743,6 @@ class Design extends BaseDesign */ public function buildTableHeader(string $type): array { - $this->processTaxColumns($type); - // $this->processCustomColumns($type); $elements = []; @@ -757,10 +755,16 @@ class Design extends BaseDesign $table_type = "{$type}_columns"; + $column_type = $type; + if ($type == 'product' && $this->entity instanceof Quote && !$this->settings_object->getSetting('sync_invoice_quote_columns')) { $table_type = "product_quote_columns"; + $column_type = 'product_quote'; } - + + $this->processTaxColumns($column_type); + + foreach ($this->context['pdf_variables'][$table_type] as $column) { if (array_key_exists($column, $aliases)) { $elements[] = ['element' => 'th', 'content' => $aliases[$column] . '_label', 'properties' => ['data-ref' => "{$type}_table-" . substr($aliases[$column], 1) . '-th', 'hidden' => $this->settings_object->getSetting('hide_empty_columns_on_pdf')]]; diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 1e9a4ccab5d1..183c4de8df35 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -150,8 +150,11 @@ trait DesignHelpers */ public function processTaxColumns(string $type): void { - if ($type == 'product') { + $column_type = $type; + if ($type == 'product' || $type == 'product_quote') { $type_id = 1; + $column_type = 'product_quote'; + $type = 'product'; } if ($type == 'task') { @@ -163,7 +166,7 @@ trait DesignHelpers // This sprintf() will help us convert "task" or "product" into "$task" or "$product" without // evaluating the variable. - if (in_array(sprintf('%s%s.tax', '$', $type), (array) $this->context['pdf_variables']["{$type}_columns"])) { + if (in_array(sprintf('%s%s.tax', '$', $type), (array) $this->context['pdf_variables']["{$column_type}_columns"])) { $line_items = collect($this->entity->line_items)->filter(function ($item) use ($type_id) { return $item->type_id = $type_id; }); @@ -186,10 +189,10 @@ trait DesignHelpers array_push($taxes, sprintf('%s%s.tax_rate3', '$', $type)); } - $key = array_search(sprintf('%s%s.tax', '$', $type), $this->context['pdf_variables']["{$type}_columns"], true); + $key = array_search(sprintf('%s%s.tax', '$', $type), $this->context['pdf_variables']["{$column_type}_columns"], true); if ($key !== false) { - array_splice($this->context['pdf_variables']["{$type}_columns"], $key, 1, $taxes); + array_splice($this->context['pdf_variables']["{$column_type}_columns"], $key, 1, $taxes); } } } From 58cb6ec874287675fc4ffee1cfd643bc9cab3728 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 May 2023 20:46:12 +1000 Subject: [PATCH 3/6] Fixes for custom quote columns --- app/Services/PdfMaker/Design.php | 2 ++ .../PdfMaker/Designs/Utilities/DesignHelpers.php | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 71b83284438f..9bb0e91f9bbb 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -874,6 +874,8 @@ class Design extends BaseDesign // $task.cost => $task.rate // $task.quantity => $task.hours + nlog("{$key} => {$cell}"); + if ($cell == '$task.rate') { $element['elements'][] = ['element' => 'td', 'content' => $row['$task.cost'], 'properties' => ['data-ref' => 'task_table-task.cost-td']]; } elseif ($cell == '$product.discount' && !$this->company->enable_product_discount) { diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 183c4de8df35..4a2d287ef5bb 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -151,15 +151,21 @@ trait DesignHelpers public function processTaxColumns(string $type): void { $column_type = $type; - if ($type == 'product' || $type == 'product_quote') { + + if ($type == 'product') { $type_id = 1; - $column_type = 'product_quote'; - $type = 'product'; } if ($type == 'task') { $type_id = 2; } + + if ($type == 'product_quote') { + $type_id = 1; + $column_type = 'product_quote'; + $type = 'product'; + } + // At the moment we pass "task" or "product" as type. // However, "pdf_variables" contains "$task.tax" or "$product.tax" <-- Notice the dollar sign. From 183811ef953f6cc3959459c803fa82e46d5dd26c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 May 2023 20:47:39 +1000 Subject: [PATCH 4/6] v5.5.118 --- VERSION.txt | 2 +- app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php | 1 + config/ninja.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index ea9844910802..fec0973fe321 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.5.117 \ No newline at end of file +5.5.118 \ No newline at end of file diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 4a2d287ef5bb..8f41938b4540 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -160,6 +160,7 @@ trait DesignHelpers $type_id = 2; } + /** 17-05-2023 need to explicity define product_quote here */ if ($type == 'product_quote') { $type_id = 1; $column_type = 'product_quote'; diff --git a/config/ninja.php b/config/ninja.php index f61cf2828fd5..420f57681116 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -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' => '5.5.117', - 'app_tag' => '5.5.117', + 'app_version' => '5.5.118', + 'app_tag' => '5.5.118', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), From 0adb908df9ec51fb43e709779b9e8a74518c79dc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 May 2023 20:55:27 +1000 Subject: [PATCH 5/6] Clean up for taxes --- app/DataMapper/Tax/BaseRule.php | 2 +- app/Services/Tax/Providers/ZipTax.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/DataMapper/Tax/BaseRule.php b/app/DataMapper/Tax/BaseRule.php index 1cf893d5dded..1a89d4ea5718 100644 --- a/app/DataMapper/Tax/BaseRule.php +++ b/app/DataMapper/Tax/BaseRule.php @@ -194,7 +194,7 @@ class BaseRule implements RuleInterface } /** If we are in a Origin based state, force the company tax here */ - if($company->origin_tax_data->originDestination == 'O' && ($company->tax_data->seller_subregion == $this->client_subregion)) { + if($company->origin_tax_data?->originDestination == 'O' && ($company->tax_data?->seller_subregion == $this->client_subregion)) { $tax_data = $company->origin_tax_data; diff --git a/app/Services/Tax/Providers/ZipTax.php b/app/Services/Tax/Providers/ZipTax.php index 9f0e40b8b4de..8a6ffb78a2ef 100644 --- a/app/Services/Tax/Providers/ZipTax.php +++ b/app/Services/Tax/Providers/ZipTax.php @@ -45,7 +45,7 @@ class ZipTax implements TaxProviderInterface } - $response->throw(); + // $response->throw(); } @@ -75,7 +75,7 @@ class ZipTax implements TaxProviderInterface if(isset($response['results']['0'])) return $response['results']['0']; - throw new \Exception("Error resolving tax (code) = " . $response['rCode']); - + return null; + // throw new \Exception("Error resolving tax (code) = " . $response['rCode']); } } From 51fd4d3ee9f95e56e7757af21026f327bd3c55cf Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 May 2023 21:02:25 +1000 Subject: [PATCH 6/6] Clean up for logging --- app/DataMapper/Tax/US/Rule.php | 2 -- app/Services/PdfMaker/Design.php | 3 --- 2 files changed, 5 deletions(-) diff --git a/app/DataMapper/Tax/US/Rule.php b/app/DataMapper/Tax/US/Rule.php index 4a4527057b9f..6749ad162a0c 100644 --- a/app/DataMapper/Tax/US/Rule.php +++ b/app/DataMapper/Tax/US/Rule.php @@ -145,8 +145,6 @@ class Rule extends BaseRule implements RuleInterface */ public function taxPhysical($item): self { - nlog("tax physical"); - nlog($item); $this->default($item); return $this; diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 9bb0e91f9bbb..0ca327ce1572 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -841,7 +841,6 @@ class Design extends BaseDesign $table_type = "product_quote_columns"; } - foreach ($items as $row) { $element = ['element' => 'tr', 'elements' => []]; @@ -874,8 +873,6 @@ class Design extends BaseDesign // $task.cost => $task.rate // $task.quantity => $task.hours - nlog("{$key} => {$cell}"); - if ($cell == '$task.rate') { $element['elements'][] = ['element' => 'td', 'content' => $row['$task.cost'], 'properties' => ['data-ref' => 'task_table-task.cost-td']]; } elseif ($cell == '$product.discount' && !$this->company->enable_product_discount) {