mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
FIxes for show_credits_tables
This commit is contained in:
parent
ebda7b7033
commit
11c5aaba82
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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')) {
|
||||
|
@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -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']
|
||||
];
|
||||
}
|
||||
|
@ -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([
|
||||
|
Loading…
Reference in New Issue
Block a user