mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 13:41:23 +00:00
Adding Flat Tax support with fixed amount (#253)
* Possibility to set a fixed amount on tax types settings * Pint and manage flat taxes on items * Fix display errors and handle global taxes * Tests * Pint with PHP 8.2 cause with PHP 8.3 version it cause workflow error * Merging percent and fixed amount into one column * Now display the currency on SelectTaxPopup on fixed taxes
This commit is contained in:
@@ -141,3 +141,31 @@ test('search items', function () {
|
||||
|
||||
$response->assertOk();
|
||||
});
|
||||
|
||||
test('create item with fixed amount tax', function () {
|
||||
$item = Item::factory()->raw([
|
||||
'taxes' => [
|
||||
Tax::factory()->raw([
|
||||
'calculation_type' => 'fixed',
|
||||
'fixed_amount' => 5000,
|
||||
]),
|
||||
],
|
||||
]);
|
||||
|
||||
$response = postJson('api/v1/items', $item);
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$this->assertDatabaseHas('items', [
|
||||
'name' => $item['name'],
|
||||
'description' => $item['description'],
|
||||
'price' => $item['price'],
|
||||
'company_id' => $item['company_id'],
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('taxes', [
|
||||
'item_id' => $response->getData()->data->id,
|
||||
'calculation_type' => 'fixed',
|
||||
'fixed_amount' => 5000,
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -97,3 +97,16 @@ test('create negative tax type', function () {
|
||||
|
||||
$this->assertDatabaseHas('tax_types', $taxType);
|
||||
});
|
||||
|
||||
test('create fixed amount tax type', function () {
|
||||
$taxType = TaxType::factory()->raw([
|
||||
'calculation_type' => 'fixed',
|
||||
'percent' => null,
|
||||
'fixed_amount' => 5000,
|
||||
]);
|
||||
|
||||
postJson('api/v1/tax-types', $taxType)
|
||||
->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('tax_types', $taxType);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user