mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-08 16:14:13 +00:00
fix(taxes): correct compound tax document flows (#754)
This commit is contained in:
@@ -28,8 +28,8 @@ test('applies document discount and document-level tax', function () {
|
||||
test('uses per-item taxes (not document taxes) when tax_per_item is YES', function () {
|
||||
$totals = DocumentTotals::compute(
|
||||
[
|
||||
['price' => 1000, 'quantity' => 1, 'taxes' => [['amount' => 100]]],
|
||||
['price' => 2000, 'quantity' => 1, 'taxes' => [['amount' => 200]]],
|
||||
['price' => 1000, 'quantity' => 1, 'taxes' => [['tax_type_id' => 1, 'amount' => 100]]],
|
||||
['price' => 2000, 'quantity' => 1, 'taxes' => [['tax_type_id' => 2, 'amount' => 200]]],
|
||||
],
|
||||
[['amount' => 9999]],
|
||||
0, 'YES', false, 'YES'
|
||||
@@ -77,7 +77,7 @@ test('supports negative quantities', function () {
|
||||
expect($totals['sub_total'])->toBe(-150)->and($totals['total'])->toBe(-150);
|
||||
});
|
||||
|
||||
test('sums a compound tax line just like any other document-level tax line', function () {
|
||||
test('calculates exclusive document-level compound tax totals', function () {
|
||||
$totals = DocumentTotals::compute(
|
||||
[['price' => 10000, 'quantity' => 1]],
|
||||
[['amount' => 1900], ['amount' => 119, 'compound_tax' => true]],
|
||||
@@ -87,3 +87,49 @@ test('sums a compound tax line just like any other document-level tax line', fun
|
||||
expect($totals['tax'])->toBe(2019)
|
||||
->and($totals['total'])->toBe(12019);
|
||||
});
|
||||
|
||||
test('keeps simple taxes inside an inclusive document total while adding compound taxes', function () {
|
||||
$totals = DocumentTotals::compute(
|
||||
[['price' => 11900, 'quantity' => 1]],
|
||||
[['amount' => 1900], ['amount' => 119, 'compound_tax' => true]],
|
||||
0, 'NO', true, 'NO'
|
||||
);
|
||||
|
||||
expect($totals['tax'])->toBe(2019)
|
||||
->and($totals['total'])->toBe(12019);
|
||||
});
|
||||
|
||||
test('calculates exclusive per-item compound tax totals and ignores the UI placeholder', function () {
|
||||
$totals = DocumentTotals::compute(
|
||||
[[
|
||||
'price' => 10000,
|
||||
'quantity' => 1,
|
||||
'taxes' => [
|
||||
['tax_type_id' => 1, 'amount' => 1900],
|
||||
['tax_type_id' => 2, 'amount' => 119, 'compound_tax' => true],
|
||||
['tax_type_id' => 0, 'amount' => 0],
|
||||
],
|
||||
]],
|
||||
[], 0, 'YES', false, 'NO'
|
||||
);
|
||||
|
||||
expect($totals['tax'])->toBe(2019)
|
||||
->and($totals['total'])->toBe(12019);
|
||||
});
|
||||
|
||||
test('keeps simple per-item taxes inside an inclusive total while adding compound taxes', function () {
|
||||
$totals = DocumentTotals::compute(
|
||||
[[
|
||||
'price' => 11900,
|
||||
'quantity' => 1,
|
||||
'taxes' => [
|
||||
['tax_type_id' => 1, 'amount' => 1900],
|
||||
['tax_type_id' => 2, 'amount' => 119, 'compound_tax' => true],
|
||||
],
|
||||
]],
|
||||
[], 0, 'YES', true, 'NO'
|
||||
);
|
||||
|
||||
expect($totals['tax'])->toBe(2019)
|
||||
->and($totals['total'])->toBe(12019);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user