set the reference document in the payment entry while creating from fees (#11861)
* set the reference document in the payment entry while creating from fees * allocate the paid amount in the reference document
This commit is contained in:
parent
7351709980
commit
a160879159
@ -512,7 +512,7 @@ frappe.ui.form.on('Payment Entry', {
|
|||||||
c.outstanding_amount = d.outstanding_amount;
|
c.outstanding_amount = d.outstanding_amount;
|
||||||
c.bill_no = d.bill_no;
|
c.bill_no = d.bill_no;
|
||||||
|
|
||||||
if(!in_list(["Sales Order", "Purchase Order", "Expense Claim"], d.voucher_type)) {
|
if(!in_list(["Sales Order", "Purchase Order", "Expense Claim", "Fees"], d.voucher_type)) {
|
||||||
if(flt(d.outstanding_amount) > 0)
|
if(flt(d.outstanding_amount) > 0)
|
||||||
total_positive_outstanding += flt(d.outstanding_amount);
|
total_positive_outstanding += flt(d.outstanding_amount);
|
||||||
else
|
else
|
||||||
@ -527,7 +527,7 @@ frappe.ui.form.on('Payment Entry', {
|
|||||||
} else {
|
} else {
|
||||||
c.exchange_rate = 1;
|
c.exchange_rate = 1;
|
||||||
}
|
}
|
||||||
if (in_list(['Sales Invoice', 'Purchase Invoice', "Expense Claim"], d.reference_doctype)){
|
if (in_list(['Sales Invoice', 'Purchase Invoice', "Expense Claim", "Fees"], d.reference_doctype)){
|
||||||
c.due_date = d.due_date;
|
c.due_date = d.due_date;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -535,7 +535,8 @@ frappe.ui.form.on('Payment Entry', {
|
|||||||
if(
|
if(
|
||||||
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Customer") ||
|
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Customer") ||
|
||||||
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Supplier") ||
|
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Supplier") ||
|
||||||
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Employee")
|
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Employee") ||
|
||||||
|
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Student")
|
||||||
) {
|
) {
|
||||||
if(total_positive_outstanding > total_negative_outstanding)
|
if(total_positive_outstanding > total_negative_outstanding)
|
||||||
frm.set_value("paid_amount",
|
frm.set_value("paid_amount",
|
||||||
@ -579,13 +580,16 @@ frappe.ui.form.on('Payment Entry', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
var allocated_negative_outstanding = 0;
|
var allocated_negative_outstanding = 0;
|
||||||
if ((frm.doc.payment_type=="Receive" && frm.doc.party_type=="Customer") ||
|
if (
|
||||||
|
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Customer") ||
|
||||||
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Supplier") ||
|
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Supplier") ||
|
||||||
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Employee")) {
|
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Employee") ||
|
||||||
if(total_positive_outstanding_including_order > paid_amount) {
|
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Student")
|
||||||
var remaining_outstanding = total_positive_outstanding_including_order - paid_amount;
|
) {
|
||||||
allocated_negative_outstanding = total_negative_outstanding < remaining_outstanding ?
|
if(total_positive_outstanding_including_order > paid_amount) {
|
||||||
total_negative_outstanding : remaining_outstanding;
|
var remaining_outstanding = total_positive_outstanding_including_order - paid_amount;
|
||||||
|
allocated_negative_outstanding = total_negative_outstanding < remaining_outstanding ?
|
||||||
|
total_negative_outstanding : remaining_outstanding;
|
||||||
}
|
}
|
||||||
|
|
||||||
var allocated_positive_outstanding = paid_amount + allocated_negative_outstanding;
|
var allocated_positive_outstanding = paid_amount + allocated_negative_outstanding;
|
||||||
|
@ -310,9 +310,10 @@ class PaymentEntry(AccountsController):
|
|||||||
self.difference_amount = flt(self.difference_amount - total_deductions,
|
self.difference_amount = flt(self.difference_amount - total_deductions,
|
||||||
self.precision("difference_amount"))
|
self.precision("difference_amount"))
|
||||||
|
|
||||||
|
# Paid amount is auto allocated in the reference document by default.
|
||||||
|
# Clear the reference document which doesn't have allocated amount on validate so that form can be loaded fast
|
||||||
def clear_unallocated_reference_document_rows(self):
|
def clear_unallocated_reference_document_rows(self):
|
||||||
self.set("references", self.get("references", {"allocated_amount": ["not in", [0, None, ""]]}))
|
self.set("references", self.get("references", {"allocated_amount": ["not in", [0, None, ""]]}))
|
||||||
|
|
||||||
frappe.db.sql("""delete from `tabPayment Entry Reference`
|
frappe.db.sql("""delete from `tabPayment Entry Reference`
|
||||||
where parent = %s and allocated_amount = 0""", self.name)
|
where parent = %s and allocated_amount = 0""", self.name)
|
||||||
|
|
||||||
|
@ -576,14 +576,13 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
|||||||
outstanding_invoices = []
|
outstanding_invoices = []
|
||||||
precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
|
precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
|
||||||
|
|
||||||
if party_type == "Customer":
|
if party_type == "Customer" or party_type == "Student":
|
||||||
dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
|
dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
|
||||||
payment_dr_or_cr = "payment_gl_entry.credit_in_account_currency - payment_gl_entry.debit_in_account_currency"
|
payment_dr_or_cr = "payment_gl_entry.credit_in_account_currency - payment_gl_entry.debit_in_account_currency"
|
||||||
else:
|
else:
|
||||||
dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
|
dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
|
||||||
payment_dr_or_cr = "payment_gl_entry.debit_in_account_currency - payment_gl_entry.credit_in_account_currency"
|
payment_dr_or_cr = "payment_gl_entry.debit_in_account_currency - payment_gl_entry.credit_in_account_currency"
|
||||||
|
|
||||||
invoice = 'Sales Invoice' if party_type == 'Customer' else 'Purchase Invoice'
|
|
||||||
invoice_list = frappe.db.sql("""
|
invoice_list = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount, due_date,
|
voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount, due_date,
|
||||||
@ -613,7 +612,6 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
|||||||
having (invoice_amount - payment_amount) > 0.005
|
having (invoice_amount - payment_amount) > 0.005
|
||||||
order by posting_date, name, due_date""".format(
|
order by posting_date, name, due_date""".format(
|
||||||
dr_or_cr=dr_or_cr,
|
dr_or_cr=dr_or_cr,
|
||||||
invoice=invoice,
|
|
||||||
payment_dr_or_cr=payment_dr_or_cr,
|
payment_dr_or_cr=payment_dr_or_cr,
|
||||||
condition=condition or ""
|
condition=condition or ""
|
||||||
), {
|
), {
|
||||||
|
@ -1263,35 +1263,6 @@
|
|||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "data_42",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"unique": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"has_web_view": 0,
|
||||||
@ -1305,7 +1276,7 @@
|
|||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"menu_index": 0,
|
"menu_index": 0,
|
||||||
"modified": "2017-11-10 18:57:12.021112",
|
"modified": "2017-12-06 05:55:10.502567",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Education",
|
"module": "Education",
|
||||||
"name": "Fees",
|
"name": "Fees",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user