Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions fiscguy/zimra_receipt_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import qrcode
from django.core.files.base import ContentFile
from django.db import DatabaseError
from django.db.models import F
from loguru import logger

from fiscguy.exceptions import ReceiptSubmissionError
Expand Down Expand Up @@ -507,8 +508,9 @@ def _upsert_counter(
defaults={"fiscal_counter_value": amount},
)
if not created:
counter.fiscal_counter_value += amount
counter.save()
FiscalCounter.objects.filter(pk=counter.pk).update(
fiscal_counter_value=F("fiscal_counter_value") + amount
)
except DatabaseError as exc:
logger.exception(f"Failed to upsert {counter_type} counter for device {self._device}")
raise ReceiptSubmissionError(f"Failed to update {counter_type} fiscal counter") from exc
Loading