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.)
|
||||
- Preserves tax calculations and reporting
|
||||
- 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
|
||||
|
||||
|
||||
@ -30,6 +30,11 @@
|
||||
'demo': [
|
||||
# 'demo/demo.xml',
|
||||
],
|
||||
'assets': {
|
||||
'point_of_sale._assets_pos': [
|
||||
'split_pendapatan_payment/static/src/app/**/*',
|
||||
],
|
||||
},
|
||||
'installable': True,
|
||||
'application': False,
|
||||
'auto_install': False,
|
||||
|
||||
@ -191,6 +191,10 @@ class PosSession(models.Model):
|
||||
return
|
||||
|
||||
target_account_id = sale_key[0]
|
||||
original_account = self.env['account.account'].browse(target_account_id)
|
||||
is_income_account = original_account.account_type in ('income', 'income_other')
|
||||
|
||||
if is_income_account:
|
||||
if is_discount_part:
|
||||
if payment.payment_method_id.discount_account_id:
|
||||
target_account_id = payment.payment_method_id.discount_account_id.id
|
||||
|
||||
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