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:
mchev
2025-05-04 02:24:56 +02:00
committed by GitHub
parent 546f75d3a6
commit bf5b544ca3
22 changed files with 306 additions and 39 deletions

View File

@@ -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,
]);
});

View File

@@ -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);
});