fix the calculation of opening cash and closing cash when there are some difference
This commit is contained in:
parent
7fb38ceb8b
commit
fdad209a02
Binary file not shown.
@ -1,10 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import logging
|
|
||||||
|
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class PosSession(models.Model):
|
class PosSession(models.Model):
|
||||||
_inherit = "pos.session"
|
_inherit = "pos.session"
|
||||||
@ -52,25 +48,11 @@ class PosSession(models.Model):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def set_cashbox_pos(self, cashbox_value: int, notes: str):
|
def set_cashbox_pos(self, cashbox_value: int, notes: str):
|
||||||
_logger.debug(
|
|
||||||
"POS cash opening adjustment: set_cashbox_pos called for session_ids=%s, cashbox_value=%s, notes=%s",
|
|
||||||
self.ids,
|
|
||||||
cashbox_value,
|
|
||||||
notes,
|
|
||||||
)
|
|
||||||
for session in self:
|
for session in self:
|
||||||
expected = session.opening_cash_expected if session.config_id.cash_control else 0.0
|
expected = session.opening_cash_expected if session.config_id.cash_control else 0.0
|
||||||
if not session.config_id.cash_control:
|
if not session.config_id.cash_control:
|
||||||
expected = session.cash_register_balance_start or 0.0
|
expected = session.cash_register_balance_start or 0.0
|
||||||
difference = cashbox_value - (expected or 0.0)
|
difference = cashbox_value - (expected or 0.0)
|
||||||
_logger.debug(
|
|
||||||
"POS cash opening adjustment: session=%s expected=%s counted=%s difference=%s cash_control=%s",
|
|
||||||
session.id,
|
|
||||||
expected,
|
|
||||||
cashbox_value,
|
|
||||||
difference,
|
|
||||||
session.config_id.cash_control,
|
|
||||||
)
|
|
||||||
session.write({
|
session.write({
|
||||||
"state": "opened",
|
"state": "opened",
|
||||||
"opening_notes": notes,
|
"opening_notes": notes,
|
||||||
@ -93,16 +75,11 @@ class PosSession(models.Model):
|
|||||||
def _post_statement_difference(self, amount, is_opening):
|
def _post_statement_difference(self, amount, is_opening):
|
||||||
for session in self:
|
for session in self:
|
||||||
session_amount = amount
|
session_amount = amount
|
||||||
if not is_opening and session.config_id.cash_control:
|
opening_float = session._get_opening_float_amount() if session.config_id.cash_control else 0.0
|
||||||
opening_float = session._get_opening_float_amount()
|
if not is_opening and opening_float:
|
||||||
if opening_float and session.currency_id.is_zero(session_amount + opening_float):
|
if session.currency_id.compare_amounts(session.cash_register_balance_end_real, opening_float) <= 0:
|
||||||
_logger.debug(
|
session_amount += opening_float
|
||||||
"POS cash opening adjustment: skipping difference posting for session %s "
|
if session.currency_id.is_zero(session_amount):
|
||||||
"because it solely matches the opening float (amount=%s, opening_float=%s).",
|
|
||||||
session.id,
|
|
||||||
session_amount,
|
|
||||||
opening_float,
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
super(PosSession, session)._post_statement_difference(session_amount, is_opening)
|
super(PosSession, session)._post_statement_difference(session_amount, is_opening)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user