Skip to content
Draft
Show file tree
Hide file tree
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
93 changes: 93 additions & 0 deletions pos_payment_cash_change/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
===================================
Point of Sale - Payment Cash Change
===================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:15ee25b2032d0b38dc5f7c365c444ed6beabd7c6a7f75c2c81b86938f2a30540
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/18.0/pos_payment_cash_change
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-18-0/pos-18-0-pos_payment_cash_change
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows configuring an account to record cash changes given
to customers in the Point of Sale (POS) system. When a customer pays
with cash and requires change, the system will automatically record the
transaction in the specified cash change account.

**Table of contents**

.. contents::
:local:

Configuration
=============

- Go to Invoicing → Configuration → Journals.
- Create new journal with type ``cash`` for Cash Change Account.
- Open a journal or create a new journal with type ``cash``.
- Add Cash Change Account in the field ``Account for the Change``.

|Account for the Change|

.. |Account for the Change| image:: https://raw.githubusercontent.com/OCA/pos/18.0/pos_payment_cash_change/static/desciption/cash_change_account.png

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_payment_cash_change%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Trobz

Contributors
------------

- `Trobz <https://www.trobz.com>`__:

- Phan Hong Phuc </phucph@trobz.com/>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/18.0/pos_payment_cash_change>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions pos_payment_cash_change/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions pos_payment_cash_change/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Point of Sale - Payment Cash Change",
"version": "18.0.1.0.0",
"category": "Point Of Sale",
"author": "Trobz, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"depends": [
"point_of_sale",
],
"data": [
"views/pos_payment_method_views.xml",
],
"installable": True,
}
3 changes: 3 additions & 0 deletions pos_payment_cash_change/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import account_bank_statement_line
from . import pos_payment_method
from . import pos_order
24 changes: 24 additions & 0 deletions pos_payment_cash_change/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from odoo import fields, models


class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"

liquidity_account_id = fields.Many2one(
"account.account",
check_company=True,
copy=False,
help="The liquidity account for this statement line.",
)

def _prepare_move_line_default_vals(self, counterpart_account_id=None):
liquidity_line_vals, counterpart_line_vals = (
super()._prepare_move_line_default_vals(counterpart_account_id)
)
if self.liquidity_account_id:
liquidity_line_vals.update(
{
"account_id": self.liquidity_account_id.id,
}
)
return [liquidity_line_vals, counterpart_line_vals]
75 changes: 75 additions & 0 deletions pos_payment_cash_change/models/pos_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from odoo import fields, models


class PosSession(models.Model):
_inherit = "pos.session"

def _prepare_account_bank_statement_line_vals(
self, session, sign, amount, reason, extras
):
res = super()._prepare_account_bank_statement_line_vals(
session, sign, amount, reason, extras
)
cash_method = session.payment_method_ids.filtered("is_cash_count")[:1]
if cash_method.change_account_id:
res["liquidity_account_id"] = cash_method.change_account_id.id
return res


class PoSOrder(models.Model):
_inherit = "pos.order"

def _process_payment_lines(self, pos_order, order, pos_session, draft):
res = super()._process_payment_lines(pos_order, order, pos_session, draft)
cash_method = pos_session.payment_method_ids.filtered("is_cash_count")[:1]
if self._condition_create_cash_change_payment_move(cash_method, draft):
self._process_cash_change_payments(
pos_order, order, pos_session, cash_method
)
return res

def _condition_create_cash_change_payment_move(self, cash_method, draft):
return bool(not draft and cash_method and cash_method.change_account_id)

def _prepare_account_bank_statement_line_vals(
self,
pos_session,
journal,
amount,
counterpart_account,
liquidity_account,
track_number,
):
return {
"pos_session_id": pos_session.id,
"journal_id": journal.id,
"amount": amount,
"date": fields.Date.context_today(self),
"payment_ref": self._get_cash_transfer_label(pos_session, track_number),
"counterpart_account_id": counterpart_account.id,
"liquidity_account_id": liquidity_account.id,
}

def _process_cash_change_payments(self, pos_order, order, pos_session, cash_method):
amount_total = pos_order["amount_total"]
tracking_number = order.tracking_number
journal = pos_session.cash_journal_id
counterpart_account_id = journal.default_account_id
liquidity_account_id = cash_method.change_account_id
statement_line_vals = self._prepare_account_bank_statement_line_vals(
pos_session,
journal,
amount_total,
counterpart_account_id,
liquidity_account_id,
tracking_number,
)
self.env["account.bank.statement.line"].create(statement_line_vals)

def _get_cash_transfer_label(self, pos_session, tracking_number):
"""Return translatable label for cash transfer."""
return self.env._(
"Cash transfer for session: %s - Order number: %s",
pos_session.name,
tracking_number,
)
9 changes: 9 additions & 0 deletions pos_payment_cash_change/models/pos_payment_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models


class PosPaymentMethod(models.Model):
_inherit = "pos.payment.method"

change_account_id = fields.Many2one(
comodel_name="account.account", string="Account for the Change"
)
3 changes: 3 additions & 0 deletions pos_payment_cash_change/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
6 changes: 6 additions & 0 deletions pos_payment_cash_change/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Go to Invoicing → Configuration → Journals.
- Create new journal with type `cash` for Cash Change Account.
- Open a journal or create a new journal with type `cash`.
- Add Cash Change Account in the field `Account for the Change`.

![Account for the Change](../static/desciption/cash_change_account.png)
2 changes: 2 additions & 0 deletions pos_payment_cash_change/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Trobz](https://www.trobz.com):
- Phan Hong Phuc </phucph@trobz.com/>
2 changes: 2 additions & 0 deletions pos_payment_cash_change/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows configuring an account to record cash changes given to customers in the Point of Sale (POS) system.
When a customer pays with cash and requires change, the system will automatically record the transaction in the specified cash change account.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading