mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-10-28 19:18:58 -04:00
* fix(taxes): reject negative tax rates and percentages
Reject negative tax values across all tax entry points so they can
never be persisted and produce inverted sales totals:
- Items::postSave / postBulkUpdate: validate tax_percents.* as
nonNegativeDecimal (was unvalidated, persisted raw).
- Items::save_tax_data (CSV import): fail the row on a negative
Tax N Percent instead of silently dropping the tax.
- Taxes::postSave: reject negative tax_rate before saving.
- Config::postSaveTax: reject negative default tax rates.
Adds non-negative regression tests for Items, Taxes and Config, plus
boundary tests proving a zero tax rate/percent is still accepted. New
language strings for the rejection messages.
* test: adopt test{Method}_{Purpose} naming convention for new tests
Align the negative-tax test method names with the convention established
in ConfigTest (testPostSave_RejectsNegativeTaxPercent, etc.), per review.
* fix(config): add language entries to all locales, extract TaxFixtureTrait
* fix(i18n): place tax_rate_non_negative in alphabetical order
Move the new tax_rate_non_negative entry to its correct alphabetical
position (after tax_rate_error_adding_updating) in all locale files.
---------
Co-authored-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
23 lines
677 B
PHP
23 lines
677 B
PHP
<?php
|
|
|
|
namespace Tests\Support;
|
|
|
|
trait TaxFixtureTrait
|
|
{
|
|
protected function baseTaxPayload(array $overrides = []): array
|
|
{
|
|
return array_merge([
|
|
'default_tax_1_rate' => '5.00',
|
|
'default_tax_1_name' => 'VAT',
|
|
'default_tax_2_rate' => '10.00',
|
|
'default_tax_2_name' => 'GST',
|
|
'tax_included' => '',
|
|
'use_destination_based_tax' => '',
|
|
'default_tax_code' => '',
|
|
'default_tax_category' => '',
|
|
'default_tax_jurisdiction' => '',
|
|
'tax_id' => '',
|
|
], $overrides);
|
|
}
|
|
}
|