Added due date in the gl entry
This commit is contained in:
parent
2f3f7507c4
commit
0f065d5de1
@ -848,6 +848,39 @@
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "due_date",
|
||||
"fieldtype": "Date",
|
||||
"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,
|
||||
"label": "Due Date",
|
||||
"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,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
@ -861,7 +894,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-01-07 07:05:00.366399",
|
||||
"modified": "2019-05-01 07:05:00.366399",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "GL Entry",
|
||||
|
@ -498,6 +498,7 @@ class JournalEntry(AccountsController):
|
||||
self.get_gl_dict({
|
||||
"account": d.account,
|
||||
"party_type": d.party_type,
|
||||
"due_date": self.due_date,
|
||||
"party": d.party,
|
||||
"against": d.against_account,
|
||||
"debit": flt(d.debit, d.precision("debit")),
|
||||
|
@ -530,20 +530,57 @@ frappe.ui.form.on('Payment Entry', {
|
||||
},
|
||||
|
||||
get_outstanding_invoice: function(frm) {
|
||||
const today = frappe.datetime.get_today();
|
||||
const fields = [
|
||||
{fieldtype:"Date", label: __("Posting From Date"), fieldname:"from_date"},
|
||||
{fieldtype:"Section Break", label: __("Posting Date")},
|
||||
{fieldtype:"Date", label: __("From Date"),
|
||||
fieldname:"from_posting_date", default:frappe.datetime.add_days(today, -30)},
|
||||
{fieldtype:"Column Break"},
|
||||
{fieldtype:"Date", label: __("Posting To Date"), fieldname:"to_date"},
|
||||
{fieldtype:"Date", label: __("To Date"), fieldname:"to_posting_date", default:today},
|
||||
{fieldtype:"Section Break", label: __("Due Date")},
|
||||
{fieldtype:"Date", label: __("From Date"), fieldname:"from_due_date"},
|
||||
{fieldtype:"Column Break"},
|
||||
{fieldtype:"Date", label: __("To Date"), fieldname:"to_due_date"},
|
||||
{fieldtype:"Section Break", label: __("Outstanding Amount")},
|
||||
{fieldtype:"Float", label: __("Greater Than Amount"),
|
||||
fieldname:"outstanding_amt_greater_than", default: 0},
|
||||
{fieldtype:"Column Break"},
|
||||
{fieldtype:"Float", label: __("Less Than Amount"), fieldname:"outstanding_amt_less_than"},
|
||||
{fieldtype:"Section Break"},
|
||||
{fieldtype:"Check", label: __("Allocate Payment Amount"), fieldname:"allocate_payment_amount", default:1},
|
||||
];
|
||||
|
||||
frappe.prompt(fields, function(data){
|
||||
frappe.prompt(fields, function(filters){
|
||||
frappe.flags.allocate_payment_amount = true;
|
||||
frm.events.get_outstanding_documents(frm, data);
|
||||
}, __("Select Date"), __("Get Outstanding Invoices"));
|
||||
frm.events.validate_filters_data(frm, filters);
|
||||
frm.events.get_outstanding_documents(frm, filters);
|
||||
}, __("Filters"), __("Get Outstanding Invoices"));
|
||||
},
|
||||
|
||||
get_outstanding_documents: function(frm, date_args) {
|
||||
validate_filters_data: function(frm, filters) {
|
||||
const fields = {
|
||||
'Posting Date': ['from_posting_date', 'to_posting_date'],
|
||||
'Due Date': ['from_posting_date', 'to_posting_date'],
|
||||
'Advance Amount': ['from_posting_date', 'to_posting_date'],
|
||||
};
|
||||
|
||||
for (let key in fields) {
|
||||
let from_field = fields[key][0];
|
||||
let to_field = fields[key][1];
|
||||
|
||||
if (filters[from_field] && !filters[to_field]) {
|
||||
frappe.throw(__("Error: {0} is mandatory field",
|
||||
[to_field.replace(/_/g, " ")]
|
||||
));
|
||||
} else if (filters[from_field] && filters[from_field] > filters[to_field]) {
|
||||
frappe.throw(__("{0}: {1} must be less than {2}",
|
||||
[key, from_field.replace(/_/g, " "), to_field.replace(/_/g, " ")]
|
||||
));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get_outstanding_documents: function(frm, filters) {
|
||||
frm.clear_table("references");
|
||||
|
||||
if(!frm.doc.party) {
|
||||
@ -563,11 +600,12 @@ frappe.ui.form.on('Payment Entry', {
|
||||
"cost_center": frm.doc.cost_center
|
||||
}
|
||||
|
||||
if(date_args) {
|
||||
args["from_date"] = date_args["from_date"];
|
||||
args["to_date"] = date_args["to_date"];
|
||||
for (let key in filters) {
|
||||
args[key] = filters[key];
|
||||
}
|
||||
|
||||
frappe.flags.allocate_payment_amount = filters['allocate_payment_amount'];
|
||||
|
||||
return frappe.call({
|
||||
method: 'erpnext.accounts.doctype.payment_entry.payment_entry.get_outstanding_reference_documents',
|
||||
args: {
|
||||
@ -628,26 +666,10 @@ frappe.ui.form.on('Payment Entry', {
|
||||
frm.events.allocate_party_amount_against_ref_docs(frm,
|
||||
(frm.doc.payment_type=="Receive" ? frm.doc.paid_amount : frm.doc.received_amount));
|
||||
|
||||
frappe.flags.allocate_payment_amount = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// allocate_payment_amount: function(frm) {
|
||||
// if(frm.doc.payment_type == 'Internal Transfer'){
|
||||
// return
|
||||
// }
|
||||
|
||||
// if(frm.doc.references.length == 0){
|
||||
// frm.events.get_outstanding_documents(frm);
|
||||
// }
|
||||
// if(frm.doc.payment_type == 'Internal Transfer') {
|
||||
// frm.events.allocate_party_amount_against_ref_docs(frm, frm.doc.paid_amount);
|
||||
// } else {
|
||||
// frm.events.allocate_party_amount_against_ref_docs(frm, frm.doc.received_amount);
|
||||
// }
|
||||
// },
|
||||
|
||||
allocate_party_amount_against_ref_docs: function(frm, paid_amount) {
|
||||
var total_positive_outstanding_including_order = 0;
|
||||
var total_negative_outstanding = 0;
|
||||
|
@ -40,7 +40,7 @@
|
||||
"target_exchange_rate",
|
||||
"base_received_amount",
|
||||
"section_break_14",
|
||||
"allocate_payment_amount",
|
||||
"get_outstanding_invoice",
|
||||
"references",
|
||||
"section_break_34",
|
||||
"total_allocated_amount",
|
||||
@ -325,8 +325,6 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"collapsible": 0,
|
||||
"collapsible_depends_on": "",
|
||||
"depends_on": "eval:(doc.party && doc.paid_from && doc.paid_to && doc.paid_amount && doc.received_amount)",
|
||||
"fieldname": "section_break_14",
|
||||
"fieldtype": "Section Break",
|
||||
@ -568,7 +566,7 @@
|
||||
}
|
||||
],
|
||||
"is_submittable": 1,
|
||||
"modified": "2019-05-25 22:02:40.575822",
|
||||
"modified": "2019-05-27 15:53:21.108857",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Payment Entry",
|
||||
|
@ -587,14 +587,21 @@ def get_outstanding_reference_documents(args):
|
||||
if args.get("cost_center") and get_allow_cost_center_in_entry_of_bs_account():
|
||||
condition += " and cost_center='%s'" % args.get("cost_center")
|
||||
|
||||
if args.get("from_date") and args.get("to_date"):
|
||||
condition += " and posting_date between '{0}' and '{1}'".format(args.get("from_date"), args.get("to_date"))
|
||||
date_fields_dict = {
|
||||
'posting_date': ['from_posting_date', 'to_posting_date'],
|
||||
'due_date': ['from_due_date', 'to_due_date']
|
||||
}
|
||||
|
||||
for fieldname, date_fields in date_fields_dict.items():
|
||||
if args.get(date_fields[0]) and args.get(date_fields[1]):
|
||||
condition += " and {0} between '{1}' and '{2}'".format(fieldname,
|
||||
args.get(date_fields[0]), args.get(date_fields[1]))
|
||||
|
||||
if args.get("company"):
|
||||
condition += " and company = '{0}'".format(frappe.db.escape(args.get("company")))
|
||||
condition += " and company = {0}".format(frappe.db.escape(args.get("company")))
|
||||
|
||||
outstanding_invoices = get_outstanding_invoices(args.get("party_type"), args.get("party"),
|
||||
args.get("party_account"), condition=condition, limit=100)
|
||||
args.get("party_account"), filters=args, condition=condition, limit=100)
|
||||
|
||||
for d in outstanding_invoices:
|
||||
d["exchange_rate"] = 1
|
||||
@ -612,13 +619,19 @@ def get_outstanding_reference_documents(args):
|
||||
orders_to_be_billed = []
|
||||
if (args.get("party_type") != "Student"):
|
||||
orders_to_be_billed = get_orders_to_be_billed(args.get("posting_date"),args.get("party_type"),
|
||||
args.get("party"), args.get("company"), party_account_currency, company_currency)
|
||||
args.get("party"), args.get("company"), party_account_currency, company_currency, filters=args)
|
||||
|
||||
return negative_outstanding_invoices + outstanding_invoices + orders_to_be_billed
|
||||
data = negative_outstanding_invoices + outstanding_invoices + orders_to_be_billed
|
||||
|
||||
if not data:
|
||||
frappe.msgprint(_("No outstanding invoices found for the {0} <b>{1}</b>.")
|
||||
.format(args.get("party_type").lower(), args.get("party")))
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def get_orders_to_be_billed(posting_date, party_type, party,
|
||||
company, party_account_currency, company_currency, cost_center=None):
|
||||
company, party_account_currency, company_currency, cost_center=None, filters=None):
|
||||
if party_type == "Customer":
|
||||
voucher_type = 'Sales Order'
|
||||
elif party_type == "Supplier":
|
||||
@ -664,6 +677,10 @@ def get_orders_to_be_billed(posting_date, party_type, party,
|
||||
|
||||
order_list = []
|
||||
for d in orders:
|
||||
if not (d.outstanding_amount >= filters.get("outstanding_amt_greater_than")
|
||||
and d.outstanding_amount <= filters.get("outstanding_amt_less_than")):
|
||||
continue
|
||||
|
||||
d["voucher_type"] = voucher_type
|
||||
# This assumes that the exchange rate required is the one in the SO
|
||||
d["exchange_rate"] = get_exchange_rate(party_account_currency, company_currency, posting_date)
|
||||
@ -934,7 +951,6 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount=
|
||||
pe.paid_to_account_currency = party_account_currency if payment_type=="Pay" else bank.account_currency
|
||||
pe.paid_amount = paid_amount
|
||||
pe.received_amount = received_amount
|
||||
pe.allocate_payment_amount = 1
|
||||
pe.letter_head = doc.get("letter_head")
|
||||
|
||||
if pe.party_type in ["Customer", "Supplier"]:
|
||||
|
@ -416,6 +416,7 @@ class PurchaseInvoice(BuyingController):
|
||||
"account": self.credit_to,
|
||||
"party_type": "Supplier",
|
||||
"party": self.supplier,
|
||||
"due_date": self.due_date,
|
||||
"against": self.against_expense_account,
|
||||
"credit": grand_total_in_company_currency,
|
||||
"credit_in_account_currency": grand_total_in_company_currency \
|
||||
|
@ -734,6 +734,7 @@ class SalesInvoice(SellingController):
|
||||
"account": self.debit_to,
|
||||
"party_type": "Customer",
|
||||
"party": self.customer,
|
||||
"due_date": self.due_date,
|
||||
"against": self.against_income_account,
|
||||
"debit": grand_total_in_company_currency,
|
||||
"debit_in_account_currency": grand_total_in_company_currency \
|
||||
|
@ -628,14 +628,10 @@ def get_held_invoices(party_type, party):
|
||||
return held_invoices
|
||||
|
||||
|
||||
def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
def get_outstanding_invoices(party_type, party, account, condition=None, filters=None):
|
||||
outstanding_invoices = []
|
||||
precision = frappe.get_precision("Sales Invoice", "outstanding_amount") or 2
|
||||
|
||||
limit_cond = ''
|
||||
if limit:
|
||||
limit_cond = " limit {}".format(limit)
|
||||
|
||||
if erpnext.get_party_account_type(party_type) == 'Receivable':
|
||||
dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
|
||||
payment_dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
|
||||
@ -648,7 +644,8 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
|
||||
invoice_list = frappe.db.sql("""
|
||||
select
|
||||
voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount
|
||||
voucher_no, voucher_type, posting_date, due_date,
|
||||
ifnull(sum({dr_or_cr}), 0) as invoice_amount
|
||||
from
|
||||
`tabGL Entry`
|
||||
where
|
||||
@ -677,8 +674,8 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
and account = %(account)s
|
||||
and {payment_dr_or_cr} > 0
|
||||
and against_voucher is not null and against_voucher != ''
|
||||
group by against_voucher_type, against_voucher {limit_cond}
|
||||
""".format(payment_dr_or_cr=payment_dr_or_cr, limit_cond= limit_cond), {
|
||||
group by against_voucher_type, against_voucher
|
||||
""".format(payment_dr_or_cr=payment_dr_or_cr), {
|
||||
"party_type": party_type,
|
||||
"party": party,
|
||||
"account": account
|
||||
@ -692,10 +689,12 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
payment_amount = pe_map.get((d.voucher_type, d.voucher_no), 0)
|
||||
outstanding_amount = flt(d.invoice_amount - payment_amount, precision)
|
||||
if outstanding_amount > 0.5 / (10**precision):
|
||||
if not d.voucher_type == "Purchase Invoice" or d.voucher_no not in held_invoices:
|
||||
due_date = frappe.db.get_value(
|
||||
d.voucher_type, d.voucher_no, "posting_date" if party_type == "Employee" else "due_date")
|
||||
if (filters.get("outstanding_amt_greater_than") and
|
||||
not (outstanding_amount >= filters.get("outstanding_amt_greater_than") and
|
||||
outstanding_amount <= filters.get("outstanding_amt_less_than"))):
|
||||
continue
|
||||
|
||||
if not d.voucher_type == "Purchase Invoice" or d.voucher_no not in held_invoices:
|
||||
outstanding_invoices.append(
|
||||
frappe._dict({
|
||||
'voucher_no': d.voucher_no,
|
||||
@ -704,7 +703,7 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
'invoice_amount': flt(d.invoice_amount),
|
||||
'payment_amount': payment_amount,
|
||||
'outstanding_amount': outstanding_amount,
|
||||
'due_date': due_date
|
||||
'due_date': d.due_date
|
||||
})
|
||||
)
|
||||
|
||||
|
@ -615,3 +615,4 @@ erpnext.patches.v11_1.set_missing_opportunity_from
|
||||
erpnext.patches.v12_0.set_quotation_status
|
||||
erpnext.patches.v12_0.set_priority_for_support
|
||||
erpnext.patches.v12_0.delete_priority_property_setter
|
||||
erpnext.patches.v12_0.update_due_date_in_gle
|
||||
|
17
erpnext/patches/v12_0/update_due_date_in_gle.py
Normal file
17
erpnext/patches/v12_0/update_due_date_in_gle.py
Normal file
@ -0,0 +1,17 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("accounts", "doctype", "gl_entry")
|
||||
|
||||
for doctype in ["Sales Invoice", "Purchase Invoice", "Journal Entry"]:
|
||||
frappe.reload_doc("accounts", "doctype", frappe.scrub(doctype))
|
||||
|
||||
frappe.db.sql(""" UPDATE `tabGL Entry`, `tab{doctype}`
|
||||
SET
|
||||
`tabGL Entry`.due_date = `tab{doctype}`.due_date
|
||||
WHERE
|
||||
`tabGL Entry`.voucher_no = `tab{doctype}`.name and `tabGL Entry`.party is not null
|
||||
and `tabGL Entry`.voucher_type in ('Sales Invoice', 'Purchase Invoice', 'Journal Entry')
|
||||
and account in (select name from `tabAccount` where account_type in ('Receivable', 'Payable') )"""
|
||||
.format(doctype=doctype))
|
Loading…
x
Reference in New Issue
Block a user