refactor: Redo workflows
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json
index 6224d40..d7b6a19 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.json
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json
@@ -19,6 +19,7 @@
"party_type",
"party",
"party_name",
+ "book_advance_payments_in_separate_party_account",
"column_break_11",
"bank_account",
"party_bank_account",
@@ -735,12 +736,21 @@
"fieldname": "get_outstanding_orders",
"fieldtype": "Button",
"label": "Get Outstanding Orders"
+ },
+ {
+ "default": "0",
+ "fetch_from": "company.book_advance_payments_in_separate_party_account",
+ "fieldname": "book_advance_payments_in_separate_party_account",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "label": "Book Advance Payments in Separate Party Account",
+ "read_only": 1
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
- "modified": "2023-06-19 11:38:04.387219",
+ "modified": "2023-06-23 18:07:38.023010",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Entry",
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index f6c6bce..8141d05 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -21,7 +21,11 @@
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import (
get_party_tax_withholding_details,
)
-from erpnext.accounts.general_ledger import make_gl_entries, process_gl_map
+from erpnext.accounts.general_ledger import (
+ make_gl_entries,
+ make_reverse_gl_entries,
+ process_gl_map,
+)
from erpnext.accounts.party import get_party_account
from erpnext.accounts.utils import get_account_currency, get_balance_on, get_outstanding_invoices
from erpnext.controllers.accounts_controller import (
@@ -88,17 +92,14 @@
if self.difference_amount:
frappe.throw(_("Difference Amount must be zero"))
self.make_gl_entries()
+ self.make_advance_gl_entries()
self.update_outstanding_amounts()
self.update_advance_paid()
self.update_payment_schedule()
self.set_status()
def set_liability_account(self):
- book_advance_payments_as_liability = frappe.get_value(
- "Company", {"company_name": self.company}, "book_advance_payments_as_liability"
- )
-
- if not book_advance_payments_as_liability:
+ if not self.book_advance_payments_in_separate_party_account:
return
account_type = frappe.get_value(
@@ -139,6 +140,7 @@
"Repost Payment Ledger Items",
)
self.make_gl_entries(cancel=1)
+ self.make_advance_gl_entries(cancel=1)
self.update_outstanding_amounts()
self.update_advance_paid()
self.delink_advance_entry_references()
@@ -212,7 +214,8 @@
"party_account": self.paid_from if self.payment_type == "Receive" else self.paid_to,
"get_outstanding_invoices": True,
"get_orders_to_be_billed": True,
- }
+ },
+ validate=True,
)
# Group latest_references by (voucher_type, voucher_no)
@@ -417,6 +420,13 @@
elif self.party_type == "Employee":
ref_party_account = ref_doc.payable_account
+ if ref_party_account != self.party_account:
+ frappe.throw(
+ _("{0} {1} is associated with {2}, but Party Account is {3}").format(
+ d.reference_doctype, d.reference_name, ref_party_account, self.party_account
+ )
+ )
+
if ref_doc.doctype == "Purchase Invoice" and ref_doc.get("on_hold"):
frappe.throw(
_("{0} {1} is on hold").format(d.reference_doctype, d.reference_name),
@@ -952,7 +962,7 @@
else:
against_account = self.paid_from
- party_dict = self.get_gl_dict(
+ party_gl_dict = self.get_gl_dict(
{
"account": self.party_account,
"party_type": self.party_type,
@@ -968,32 +978,21 @@
"credit" if erpnext.get_party_account_type(self.party_type) == "Receivable" else "debit"
)
- is_advance = self.is_advance_entry()
-
for d in self.get("references"):
- gle = party_dict.copy()
- book_advance_payments_as_liability = frappe.get_value(
- "Company", {"company_name": self.company}, "book_advance_payments_as_liability"
- )
- if (
- d.reference_doctype in ["Sales Invoice", "Purchase Invoice"]
- and book_advance_payments_as_liability
- and is_advance
- ):
- self.make_invoice_liability_entry(gl_entries, d)
- against_voucher_type = "Payment Entry"
- against_voucher = self.name
- else:
- against_voucher_type = d.reference_doctype
- against_voucher = d.reference_name
+ cost_center = self.cost_center
+ if d.reference_doctype == "Sales Invoice" and not cost_center:
+ cost_center = frappe.db.get_value(d.reference_doctype, d.reference_name, "cost_center")
+
+ gle = party_gl_dict.copy()
allocated_amount_in_company_currency = self.calculate_base_allocated_amount_for_reference(d)
gle.update(
{
dr_or_cr: allocated_amount_in_company_currency,
dr_or_cr + "_in_account_currency": d.allocated_amount,
- "against_voucher_type": against_voucher_type,
- "against_voucher": against_voucher,
+ "against_voucher_type": d.reference_doctype,
+ "against_voucher": d.reference_name,
+ "cost_center": cost_center,
}
)
gl_entries.append(gle)
@@ -1002,25 +1001,44 @@
exchange_rate = self.get_exchange_rate()
base_unallocated_amount = self.unallocated_amount * exchange_rate
- gle = party_dict.copy()
+ gle = party_gl_dict.copy()
gle.update(
{
dr_or_cr + "_in_account_currency": self.unallocated_amount,
dr_or_cr: base_unallocated_amount,
- "against_voucher_type": "Payment Entry",
- "against_voucher": self.name,
}
)
gl_entries.append(gle)
- def is_advance_entry(self):
- for d in self.get("references"):
- if d.reference_doctype in ("Sales Order", "Purchase Order"):
- return True
- if self.unallocated_amount > 0:
- return True
- return False
+ def make_advance_gl_entries(self, against_voucher_type=None, against_voucher=None, cancel=0):
+ if self.book_advance_payments_in_separate_party_account:
+ gl_entries = []
+ for d in self.get("references"):
+ if d.reference_doctype in ("Sales Invoice", "Purchase Invoice"):
+ if not (against_voucher_type and against_voucher) or (
+ d.reference_doctype == against_voucher_type and d.reference_name == against_voucher
+ ):
+ self.make_invoice_liability_entry(gl_entries, d)
+
+ if cancel:
+ for entry in gl_entries:
+ frappe.db.set_value(
+ "GL Entry",
+ {
+ "voucher_no": self.name,
+ "voucher_type": self.doctype,
+ "voucher_detail_no": entry.voucher_detail_no,
+ "against_voucher_type": entry.against_voucher_type,
+ "against_voucher": entry.against_voucher,
+ },
+ "is_cancelled",
+ 1,
+ )
+
+ make_reverse_gl_entries(gl_entries=gl_entries, partial_cancel=True)
+ else:
+ make_gl_entries(gl_entries)
def make_invoice_liability_entry(self, gl_entries, invoice):
args_dict = {
@@ -1030,6 +1048,7 @@
"cost_center": self.cost_center,
"voucher_type": "Payment Entry",
"voucher_no": self.name,
+ "voucher_detail_no": invoice.name,
}
dr_or_cr = "credit" if invoice.reference_doctype == "Sales Invoice" else "debit"
@@ -1391,7 +1410,7 @@
@frappe.whitelist()
-def get_outstanding_reference_documents(args):
+def get_outstanding_reference_documents(args, validate=False):
if isinstance(args, str):
args = json.loads(args)
@@ -1511,13 +1530,14 @@
elif args.get("get_orders_to_be_billed"):
ref_document_type = "orders"
- frappe.msgprint(
- _(
- "No outstanding {0} found for the {1} {2} which qualify the filters you have specified."
- ).format(
- ref_document_type, _(args.get("party_type")).lower(), frappe.bold(args.get("party"))
+ if not validate:
+ frappe.msgprint(
+ _(
+ "No outstanding {0} found for the {1} {2} which qualify the filters you have specified."
+ ).format(
+ ref_document_type, _(args.get("party_type")).lower(), frappe.bold(args.get("party"))
+ )
)
- )
return data
diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
index e9cc390..8e2f0e5 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
+++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
@@ -12,16 +12,12 @@
from erpnext.accounts.doctype.process_payment_reconciliation.process_payment_reconciliation import (
is_any_doc_running,
)
-from erpnext.accounts.general_ledger import make_gl_entries
from erpnext.accounts.utils import (
QueryPaymentLedger,
get_outstanding_invoices,
reconcile_against_document,
)
-from erpnext.controllers.accounts_controller import (
- get_advance_payment_entries,
- make_advance_liability_entry,
-)
+from erpnext.controllers.accounts_controller import get_advance_payment_entries
class PaymentReconciliation(Document):
@@ -355,15 +351,6 @@
for row in self.get("allocation"):
reconciled_entry = []
if row.invoice_number and row.allocated_amount:
- if (
- row.invoice_type in ["Sales Invoice", "Purchase Invoice"]
- and row.reference_type == "Payment Entry"
- ):
- gl_entries = []
- make_advance_liability_entry(
- gl_entries, row.reference_name, row.allocated_amount, row.invoice_number, self.party_type
- )
- make_gl_entries(gl_entries)
if row.reference_type in ["Sales Invoice", "Purchase Invoice"]:
reconciled_entry = dr_or_cr_notes
else:
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 68fa7bf..230a8b3 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -33,10 +33,7 @@
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.buying.utils import check_on_hold_or_closed_status
-from erpnext.controllers.accounts_controller import (
- check_advance_liability_entry,
- validate_account_head,
-)
+from erpnext.controllers.accounts_controller import validate_account_head
from erpnext.controllers.buying_controller import BuyingController
from erpnext.stock import get_warehouse_account_map
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import (
@@ -576,15 +573,6 @@
gl_entries = []
self.make_supplier_gl_entry(gl_entries)
-
- check_advance_liability_entry(
- gl_entries,
- company=self.company,
- advances=self.advances,
- invoice=self.name,
- party_type="Supplier",
- )
-
self.make_item_gl_entries(gl_entries)
self.make_precision_loss_gl_entry(gl_entries)
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 569a48a..8c96480 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -1664,10 +1664,17 @@
self.assertTrue(return_pi.docstatus == 1)
- def test_advance_entries_as_liability(self):
+ def test_advance_entries_as_asset(self):
from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_entry
- set_advance_flag(company="_Test Company", flag=1, default_account="Debtors - _TC")
+ account = create_account(
+ parent_account="Current Assets - _TC",
+ account_name="Advances Paid",
+ company="_Test Company",
+ account_type="Receivable",
+ )
+
+ set_advance_flag(company="_Test Company", flag=1, default_account=account)
pe = create_payment_entry(
company="_Test Company",
@@ -1701,13 +1708,15 @@
# Check GL Entry against payment doctype
expected_gle = [
+ ["Advances Paid - _TC", 0.0, 500, nowdate()],
["Cash - _TC", 0.0, 500, nowdate()],
["Creditors - _TC", 500, 0.0, nowdate()],
["Creditors - _TC", 500, 0.0, nowdate()],
- ["Debtors - _TC", 0.0, 500, nowdate()],
]
check_gl_entries(self, pe.name, expected_gle, nowdate(), voucher_type="Payment Entry")
+
+ pi.load_from_db()
self.assertEqual(pi.outstanding_amount, 500)
set_advance_flag(company="_Test Company", flag=0, default_account="")
@@ -1733,7 +1742,7 @@
"Company",
company,
{
- "book_advance_payments_as_liability": flag,
+ "book_advance_payments_in_separate_party_account": flag,
"default_advance_paid_account": default_account,
},
)
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index d2cd95f..25553cf 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -32,10 +32,7 @@
reset_depreciation_schedule,
reverse_depreciation_entry_made_after_disposal,
)
-from erpnext.controllers.accounts_controller import (
- check_advance_liability_entry,
- validate_account_head,
-)
+from erpnext.controllers.accounts_controller import validate_account_head
from erpnext.controllers.selling_controller import SellingController
from erpnext.projects.doctype.timesheet.timesheet import get_projectwise_timesheet_data
from erpnext.setup.doctype.company.company import update_company_current_month_sales
@@ -1055,21 +1052,12 @@
elif self.docstatus == 2 and cint(self.update_stock) and cint(auto_accounting_for_stock):
make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
- def get_gl_entries(self, warehouse_account=None):
+ def get_gl_entries(self):
from erpnext.accounts.general_ledger import merge_similar_entries
gl_entries = []
self.make_customer_gl_entry(gl_entries)
-
- check_advance_liability_entry(
- gl_entries,
- company=self.company,
- advances=self.advances,
- invoice=self.name,
- party_type="Customer",
- )
-
self.make_tax_gl_entries(gl_entries)
self.make_exchange_gain_loss_gl_entries(gl_entries)
self.make_internal_transfer_gl_entries(gl_entries)
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index e8e81fd..69ddfaa 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -6,7 +6,6 @@
import frappe
from frappe.model.dynamic_links import get_dynamic_link_map
-from frappe.model.naming import make_autoname
from frappe.tests.utils import change_settings
from frappe.utils import add_days, flt, getdate, nowdate, today
@@ -35,7 +34,6 @@
get_serial_nos_from_bundle,
make_serial_batch_bundle,
)
-from erpnext.stock.doctype.serial_no.serial_no import SerialNoWarehouseError
from erpnext.stock.doctype.stock_entry.test_stock_entry import (
get_qty_after_transaction,
make_stock_entry,
@@ -3314,7 +3312,14 @@
def test_advance_entries_as_liability(self):
from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_entry
- set_advance_flag(company="_Test Company", flag=1, default_account="Creditors - _TC")
+ account = create_account(
+ parent_account="Current Liabilities - _TC",
+ account_name="Advances Received",
+ company="_Test Company",
+ account_type="Receivable",
+ )
+
+ set_advance_flag(company="_Test Company", flag=1, default_account=account)
pe = create_payment_entry(
company="_Test Company",
@@ -3347,13 +3352,15 @@
# Check GL Entry against payment doctype
expected_gle = [
+ ["Advances Received - _TC", 500, 0.0, nowdate()],
["Cash - _TC", 1000, 0.0, nowdate()],
- ["Creditors - _TC", 500, 0.0, nowdate()],
["Debtors - _TC", 0.0, 1000, nowdate()],
["Debtors - _TC", 0.0, 500, nowdate()],
]
check_gl_entries(self, pe.name, expected_gle, nowdate(), voucher_type="Payment Entry")
+
+ si.load_from_db()
self.assertEqual(si.outstanding_amount, 0)
set_advance_flag(company="_Test Company", flag=0, default_account="")
@@ -3364,7 +3371,7 @@
"Company",
company,
{
- "book_advance_payments_as_liability": flag,
+ "book_advance_payments_in_separate_party_account": flag,
"default_advance_received_account": default_account,
},
)
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index a0954a9..22f3959 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -501,7 +501,12 @@
def make_reverse_gl_entries(
- gl_entries=None, voucher_type=None, voucher_no=None, adv_adj=False, update_outstanding="Yes"
+ gl_entries=None,
+ voucher_type=None,
+ voucher_no=None,
+ adv_adj=False,
+ update_outstanding="Yes",
+ partial_cancel=False,
):
"""
Get original gl entries of the voucher
@@ -528,7 +533,8 @@
is_opening = any(d.get("is_opening") == "Yes" for d in gl_entries)
validate_against_pcv(is_opening, gl_entries[0]["posting_date"], gl_entries[0]["company"])
- set_as_cancel(gl_entries[0]["voucher_type"], gl_entries[0]["voucher_no"])
+ if not partial_cancel:
+ set_as_cancel(gl_entries[0]["voucher_type"], gl_entries[0]["voucher_no"])
for entry in gl_entries:
new_gle = copy.deepcopy(entry)
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index f92e2c7..5c256b7 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -474,6 +474,7 @@
doc = frappe.get_doc(entry.voucher_type, entry.voucher_no)
gl_map = doc.build_gl_map()
create_payment_ledger_entry(gl_map, update_outstanding="No", cancel=0, adv_adj=1)
+ doc.make_advance_gl_entries(entry.against_voucher_type, entry.against_voucher)
# Only update outstanding for newly linked vouchers
for entry in entries:
@@ -731,8 +732,9 @@
for pe in linked_pe:
try:
- pe_doc = frappe.get_doc("Payment Entry", pe)
+ pe_doc = frappe.get_doc("Payment Entry", pe, cache=True)
pe_doc.set_amounts()
+ pe_doc.make_advance_gl_entries(against_voucher_type=ref_type, against_voucher=ref_no, cancel=1)
pe_doc.clear_unallocated_reference_document_rows()
pe_doc.validate_payment_type_with_outstanding()
except Exception as e:
diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js
index a5bf4b2..c9ac279 100644
--- a/erpnext/buying/doctype/supplier/supplier.js
+++ b/erpnext/buying/doctype/supplier/supplier.js
@@ -22,7 +22,8 @@
let d = locals[cdt][cdn];
return {
filters: {
- "account_type": "Receivable",
+ "account_type": "Payable",
+ "root_type": "Asset",
"company": d.company,
"is_group": 0
}
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 02fef4d..0d9ab64 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -756,6 +756,7 @@
"party": None,
"project": self.get("project"),
"post_net_value": args.get("post_net_value"),
+ "voucher_detail_no": args.get("voucher_detail_no"),
}
)
@@ -2915,82 +2916,82 @@
parent.create_stock_reservation_entries()
-def make_advance_liability_entry(
- gl_entries, pe, allocated_amount, invoice, party_type, references=False
-):
- pe = frappe.get_doc("Payment Entry", pe)
- if party_type == "Customer":
- invoice = frappe.get_doc("Sales Invoice", invoice)
- account = pe.paid_from
- dr_or_cr = "debit"
- rev = "credit"
- against = invoice.debit_to
- party = invoice.customer
- else:
- invoice = frappe.get_doc("Purchase Invoice", invoice)
- account = pe.paid_to
- dr_or_cr = "credit"
- rev = "debit"
- against = invoice.credit_to
- party = invoice.supplier
- gl_entries.append(
- pe.get_gl_dict(
- {
- "account": account,
- "party_type": party_type,
- "party": party,
- "due_date": invoice.due_date,
- "against": against,
- dr_or_cr: allocated_amount,
- dr_or_cr + "_in_account_currency": allocated_amount,
- rev: 0,
- rev + "_in_account_currency": 0,
- "cost_center": invoice.cost_center,
- "project": invoice.project,
- "against_voucher_type": "Payment Entry",
- "against_voucher": pe.name,
- },
- invoice.party_account_currency,
- item=pe,
- )
- )
+# def make_advance_liability_entry(
+# gl_entries, pe, allocated_amount, invoice, party_type
+# ):
+# pe = frappe.get_doc("Payment Entry", pe)
+# if party_type == "Customer":
+# invoice = frappe.get_doc("Sales Invoice", invoice)
+# account = pe.paid_from
+# dr_or_cr = "debit"
+# rev = "credit"
+# against = invoice.debit_to
+# party = invoice.customer
+# else:
+# invoice = frappe.get_doc("Purchase Invoice", invoice)
+# account = pe.paid_to
+# dr_or_cr = "credit"
+# rev = "debit"
+# against = invoice.credit_to
+# party = invoice.supplier
+# gl_entries.append(
+# pe.get_gl_dict(
+# {
+# "account": account,
+# "party_type": party_type,
+# "party": party,
+# "due_date": invoice.due_date,
+# "against": against,
+# dr_or_cr: allocated_amount,
+# dr_or_cr + "_in_account_currency": allocated_amount,
+# rev: 0,
+# rev + "_in_account_currency": 0,
+# "cost_center": invoice.cost_center,
+# "project": invoice.project,
+# "against_voucher_type": "Payment Entry",
+# "against_voucher": pe.name,
+# },
+# invoice.party_account_currency,
+# item=pe,
+# )
+# )
- (dr_or_cr, rev) = ("credit", "debit") if party_type == "Customer" else ("debit", "credit")
- gl_entries.append(
- pe.get_gl_dict(
- {
- "account": against,
- "party_type": party_type,
- "party": party,
- "due_date": invoice.due_date,
- dr_or_cr: allocated_amount,
- dr_or_cr + "_in_account_currency": allocated_amount,
- rev: 0,
- rev + "_in_account_currency": 0,
- "cost_center": invoice.cost_center,
- "project": invoice.project,
- "against_voucher_type": invoice.doctype,
- "against_voucher": invoice.name,
- },
- invoice.party_account_currency,
- item=pe,
- )
- )
+# (dr_or_cr, rev) = ("credit", "debit") if party_type == "Customer" else ("debit", "credit")
+# gl_entries.append(
+# pe.get_gl_dict(
+# {
+# "account": against,
+# "party_type": party_type,
+# "party": party,
+# "due_date": invoice.due_date,
+# dr_or_cr: allocated_amount,
+# dr_or_cr + "_in_account_currency": allocated_amount,
+# rev: 0,
+# rev + "_in_account_currency": 0,
+# "cost_center": invoice.cost_center,
+# "project": invoice.project,
+# "against_voucher_type": invoice.doctype,
+# "against_voucher": invoice.name,
+# },
+# invoice.party_account_currency,
+# item=pe,
+# )
+# )
-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,
- )
+# 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
diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js
index 408e89b..c3bd753 100644
--- a/erpnext/selling/doctype/customer/customer.js
+++ b/erpnext/selling/doctype/customer/customer.js
@@ -39,7 +39,8 @@
let d = locals[cdt][cdn];
return {
filters: {
- "account_type": 'Payable',
+ "account_type": 'Receivable',
+ "root_type": "Liability",
"company": d.company,
"is_group": 0
}
diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js
index 089e20d..3335387 100644
--- a/erpnext/setup/doctype/company/company.js
+++ b/erpnext/setup/doctype/company/company.js
@@ -227,8 +227,8 @@
["asset_received_but_not_billed", {"account_type": "Asset Received But Not Billed"}],
["unrealized_profit_loss_account", {"root_type": ["in", ["Liability", "Asset"]]}],
["default_provisional_account", {"root_type": ["in", ["Liability", "Asset"]]}],
- ["default_advance_received_account", {"account_type": "Payable"}],
- ["default_advance_paid_account", {"account_type": "Receivable"}],
+ ["default_advance_received_account", {"root_type": "Liability", "account_type": "Receivable"}],
+ ["default_advance_paid_account", {"root_type": "Asset", "account_type": "Payable"}],
], function(i, v) {
erpnext.company.set_custom_query(frm, v);
});
diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json
index 611e2ab..6292ad7 100644
--- a/erpnext/setup/doctype/company/company.json
+++ b/erpnext/setup/doctype/company/company.json
@@ -71,7 +71,7 @@
"cost_center",
"default_finance_book",
"advance_payments_section",
- "book_advance_payments_as_liability",
+ "book_advance_payments_in_separate_party_account",
"column_break_fwcf",
"default_advance_received_account",
"default_advance_paid_account",
@@ -701,19 +701,12 @@
"options": "Account"
},
{
- "default": "0",
- "description": "Enabling this option will allow you to record - <br><br> 1. Advances Received in a <b>Liability Account</b> instead of the <b>Receivable Account</b><br><br>2. Advances Paid in an <b>Asset Account</b> instead of the <b> Payable Account</b>",
- "fieldname": "book_advance_payments_as_liability",
- "fieldtype": "Check",
- "label": "Book Advance Payments in Separate Party Account"
- },
- {
"fieldname": "advance_payments_section",
"fieldtype": "Section Break",
"label": "Advance Payments"
},
{
- "depends_on": "eval:doc.book_advance_payments_as_liability",
+ "depends_on": "eval:doc.book_advance_payments_in_separate_party_account",
"fieldname": "default_advance_received_account",
"fieldtype": "Link",
"label": "Default Advance Received Account",
@@ -721,7 +714,7 @@
"options": "Account"
},
{
- "depends_on": "eval:doc.book_advance_payments_as_liability",
+ "depends_on": "eval:doc.book_advance_payments_in_separate_party_account",
"fieldname": "default_advance_paid_account",
"fieldtype": "Link",
"label": "Default Advance Paid Account",
@@ -731,6 +724,13 @@
{
"fieldname": "column_break_fwcf",
"fieldtype": "Column Break"
+ },
+ {
+ "default": "0",
+ "description": "Enabling this option will allow you to record - <br><br> 1. Advances Received in a <b>Liability Account</b> instead of the <b>Asset Account</b><br><br>2. Advances Paid in an <b>Asset Account</b> instead of the <b> Liability Account</b>",
+ "fieldname": "book_advance_payments_in_separate_party_account",
+ "fieldtype": "Check",
+ "label": "Book Advance Payments in Separate Party Account"
}
],
"icon": "fa fa-building",
@@ -738,7 +738,7 @@
"image_field": "company_logo",
"is_tree": 1,
"links": [],
- "modified": "2023-06-16 13:32:48.790947",
+ "modified": "2023-06-23 18:22:27.219706",
"modified_by": "Administrator",
"module": "Setup",
"name": "Company",
diff --git a/erpnext/setup/doctype/customer_group/customer_group.js b/erpnext/setup/doctype/customer_group/customer_group.js
index ed98933..49a90f9 100644
--- a/erpnext/setup/doctype/customer_group/customer_group.js
+++ b/erpnext/setup/doctype/customer_group/customer_group.js
@@ -41,6 +41,7 @@
return {
filters: {
"root_type": 'Liability',
+ "account_type": "Receivable",
"company": locals[cdt][cdn].company,
"is_group": 0
}
diff --git a/erpnext/setup/doctype/supplier_group/supplier_group.js b/erpnext/setup/doctype/supplier_group/supplier_group.js
index ac5904f..b2acfd7 100644
--- a/erpnext/setup/doctype/supplier_group/supplier_group.js
+++ b/erpnext/setup/doctype/supplier_group/supplier_group.js
@@ -41,6 +41,7 @@
return {
filters: {
"root_type": 'Asset',
+ "account_type": "Payable",
"company": locals[cdt][cdn].company,
"is_group": 0
}