feat: sync latest ARR implementation
This commit is contained in:
@@ -216,14 +216,79 @@ class CompanyReportCoreTests(unittest.TestCase):
|
||||
"【SYN-RM2】900×1 + 【SYN-RM2】1,800×1 = 2,700",
|
||||
)
|
||||
|
||||
def test_missing_group_code_keeps_each_fact_with_blank_booking_room(self):
|
||||
facts = [
|
||||
finance_fact(
|
||||
2,
|
||||
group="",
|
||||
block_code="SYN-BLOCK-B",
|
||||
total_price=Decimal("1800"),
|
||||
),
|
||||
finance_fact(
|
||||
1,
|
||||
group="",
|
||||
block_code="SYN-BLOCK-A",
|
||||
total_price=Decimal("900"),
|
||||
),
|
||||
]
|
||||
|
||||
report = build_company_report(
|
||||
"QBD", 2026, 7, date(2026, 7, 10), snapshot(facts, [], {})
|
||||
)
|
||||
|
||||
self.assertTrue(report.valid)
|
||||
self.assertEqual(report.errors, ())
|
||||
self.assertEqual(report.row_count, 2)
|
||||
rows = report.periods[0].rows
|
||||
self.assertEqual([row.record_ids for row in rows], [(1,), (2,)])
|
||||
self.assertTrue(all(row.booking_room == "" for row in rows))
|
||||
self.assertTrue(all(row.res_comment == "" for row in rows))
|
||||
self.assertTrue(all(not row.duplicate_group for row in rows))
|
||||
self.assertEqual(
|
||||
[row.total_booking_price for row in rows],
|
||||
["【SYN-RM2】900×1 = 900", "【SYN-RM2】1,800×1 = 1,800"],
|
||||
)
|
||||
|
||||
def test_unmatched_group_code_keeps_segment_with_blank_booking_room(self):
|
||||
facts = [
|
||||
finance_fact(1, block_code="SYN-BLOCK-A", total_price=Decimal("900")),
|
||||
finance_fact(2, block_code="SYN-BLOCK-B", total_price=Decimal("1800")),
|
||||
]
|
||||
cases = (
|
||||
({}, {}),
|
||||
({"SYN-GROUP-A": 700}, {"SYN-GROUP-A": 700}),
|
||||
)
|
||||
|
||||
for parse_versions, expected_booking_versions in cases:
|
||||
with self.subTest(parse_versions=parse_versions):
|
||||
report = build_company_report(
|
||||
"QBD",
|
||||
2026,
|
||||
7,
|
||||
date(2026, 7, 10),
|
||||
snapshot(facts, [], parse_versions),
|
||||
)
|
||||
|
||||
self.assertTrue(report.valid)
|
||||
self.assertEqual(report.errors, ())
|
||||
self.assertEqual(report.row_count, 1)
|
||||
row = report.periods[0].rows[0]
|
||||
self.assertEqual(row.res_comment, "SYN-GROUP-A")
|
||||
self.assertEqual(row.booking_room, "")
|
||||
self.assertEqual(row.block_code, "SYN-BLOCK-A;SYN-BLOCK-B")
|
||||
self.assertEqual(
|
||||
row.total_booking_price,
|
||||
"【SYN-RM2】900×1 + 【SYN-RM2】1,800×1 = 2,700",
|
||||
)
|
||||
self.assertTrue(row.multi_price_review)
|
||||
self.assertEqual(
|
||||
[warning.code for warning in report.warnings],
|
||||
[WarningCode.MULTI_PRICE_REVIEW],
|
||||
)
|
||||
self.assertEqual(report.booking_versions, expected_booking_versions)
|
||||
|
||||
def test_invalid_source_facts_block_the_company_report(self):
|
||||
cases = (
|
||||
(
|
||||
finance_fact(1, group=""),
|
||||
[room_item(1)],
|
||||
{"SYN-GROUP-A": 700},
|
||||
ErrorCode.GROUP_CODE_MISSING,
|
||||
),
|
||||
(
|
||||
finance_fact(1, nights=3),
|
||||
[room_item(1)],
|
||||
@@ -236,18 +301,6 @@ class CompanyReportCoreTests(unittest.TestCase):
|
||||
{"SYN-GROUP-A": 700},
|
||||
ErrorCode.TOTAL_PRICE_INVALID,
|
||||
),
|
||||
(
|
||||
finance_fact(1),
|
||||
[room_item(1)],
|
||||
{},
|
||||
ErrorCode.BOOKING_PARSE_FAILED,
|
||||
),
|
||||
(
|
||||
finance_fact(1),
|
||||
[],
|
||||
{"SYN-GROUP-A": 700},
|
||||
ErrorCode.ROOM_ITEMS_MISSING,
|
||||
),
|
||||
)
|
||||
for fact, items, versions, expected in cases:
|
||||
with self.subTest(expected=expected):
|
||||
|
||||
Reference in New Issue
Block a user