Skip to content

[Refactor] Support different schema version - #40

Open
ileodo wants to merge 6 commits into
mainfrom
parameterise
Open

[Refactor] Support different schema version#40
ileodo wants to merge 6 commits into
mainfrom
parameterise

Conversation

@ileodo

@ileodo ileodo commented Aug 15, 2026

Copy link
Copy Markdown
Owner

No description provided.


model_cls = self.ents[typename]
obj = model_cls(mapped_row(record, model_cls))
obj.validate()

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now it's the responsibility of model class's caller to validate the object

self.category_assignment: Dict[ID, List[Tuple[ID, Decimal]]] = {}
self.refund_maps: Dict[ID, ID] = {}
self.tags_map: Dict[ID, ID] = {}
self.tags_map: Dict[ID, List[ID]] = {}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed type hinting. it's already Dict[ID, List[ID]]

"""
ENT: 9
"""
FIELDS = {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spec for this data model.

ENT: 9
"""
FIELDS = {
"display_order": schema_field("ZDISPLAYORDER"),

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. if display_order might came from columns ZDISPLAYORDER and ZDISPLAYORDER1 depends on the db/schema version (assume ZDISPLAYORDER1 take precedent, then this field can be defined as

"display_order": schema_field("ZDISPLAYORDER1", "ZDISPLAYORDER"),

and if ZDISPLAYORDER1 column exist, the value will be used to populate display_order, otherwise try ZDISPLAYORDER

Comment on lines +42 to +43
if category_assignment is None and original_category_assignment is None:
return

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed the test: when original transaction doesn't have category assignment, the refund transaction and origoanl transacation will have None category_assignment and original_category_assignment

pass
else:
assert total_amount == transaction.amount
assert total_amount == pytest.approx(transaction.amount, abs=0.001)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit review all comparison in tests and change to them to have a epsilon 0.001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant