lingo: factorize basket item creation for paid remote invoices (#55876)

This commit is contained in:
Benjamin Dauvergne 2021-07-30 11:00:00 +02:00
parent c5d17a82a5
commit 050df6b0a1
1 changed files with 12 additions and 10 deletions

View File

@ -878,20 +878,22 @@ class Transaction(models.Model):
)
else:
logger.info('notified payment for remote item %s from transaction %s', item_id, self)
subject = _('Invoice #%s') % remote_item.display_id
local_item = BasketItem.objects.create(
user=self.user,
regie=regie,
source_url='',
subject=subject,
amount=remote_item.amount,
payment_date=self.end_date,
)
self.items.add(local_item)
self.items.add(self.create_paid_invoice_basket_item(remote_item))
self.to_be_paid_remote_items = ','.join(to_be_paid_remote_items) or None
self.save(update_fields=['to_be_paid_remote_items'])
def create_paid_invoice_basket_item(self, remote_item):
subject = _('Invoice #%s') % remote_item.display_id
return BasketItem.objects.create(
user=self.user,
regie=remote_item.regie,
source_url='',
subject=subject,
amount=remote_item.amount,
payment_date=self.end_date,
)
def handle_backend_response(self, response, callback=True):
logger.debug('lingo: regie "%s" handling response for transaction "%%s"' % self.regie, self.order_id)
if self.status == response.result: