refund should not be NULL in class
These two fields are essential to construct the class, which are defined as foreign keys, which will be deleted with
If these two fields are NULL, it means that the data may already be corrupted. To prevent this from happening, we can add
null=False in these fields to protect the data integrity
class RefundLine(StatusMixin, TimeStampedModel): """A refund line, used to represent the state of a single item as part of a larger Refund.""" refund = models.ForeignKey( 'refund.Refund', related_name='lines', verbose_name=_('Refund'), on_delete=models.CASCADE ) order_line = models.ForeignKey( 'order.Line', related_name='refund_lines', verbose_name=_('Order Line'), on_delete=models.CASCADE )
order should not be NULL in class
Refund. The refund will be created from the order and order_lines. If the refund does not have an order or the order’s user is NULL, which will cause exceptions in future references. We can add a not null constraint for this.
class Refund(StatusMixin, TimeStampedModel): """Main refund model, used to represent the state of a refund.""" order = models.ForeignKey('order.Order', related_name='refunds', verbose_name=_('Order'), on_delete=models.CASCADE) user = models.ForeignKey('core.User', related_name='refunds', verbose_name=_('User'), on_delete=models.CASCADE)
I can work on the PR for this issue, please let me know your thoughts. Thanks!