Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Merge branch 'feature/invoices' of github.com:mirumee/saleor into invoicing_plugin
Tomasz Szymanski0af744222f7a
diff --cc saleor/graphql/order/mutations/orders.pyindex 8962098421,93bec4b5d1..97efa79d5d--- a/saleor/graphql/order/mutations/orders.py+++ b/saleor/graphql/order/mutations/orders.py@@@ -545,8 -567,10 +568,11 @@@ class RequestInvoice(ModelMutation)info.context.plugins.invoice_request(order=order, invoice=invoice, number=data.get("number"))+ events.invoice_requested_event(+ user=info.context.user, order=order, number=data.get("number")+ )- return RequestInvoice()+ invoice.refresh_from_db()+ return RequestInvoice(invoice=invoice)class CreateInvoiceInput(graphene.InputObjectType):diff --cc saleor/order/models.pyindex 3d9b94bc14,22db09dc7d..2a92915d80--- a/saleor/order/models.py+++ b/saleor/order/models.py@@@ -532,6 -532,32 +532,36 @@@ class Invoice(ModelWithMetadata)self.url = urlself.save()+ def fullfill_invoice(self):+ self.status = InvoiceStatus.READY+ self.save()++++ class InvoiceEvent(models.Model):+ """Model used to store events that happened during the invoice lifecycle."""++ date = models.DateTimeField(default=now, editable=False)+ type = models.CharField(max_length=255, choices=InvoiceEvents.CHOICES)+ invoice = models.ForeignKey(+ Invoice, related_name="events", blank=True, null=True, on_delete=models.SET_NULL+ )+ order = models.ForeignKey(+ Order,+ related_name="invoice_events",+ blank=True,+ null=True,+ on_delete=models.SET_NULL,+ )+ user = models.ForeignKey(+ settings.AUTH_USER_MODEL,+ null=True,+ on_delete=models.SET_NULL,+ related_name="+",+ )+ parameters = JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)++ class Meta:+ ordering = ("date",)++ def __repr__(self):+ return f"{self.__class__.__name__}(type={self.type!r}, user={self.user!r})"