来源仓库:jxc/ai-fresh-delivery 来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d 快照树: 09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件) 按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据 (生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、 deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值), 整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。 供应商系统后续开发自本提交开始。
70 lines
1.8 KiB
TypeScript
70 lines
1.8 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
import {
|
|
BRANCH_TAX_LEVELS,
|
|
classifyProductTaxBand,
|
|
formatTaxRateLabel,
|
|
normalizeBranchTaxLevel,
|
|
resolveTaxRateForBranchLevel,
|
|
snapTaxRate,
|
|
} from './branchTaxLevel';
|
|
|
|
describe('branchTaxLevel', () => {
|
|
test('normalize unknown to exempt_agri', () => {
|
|
expect(normalizeBranchTaxLevel('nope')).toBe('exempt_agri');
|
|
expect(normalizeBranchTaxLevel('flat_13')).toBe('flat_13');
|
|
});
|
|
|
|
test('classify fresh vegetable as 0', () => {
|
|
expect(
|
|
classifyProductTaxBand({
|
|
isFresh: true,
|
|
taxCode: '1010112040000000000',
|
|
categoryName: '叶菜类',
|
|
})
|
|
).toBe(0);
|
|
});
|
|
|
|
test('classify seasoning as 13', () => {
|
|
expect(
|
|
classifyProductTaxBand({
|
|
isFresh: false,
|
|
taxCode: '1030206000000000000',
|
|
categoryName: '干杂',
|
|
})
|
|
).toBe(0.13);
|
|
});
|
|
|
|
test('classify spice raw as 9', () => {
|
|
expect(
|
|
classifyProductTaxBand({
|
|
isFresh: false,
|
|
taxCode: '1010117000000000000',
|
|
categoryName: '香料',
|
|
})
|
|
).toBe(0.09);
|
|
});
|
|
|
|
test('standard_agri maps 0 to 9', () => {
|
|
expect(
|
|
resolveTaxRateForBranchLevel('standard_agri', {
|
|
isFresh: true,
|
|
taxCode: '1010112040000000000',
|
|
})
|
|
).toBe(0.09);
|
|
});
|
|
|
|
test('flat levels', () => {
|
|
expect(resolveTaxRateForBranchLevel('flat_0', { isFresh: false })).toBe(0);
|
|
expect(resolveTaxRateForBranchLevel('flat_9', { isFresh: true })).toBe(0.09);
|
|
expect(resolveTaxRateForBranchLevel('flat_13', { isFresh: true })).toBe(0.13);
|
|
});
|
|
|
|
test('format and snap', () => {
|
|
expect(formatTaxRateLabel(0)).toBe('0%');
|
|
expect(formatTaxRateLabel(0.09)).toBe('9%');
|
|
expect(formatTaxRateLabel(0.13)).toBe('13%');
|
|
expect(snapTaxRate(0.09)).toBe(0.09);
|
|
expect(BRANCH_TAX_LEVELS.length).toBe(5);
|
|
});
|
|
});
|