[fix] ignore journal entry based invoice in payment tool and payment reconciliation tool
This commit is contained in:
parent
c19afa140d
commit
0b031cdd6c
@ -79,6 +79,7 @@ class PaymentReconciliation(Document):
|
|||||||
`tabGL Entry`
|
`tabGL Entry`
|
||||||
where
|
where
|
||||||
party_type = %(party_type)s and party = %(party)s
|
party_type = %(party_type)s and party = %(party)s
|
||||||
|
and voucher_type != "Journal Entry"
|
||||||
and account = %(account)s and {dr_or_cr} > 0 {cond}
|
and account = %(account)s and {dr_or_cr} > 0 {cond}
|
||||||
group by voucher_type, voucher_no
|
group by voucher_type, voucher_no
|
||||||
""".format(**{
|
""".format(**{
|
||||||
|
@ -58,7 +58,7 @@ def get_outstanding_vouchers(args):
|
|||||||
frappe.throw(_("No permission to use Payment Tool"), frappe.PermissionError)
|
frappe.throw(_("No permission to use Payment Tool"), frappe.PermissionError)
|
||||||
|
|
||||||
args = json.loads(args)
|
args = json.loads(args)
|
||||||
|
|
||||||
party_account_currency = frappe.db.get_value("Account", args.get("party_account"), "account_currency")
|
party_account_currency = frappe.db.get_value("Account", args.get("party_account"), "account_currency")
|
||||||
company_currency = frappe.db.get_value("Company", args.get("company"), "default_currency")
|
company_currency = frappe.db.get_value("Company", args.get("company"), "default_currency")
|
||||||
|
|
||||||
@ -71,18 +71,18 @@ def get_outstanding_vouchers(args):
|
|||||||
|
|
||||||
# Get all outstanding sales /purchase invoices
|
# Get all outstanding sales /purchase invoices
|
||||||
outstanding_invoices = get_outstanding_invoices(amount_query, args.get("party_account"),
|
outstanding_invoices = get_outstanding_invoices(amount_query, args.get("party_account"),
|
||||||
args.get("party_type"), args.get("party"))
|
args.get("party_type"), args.get("party"), with_journal_entry=False)
|
||||||
|
|
||||||
# Get all SO / PO which are not fully billed or aginst which full advance not paid
|
# Get all SO / PO which are not fully billed or aginst which full advance not paid
|
||||||
orders_to_be_billed = get_orders_to_be_billed(args.get("party_type"), args.get("party"),
|
orders_to_be_billed = get_orders_to_be_billed(args.get("party_type"), args.get("party"),
|
||||||
party_account_currency, company_currency)
|
party_account_currency, company_currency)
|
||||||
return outstanding_invoices + orders_to_be_billed
|
return outstanding_invoices + orders_to_be_billed
|
||||||
|
|
||||||
def get_orders_to_be_billed(party_type, party, party_account_currency, company_currency):
|
def get_orders_to_be_billed(party_type, party, party_account_currency, company_currency):
|
||||||
voucher_type = 'Sales Order' if party_type == "Customer" else 'Purchase Order'
|
voucher_type = 'Sales Order' if party_type == "Customer" else 'Purchase Order'
|
||||||
|
|
||||||
ref_field = "base_grand_total" if party_account_currency == company_currency else "grand_total"
|
ref_field = "base_grand_total" if party_account_currency == company_currency else "grand_total"
|
||||||
|
|
||||||
orders = frappe.db.sql("""
|
orders = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
name as voucher_no,
|
name as voucher_no,
|
||||||
@ -115,7 +115,7 @@ def get_against_voucher_amount(against_voucher_type, against_voucher_no, party_a
|
|||||||
party_account_currency = frappe.db.get_value("Account", party_account, "account_currency")
|
party_account_currency = frappe.db.get_value("Account", party_account, "account_currency")
|
||||||
company_currency = frappe.db.get_value("Company", company, "default_currency")
|
company_currency = frappe.db.get_value("Company", company, "default_currency")
|
||||||
ref_field = "base_grand_total" if party_account_currency == company_currency else "grand_total"
|
ref_field = "base_grand_total" if party_account_currency == company_currency else "grand_total"
|
||||||
|
|
||||||
if against_voucher_type in ["Sales Order", "Purchase Order"]:
|
if against_voucher_type in ["Sales Order", "Purchase Order"]:
|
||||||
select_cond = "{0} as total_amount, ifnull({0}, 0) - ifnull(advance_paid, 0) as outstanding_amount"\
|
select_cond = "{0} as total_amount, ifnull({0}, 0) - ifnull(advance_paid, 0) as outstanding_amount"\
|
||||||
.format(ref_field)
|
.format(ref_field)
|
||||||
|
@ -100,7 +100,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, in_acco
|
|||||||
if party_type and party:
|
if party_type and party:
|
||||||
cond.append("""gle.party_type = "%s" and gle.party = "%s" """ %
|
cond.append("""gle.party_type = "%s" and gle.party = "%s" """ %
|
||||||
(party_type.replace('"', '\\"'), party.replace('"', '\\"')))
|
(party_type.replace('"', '\\"'), party.replace('"', '\\"')))
|
||||||
|
|
||||||
if account or (party_type and party):
|
if account or (party_type and party):
|
||||||
if in_account_currency:
|
if in_account_currency:
|
||||||
select_field = "sum(ifnull(debit_in_account_currency, 0)) - sum(ifnull(credit_in_account_currency, 0))"
|
select_field = "sum(ifnull(debit_in_account_currency, 0)) - sum(ifnull(credit_in_account_currency, 0))"
|
||||||
@ -202,7 +202,7 @@ def update_against_doc(d, jv_obj):
|
|||||||
select cost_center, balance, against_account, is_advance, account_type, exchange_rate
|
select cost_center, balance, against_account, is_advance, account_type, exchange_rate
|
||||||
from `tabJournal Entry Account` where name = %s
|
from `tabJournal Entry Account` where name = %s
|
||||||
""", d['voucher_detail_no'], as_dict=True)
|
""", d['voucher_detail_no'], as_dict=True)
|
||||||
|
|
||||||
# new entry with balance amount
|
# new entry with balance amount
|
||||||
ch = jv_obj.append("accounts")
|
ch = jv_obj.append("accounts")
|
||||||
ch.account = d['account']
|
ch.account = d['account']
|
||||||
@ -392,7 +392,7 @@ def get_stock_rbnb_difference(posting_date, company):
|
|||||||
# Amount should be credited
|
# Amount should be credited
|
||||||
return flt(stock_rbnb) + flt(sys_bal)
|
return flt(stock_rbnb) + flt(sys_bal)
|
||||||
|
|
||||||
def get_outstanding_invoices(amount_query, account, party_type, party):
|
def get_outstanding_invoices(amount_query, account, party_type, party, with_journal_entry=True):
|
||||||
all_outstanding_vouchers = []
|
all_outstanding_vouchers = []
|
||||||
outstanding_voucher_list = frappe.db.sql("""
|
outstanding_voucher_list = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
@ -420,6 +420,9 @@ def get_outstanding_invoices(amount_query, account, party_type, party):
|
|||||||
payment_amount = -1*payment_amount[0][0] if payment_amount else 0
|
payment_amount = -1*payment_amount[0][0] if payment_amount else 0
|
||||||
precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
|
precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
|
||||||
|
|
||||||
|
if not with_journal_entry and d.voucher_type=="Journal Entry":
|
||||||
|
continue
|
||||||
|
|
||||||
if d.invoice_amount > payment_amount:
|
if d.invoice_amount > payment_amount:
|
||||||
|
|
||||||
all_outstanding_vouchers.append({
|
all_outstanding_vouchers.append({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user