refactor: Redo workflows
This commit is contained in:
@@ -756,6 +756,7 @@ class AccountsController(TransactionBase):
|
||||
"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 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user