We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a823526 commit e575c56Copy full SHA for e575c56
1 file changed
fiscguy/zimra_receipt_handler.py
@@ -13,6 +13,7 @@
13
import qrcode
14
from django.core.files.base import ContentFile
15
from django.db import DatabaseError
16
+from django.db.models import F
17
from loguru import logger
18
19
from fiscguy.exceptions import ReceiptSubmissionError
@@ -507,8 +508,9 @@ def _upsert_counter(
507
508
defaults={"fiscal_counter_value": amount},
509
)
510
if not created:
- counter.fiscal_counter_value += amount
511
- counter.save()
+ FiscalCounter.objects.filter(pk=counter.pk).update(
512
+ fiscal_counter_value=F("fiscal_counter_value") + amount
513
+ )
514
except DatabaseError as exc:
515
logger.exception(f"Failed to upsert {counter_type} counter for device {self._device}")
516
raise ReceiptSubmissionError(f"Failed to update {counter_type} fiscal counter") from exc
0 commit comments