[Refactor] Support different schema version - #40
Conversation
|
|
||
| model_cls = self.ents[typename] | ||
| obj = model_cls(mapped_row(record, model_cls)) | ||
| obj.validate() |
There was a problem hiding this comment.
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]] = {} |
There was a problem hiding this comment.
fixed type hinting. it's already Dict[ID, List[ID]]
| """ | ||
| ENT: 9 | ||
| """ | ||
| FIELDS = { |
| ENT: 9 | ||
| """ | ||
| FIELDS = { | ||
| "display_order": schema_field("ZDISPLAYORDER"), |
There was a problem hiding this comment.
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
| if category_assignment is None and original_category_assignment is None: | ||
| return |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
nit review all comparison in tests and change to them to have a epsilon 0.001
No description provided.