fix: Use advance account from Reconciliation document for fetching Payment Entries
This commit is contained in:
parent
7591f1010b
commit
a06017c2c3
@ -106,6 +106,12 @@ class PaymentEntry(AccountsController):
|
|||||||
root_type == "Asset" and self.party_type == "Supplier"
|
root_type == "Asset" and self.party_type == "Supplier"
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
if self.unallocated_amount == 0:
|
||||||
|
for d in self.references:
|
||||||
|
if d.reference_doctype in ["Sales Order", "Purchase Order"]:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return
|
||||||
liability_account = get_party_account(
|
liability_account = get_party_account(
|
||||||
self.party_type, self.party, self.company, include_advance=True
|
self.party_type, self.party, self.company, include_advance=True
|
||||||
)[1]
|
)[1]
|
||||||
@ -1694,7 +1700,7 @@ def get_outstanding_on_journal_entry(name):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_reference_details(reference_doctype, reference_name, party_account_currency):
|
def get_reference_details(reference_doctype, reference_name, party_account_currency):
|
||||||
total_amount = outstanding_amount = exchange_rate = None
|
total_amount = outstanding_amount = exchange_rate = account = None
|
||||||
|
|
||||||
ref_doc = frappe.get_doc(reference_doctype, reference_name)
|
ref_doc = frappe.get_doc(reference_doctype, reference_name)
|
||||||
company_currency = ref_doc.get("company_currency") or erpnext.get_company_currency(
|
company_currency = ref_doc.get("company_currency") or erpnext.get_company_currency(
|
||||||
|
|||||||
@ -34,7 +34,7 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo
|
|||||||
filters: {
|
filters: {
|
||||||
"company": this.frm.doc.company,
|
"company": this.frm.doc.company,
|
||||||
"is_group": 0,
|
"is_group": 0,
|
||||||
"root_type": (this.frm.party_type == 'Customer') ? "Liability": "Asset"
|
"root_type": this.frm.doc.party_type == 'Customer' ? "Liability": "Asset"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -60,16 +60,7 @@ class PaymentReconciliation(Document):
|
|||||||
self.add_payment_entries(non_reconciled_payments)
|
self.add_payment_entries(non_reconciled_payments)
|
||||||
|
|
||||||
def get_payment_entries(self):
|
def get_payment_entries(self):
|
||||||
advance_accounts = []
|
party_account = [self.receivable_payable_account, self.default_advance_account]
|
||||||
if self.party_type == "Customer":
|
|
||||||
advance_accounts = frappe.db.get_list(
|
|
||||||
"Account", filters={"root_type": "Liability", "company": self.company}, pluck="name"
|
|
||||||
)
|
|
||||||
elif self.party_type == "Supplier":
|
|
||||||
advance_accounts = frappe.db.get_list(
|
|
||||||
"Account", filters={"root_type": "Asset", "company": self.company}, pluck="name"
|
|
||||||
)
|
|
||||||
party_account = [self.receivable_payable_account] + advance_accounts
|
|
||||||
|
|
||||||
order_doctype = "Sales Order" if self.party_type == "Customer" else "Purchase Order"
|
order_doctype = "Sales Order" if self.party_type == "Customer" else "Purchase Order"
|
||||||
condition = frappe._dict(
|
condition = frappe._dict(
|
||||||
|
|||||||
@ -33,8 +33,10 @@ from erpnext.accounts.utils import get_account_currency, get_fiscal_year
|
|||||||
from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_enabled
|
from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_enabled
|
||||||
from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
|
from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
|
||||||
from erpnext.buying.utils import check_on_hold_or_closed_status
|
from erpnext.buying.utils import check_on_hold_or_closed_status
|
||||||
from erpnext.controllers.accounts_controller import validate_account_head
|
from erpnext.controllers.accounts_controller import (
|
||||||
from erpnext.controllers.accounts_controller import make_advance_liability_entry
|
check_advance_liability_entry,
|
||||||
|
validate_account_head,
|
||||||
|
)
|
||||||
from erpnext.controllers.buying_controller import BuyingController
|
from erpnext.controllers.buying_controller import BuyingController
|
||||||
from erpnext.stock import get_warehouse_account_map
|
from erpnext.stock import get_warehouse_account_map
|
||||||
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import (
|
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import (
|
||||||
@ -581,11 +583,14 @@ class PurchaseInvoice(BuyingController):
|
|||||||
gl_entries = []
|
gl_entries = []
|
||||||
|
|
||||||
self.make_supplier_gl_entry(gl_entries)
|
self.make_supplier_gl_entry(gl_entries)
|
||||||
|
|
||||||
advance_payments_as_liability = frappe.db.get_value("Company", {"company_name": self.company}, "book_advance_payments_as_liability")
|
check_advance_liability_entry(
|
||||||
if advance_payments_as_liability:
|
gl_entries,
|
||||||
for advance_entry in self.advances:
|
company=self.company,
|
||||||
make_advance_liability_entry(gl_entries, advance_entry.reference_name, advance_entry.allocated_amount, invoice=self.name, party_type="Supplier")
|
advances=self.advances,
|
||||||
|
invoice=self.name,
|
||||||
|
party_type="Supplier",
|
||||||
|
)
|
||||||
|
|
||||||
self.make_item_gl_entries(gl_entries)
|
self.make_item_gl_entries(gl_entries)
|
||||||
self.make_precision_loss_gl_entry(gl_entries)
|
self.make_precision_loss_gl_entry(gl_entries)
|
||||||
|
|||||||
@ -1669,7 +1669,7 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin):
|
|||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
"Company",
|
"Company",
|
||||||
"_Test Company",
|
"_Test Company",
|
||||||
{"book_advance_payments_as_liability": 1, "default_advance_account": "Debtors - _TC"},
|
{"book_advance_payments_as_liability": 1, "default_advance_paid_account": "Debtors - _TC"},
|
||||||
)
|
)
|
||||||
pe = create_payment_entry(
|
pe = create_payment_entry(
|
||||||
company="_Test Company",
|
company="_Test Company",
|
||||||
@ -1722,6 +1722,7 @@ def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
|
|||||||
doc.assertEqual(expected_gle[i][0], gle.account)
|
doc.assertEqual(expected_gle[i][0], gle.account)
|
||||||
doc.assertEqual(expected_gle[i][1], gle.debit)
|
doc.assertEqual(expected_gle[i][1], gle.debit)
|
||||||
doc.assertEqual(expected_gle[i][2], gle.credit)
|
doc.assertEqual(expected_gle[i][2], gle.credit)
|
||||||
|
doc.assertEqual(getdate(expected_gle[i][3]), gle.posting_date)
|
||||||
|
|
||||||
|
|
||||||
def create_tax_witholding_category(category_name, company, account):
|
def create_tax_witholding_category(category_name, company, account):
|
||||||
|
|||||||
@ -32,8 +32,10 @@ from erpnext.assets.doctype.asset.depreciation import (
|
|||||||
reset_depreciation_schedule,
|
reset_depreciation_schedule,
|
||||||
reverse_depreciation_entry_made_after_disposal,
|
reverse_depreciation_entry_made_after_disposal,
|
||||||
)
|
)
|
||||||
from erpnext.controllers.accounts_controller import validate_account_head
|
from erpnext.controllers.accounts_controller import (
|
||||||
from erpnext.controllers.accounts_controller import make_advance_liability_entry
|
check_advance_liability_entry,
|
||||||
|
validate_account_head,
|
||||||
|
)
|
||||||
from erpnext.controllers.selling_controller import SellingController
|
from erpnext.controllers.selling_controller import SellingController
|
||||||
from erpnext.projects.doctype.timesheet.timesheet import get_projectwise_timesheet_data
|
from erpnext.projects.doctype.timesheet.timesheet import get_projectwise_timesheet_data
|
||||||
from erpnext.setup.doctype.company.company import update_company_current_month_sales
|
from erpnext.setup.doctype.company.company import update_company_current_month_sales
|
||||||
@ -1065,11 +1067,14 @@ class SalesInvoice(SellingController):
|
|||||||
gl_entries = []
|
gl_entries = []
|
||||||
|
|
||||||
self.make_customer_gl_entry(gl_entries)
|
self.make_customer_gl_entry(gl_entries)
|
||||||
|
|
||||||
advance_payments_as_liability = frappe.db.get_value("Company", {"company_name": self.company}, "book_advance_payments_as_liability")
|
check_advance_liability_entry(
|
||||||
if advance_payments_as_liability:
|
gl_entries,
|
||||||
for advance_entry in self.advances:
|
company=self.company,
|
||||||
make_advance_liability_entry(gl_entries, advance_entry.reference_name, advance_entry.allocated_amount, invoice=self.name, party_type="Customer")
|
advances=self.advances,
|
||||||
|
invoice=self.name,
|
||||||
|
party_type="Customer",
|
||||||
|
)
|
||||||
|
|
||||||
self.make_tax_gl_entries(gl_entries)
|
self.make_tax_gl_entries(gl_entries)
|
||||||
self.make_exchange_gain_loss_gl_entries(gl_entries)
|
self.make_exchange_gain_loss_gl_entries(gl_entries)
|
||||||
|
|||||||
@ -3320,7 +3320,10 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
"Company",
|
"Company",
|
||||||
"_Test Company",
|
"_Test Company",
|
||||||
{"book_advance_payments_as_liability": 1, "default_advance_account": "Creditors - _TC"},
|
{
|
||||||
|
"book_advance_payments_as_liability": 1,
|
||||||
|
"default_advance_received_account": "Creditors - _TC",
|
||||||
|
},
|
||||||
)
|
)
|
||||||
pe = create_payment_entry(
|
pe = create_payment_entry(
|
||||||
company="_Test Company",
|
company="_Test Company",
|
||||||
@ -3408,6 +3411,7 @@ def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
|
|||||||
doc.assertEqual(expected_gle[i][0], gle.account)
|
doc.assertEqual(expected_gle[i][0], gle.account)
|
||||||
doc.assertEqual(expected_gle[i][1], gle.debit)
|
doc.assertEqual(expected_gle[i][1], gle.debit)
|
||||||
doc.assertEqual(expected_gle[i][2], gle.credit)
|
doc.assertEqual(expected_gle[i][2], gle.credit)
|
||||||
|
doc.assertEqual(getdate(expected_gle[i][3]), gle.posting_date)
|
||||||
|
|
||||||
|
|
||||||
def create_sales_invoice(**args):
|
def create_sales_invoice(**args):
|
||||||
|
|||||||
@ -429,7 +429,12 @@ def get_party_advance_account(party_type, party, company):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not account:
|
if not account:
|
||||||
account = frappe.get_cached_value("Company", company, "default_advance_account")
|
account_name = (
|
||||||
|
"default_advance_received_account"
|
||||||
|
if party_type == "Customer"
|
||||||
|
else "default_advance_paid_account"
|
||||||
|
)
|
||||||
|
account = frappe.get_cached_value("Company", company, account_name)
|
||||||
|
|
||||||
return account
|
return account
|
||||||
|
|
||||||
|
|||||||
@ -2908,16 +2908,6 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil
|
|||||||
parent.create_stock_reservation_entries()
|
parent.create_stock_reservation_entries()
|
||||||
|
|
||||||
|
|
||||||
@erpnext.allow_regional
|
|
||||||
def validate_regional(doc):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@erpnext.allow_regional
|
|
||||||
def validate_einvoice_fields(doc):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def make_advance_liability_entry(
|
def make_advance_liability_entry(
|
||||||
gl_entries, pe, allocated_amount, invoice, party_type, references=False
|
gl_entries, pe, allocated_amount, invoice, party_type, references=False
|
||||||
):
|
):
|
||||||
@ -2990,3 +2980,33 @@ def make_advance_liability_entry(
|
|||||||
item=invoice,
|
item=invoice,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def check_advance_liability_entry(gl_entries, company, advances, invoice, party_type):
|
||||||
|
advance_payments_as_liability = frappe.db.get_value(
|
||||||
|
"Company", {"company_name": company}, "book_advance_payments_as_liability"
|
||||||
|
)
|
||||||
|
if advance_payments_as_liability:
|
||||||
|
for advance_entry in advances:
|
||||||
|
make_advance_liability_entry(
|
||||||
|
gl_entries,
|
||||||
|
advance_entry.reference_name,
|
||||||
|
advance_entry.allocated_amount,
|
||||||
|
invoice=invoice,
|
||||||
|
party_type=party_type,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@erpnext.allow_regional
|
||||||
|
def validate_regional(doc):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@erpnext.allow_regional
|
||||||
|
def validate_einvoice_fields(doc):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@erpnext.allow_regional
|
||||||
|
def update_gl_dict_with_regional_fields(doc, gl_dict):
|
||||||
|
pass
|
||||||
|
|||||||
@ -227,7 +227,8 @@ erpnext.company.setup_queries = function(frm) {
|
|||||||
["asset_received_but_not_billed", {"account_type": "Asset Received But Not Billed"}],
|
["asset_received_but_not_billed", {"account_type": "Asset Received But Not Billed"}],
|
||||||
["unrealized_profit_loss_account", {"root_type": ["in", ["Liability", "Asset"]]}],
|
["unrealized_profit_loss_account", {"root_type": ["in", ["Liability", "Asset"]]}],
|
||||||
["default_provisional_account", {"root_type": ["in", ["Liability", "Asset"]]}],
|
["default_provisional_account", {"root_type": ["in", ["Liability", "Asset"]]}],
|
||||||
["default_advance_account", {"root_type": ["in", ["Liability", "Asset"]]}],
|
["default_advance_received_account", {"root_type": "Liability"}],
|
||||||
|
["default_advance_paid_account", {"root_type": "Asset"}],
|
||||||
], function(i, v) {
|
], function(i, v) {
|
||||||
erpnext.company.set_custom_query(frm, v);
|
erpnext.company.set_custom_query(frm, v);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -72,7 +72,8 @@
|
|||||||
"default_finance_book",
|
"default_finance_book",
|
||||||
"advance_payments_section",
|
"advance_payments_section",
|
||||||
"book_advance_payments_as_liability",
|
"book_advance_payments_as_liability",
|
||||||
"default_advance_account",
|
"default_advance_received_account",
|
||||||
|
"default_advance_paid_account",
|
||||||
"column_break_cui0",
|
"column_break_cui0",
|
||||||
"auto_accounting_for_stock_settings",
|
"auto_accounting_for_stock_settings",
|
||||||
"enable_perpetual_inventory",
|
"enable_perpetual_inventory",
|
||||||
@ -716,9 +717,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:doc.book_advance_payments_as_liability",
|
"depends_on": "eval:doc.book_advance_payments_as_liability",
|
||||||
"fieldname": "default_advance_account",
|
"fieldname": "default_advance_received_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Default Account",
|
"label": "Default Advance Received Account",
|
||||||
|
"mandatory_depends_on": "book_advance_payments_as_liability",
|
||||||
|
"options": "Account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.book_advance_payments_as_liability",
|
||||||
|
"fieldname": "default_advance_paid_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Default Advance Paid Account",
|
||||||
"mandatory_depends_on": "book_advance_payments_as_liability",
|
"mandatory_depends_on": "book_advance_payments_as_liability",
|
||||||
"options": "Account"
|
"options": "Account"
|
||||||
}
|
}
|
||||||
@ -728,7 +737,7 @@
|
|||||||
"image_field": "company_logo",
|
"image_field": "company_logo",
|
||||||
"is_tree": 1,
|
"is_tree": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-06-05 14:12:37.946451",
|
"modified": "2023-06-12 12:51:12.007410",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Company",
|
"name": "Company",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user