WhyNotHugo/django-afip

Transaction management

WhyNotHugo opened this issue · 2 comments

Validating recepts handles DB transactions by itself just fine.

Using this can be dangerous:

with transaction.atomic()
    receipt.validate()

If there's a failure during this call, the can be irrecoverable data loss. validate() should internally check that no transaction is ongoing, and raise ProgramingError() if it is being run inside a transaction.

Error message should suggest reading the validate() docstring.

May be a check if validate is not running in an atomic context should be fine?