diff --git a/app/DataMapper/Tax/US/Rule.php b/app/DataMapper/Tax/US/Rule.php index 87482875643d..854a689cae2a 100644 --- a/app/DataMapper/Tax/US/Rule.php +++ b/app/DataMapper/Tax/US/Rule.php @@ -103,7 +103,7 @@ class Rule extends BaseRule implements RuleInterface */ public function taxService(): self { - if($this->tax_data->txbService == 'Y') { + if($this->tax_data?->txbService == 'Y') { $this->default(); } diff --git a/app/Http/Controllers/ClientPortal/StatementController.php b/app/Http/Controllers/ClientPortal/StatementController.php index 50675869f1a3..0720e8d52a1d 100644 --- a/app/Http/Controllers/ClientPortal/StatementController.php +++ b/app/Http/Controllers/ClientPortal/StatementController.php @@ -39,7 +39,7 @@ class StatementController extends Controller public function raw(ShowStatementRequest $request) { $pdf = $request->client()->service()->statement( - $request->only(['start_date', 'end_date', 'show_payments_table', 'show_aging_table', 'status']) + $request->only(['start_date', 'end_date', 'show_payments_table', 'show_aging_table', 'show_credits_table', 'status']) ); if ($pdf && $request->query('download')) { diff --git a/app/Http/Requests/ClientPortal/Statements/ShowStatementRequest.php b/app/Http/Requests/ClientPortal/Statements/ShowStatementRequest.php index c263248e83bb..01ad16230e82 100644 --- a/app/Http/Requests/ClientPortal/Statements/ShowStatementRequest.php +++ b/app/Http/Requests/ClientPortal/Statements/ShowStatementRequest.php @@ -39,6 +39,7 @@ class ShowStatementRequest extends FormRequest $this->merge([ 'show_payments_table' => $this->has('show_payments_table') ? \boolval($this->show_payments_table) : false, 'show_aging_table' => $this->has('show_aging_table') ? \boolval($this->show_aging_table) : false, + 'show_credits_table' => $this->has('show_credits_table') ? \boolval($this->show_credits_table) : false, ]); } diff --git a/app/Http/Requests/Statements/CreateStatementRequest.php b/app/Http/Requests/Statements/CreateStatementRequest.php index 9df2dee4e4d0..a2ac1204dabd 100644 --- a/app/Http/Requests/Statements/CreateStatementRequest.php +++ b/app/Http/Requests/Statements/CreateStatementRequest.php @@ -51,6 +51,7 @@ class CreateStatementRequest extends Request $this->merge([ 'show_payments_table' => $this->has('show_payments_table') ? \boolval($this->show_payments_table) : false, 'show_aging_table' => $this->has('show_aging_table') ? \boolval($this->show_aging_table) : false, + 'show_credits_table' => $this->has('show_credits_table') ? \boolval($this->show_credits_table) : false, ]); } diff --git a/app/Services/Scheduler/EmailStatementService.php b/app/Services/Scheduler/EmailStatementService.php index 8080ef39281d..4fa781c7a0e0 100644 --- a/app/Services/Scheduler/EmailStatementService.php +++ b/app/Services/Scheduler/EmailStatementService.php @@ -68,6 +68,7 @@ class EmailStatementService 'end_date' =>$start_end[1], 'show_payments_table' => $this->scheduler->parameters['show_payments_table'], 'show_aging_table' => $this->scheduler->parameters['show_aging_table'], + 'show_credits_table' => $this->scheduler->parameters['show_credits_table'], 'status' => $this->scheduler->parameters['status'] ]; } diff --git a/tests/Unit/Tax/UsTaxTest.php b/tests/Unit/Tax/UsTaxTest.php index 5ed356723cd2..610b1b5218c0 100644 --- a/tests/Unit/Tax/UsTaxTest.php +++ b/tests/Unit/Tax/UsTaxTest.php @@ -147,6 +147,77 @@ class UsTaxTest extends TestCase return $invoice; } + public function testSameSubregionAndExemptProduct() + { + + $settings = CompanySettings::defaults(); + $settings->country_id = '840'; // germany + + $tax_data = new TaxModel(); + $tax_data->seller_subregion = 'CA'; + $tax_data->regions->US->has_sales_above_threshold = true; + $tax_data->regions->US->tax_all_subregions = true; + $tax_data->regions->EU->has_sales_above_threshold = true; + $tax_data->regions->EU->tax_all_subregions = true; + $tax_data->regions->EU->subregions->DE->tax_rate = 21; + + $company = Company::factory()->create([ + 'account_id' => $this->account->id, + 'settings' => $settings, + 'tax_data' => $tax_data, + 'calculate_taxes' => true, + ]); + + $client = Client::factory()->create([ + 'user_id' => $this->user->id, + 'company_id' => $company->id, + 'country_id' => 840, + 'postal_code' => '90210', + 'shipping_country_id' => 840, + 'shipping_postal_code' => '90210', + 'has_valid_vat_number' => false, + 'postal_code' => 'xx', + 'is_tax_exempt' => false, + ]); + + $invoice = Invoice::factory()->create([ + 'company_id' => $company->id, + 'client_id' => $client->id, + 'status_id' => 1, + 'user_id' => $this->user->id, + 'uses_inclusive_taxes' => false, + 'discount' => 0, + 'line_items' => [ + [ + 'product_key' => 'Test', + 'notes' => 'Test', + 'cost' => 100, + 'quantity' => 1, + 'tax_name1' => '', + 'tax_rate1' => 0, + 'tax_name2' => '', + 'tax_rate2' => 0, + 'tax_name3' => '', + 'tax_rate3' => 0, + 'type_id' => '1', + 'tax_id' => Product::PRODUCT_TYPE_EXEMPT, + ], + ], + 'tax_rate1' => 0, + 'tax_rate2' => 0, + 'tax_rate3' => 0, + 'tax_name1' => '', + 'tax_name2' => '', + 'tax_name3' => '', + 'tax_data' => new Response($this->mock_response), + ]); + + $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); + + $this->assertEquals(100, $invoice->amount); + + } + public function testForeignTaxesEnabledWithExemptProduct() { $settings = CompanySettings::defaults(); @@ -174,6 +245,7 @@ class UsTaxTest extends TestCase 'shipping_country_id' => 276, 'has_valid_vat_number' => false, 'postal_code' => 'xx', + 'is_tax_exempt' => false, ]); $invoice = Invoice::factory()->create([