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/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/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/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 ]); 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..0ca327ce1572 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')]]; @@ -837,7 +841,6 @@ class Design extends BaseDesign $table_type = "product_quote_columns"; } - foreach ($items as $row) { $element = ['element' => 'tr', 'elements' => []]; diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 1e9a4ccab5d1..8f41938b4540 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -150,6 +150,8 @@ trait DesignHelpers */ public function processTaxColumns(string $type): void { + $column_type = $type; + if ($type == 'product') { $type_id = 1; } @@ -157,13 +159,21 @@ trait DesignHelpers if ($type == 'task') { $type_id = 2; } + + /** 17-05-2023 need to explicity define product_quote here */ + 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. // 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 +196,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); } } } 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']); } } 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', ''),