feat: Prevent non-income account overrides and strip taxes from POS down payments applied from sale orders.
This commit is contained in:
parent
74c25332e1
commit
eace0d7625
@ -17,6 +17,8 @@ For example, if a session has sales paid with both cash and credit card, instead
|
|||||||
- Works with all payment methods (cash, bank transfers, credit cards, etc.)
|
- Works with all payment methods (cash, bank transfers, credit cards, etc.)
|
||||||
- Preserves tax calculations and reporting
|
- Preserves tax calculations and reporting
|
||||||
- Allows linking specific income accounts to payment methods
|
- Allows linking specific income accounts to payment methods
|
||||||
|
- Prevents down payments from incorrectly overriding non-income accounts (e.g. liabilities)
|
||||||
|
- Strips taxes natively when applying down payments directly from a Sales Order in POS
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,11 @@
|
|||||||
'demo': [
|
'demo': [
|
||||||
# 'demo/demo.xml',
|
# 'demo/demo.xml',
|
||||||
],
|
],
|
||||||
|
'assets': {
|
||||||
|
'point_of_sale._assets_pos': [
|
||||||
|
'split_pendapatan_payment/static/src/app/**/*',
|
||||||
|
],
|
||||||
|
},
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'application': False,
|
'application': False,
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
|
|||||||
@ -191,15 +191,19 @@ class PosSession(models.Model):
|
|||||||
return
|
return
|
||||||
|
|
||||||
target_account_id = sale_key[0]
|
target_account_id = sale_key[0]
|
||||||
if is_discount_part:
|
original_account = self.env['account.account'].browse(target_account_id)
|
||||||
if payment.payment_method_id.discount_account_id:
|
is_income_account = original_account.account_type in ('income', 'income_other')
|
||||||
target_account_id = payment.payment_method_id.discount_account_id.id
|
|
||||||
elif payment.payment_method_id.income_account_id:
|
if is_income_account:
|
||||||
target_account_id = payment.payment_method_id.income_account_id.id
|
if is_discount_part:
|
||||||
else:
|
if payment.payment_method_id.discount_account_id:
|
||||||
if payment.payment_method_id.income_account_id:
|
target_account_id = payment.payment_method_id.discount_account_id.id
|
||||||
target_account_id = payment.payment_method_id.income_account_id.id
|
elif payment.payment_method_id.income_account_id:
|
||||||
|
target_account_id = payment.payment_method_id.income_account_id.id
|
||||||
|
else:
|
||||||
|
if payment.payment_method_id.income_account_id:
|
||||||
|
target_account_id = payment.payment_method_id.income_account_id.id
|
||||||
|
|
||||||
if not target_account_id:
|
if not target_account_id:
|
||||||
raise UserError(_(
|
raise UserError(_(
|
||||||
'No income account found for payment method "%s".\n'
|
'No income account found for payment method "%s".\n'
|
||||||
|
|||||||
27
static/src/app/sale_order_management_screen.js
Normal file
27
static/src/app/sale_order_management_screen.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/** @odoo-module */
|
||||||
|
|
||||||
|
import { SaleOrderManagementScreen } from "@pos_sale/app/order_management_screen/sale_order_management_screen/sale_order_management_screen";
|
||||||
|
import { patch } from "@web/core/utils/patch";
|
||||||
|
|
||||||
|
patch(SaleOrderManagementScreen.prototype, {
|
||||||
|
_createDownpaymentLines(sale_order, total_down_payment, clickedOrder, down_payment_product) {
|
||||||
|
const order = this.pos.get_order();
|
||||||
|
const linesBefore = order.get_orderlines().length;
|
||||||
|
|
||||||
|
// Call the original method to create the lines
|
||||||
|
super._createDownpaymentLines(sale_order, total_down_payment, clickedOrder, down_payment_product);
|
||||||
|
|
||||||
|
const linesAfter = order.get_orderlines().length;
|
||||||
|
const orderlines = order.get_orderlines();
|
||||||
|
|
||||||
|
// Find the down payment lines that were just added and remove their taxes
|
||||||
|
for (let i = linesBefore; i < linesAfter; i++) {
|
||||||
|
let line = orderlines[i];
|
||||||
|
if (line.get_product().id === down_payment_product.id) {
|
||||||
|
const priceWithTax = line.get_price_with_tax();
|
||||||
|
line.tax_ids = [];
|
||||||
|
line.set_unit_price(priceWithTax);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user