From 622fe3f1e312ed6659ffdf1284ce5b3ee017534d Mon Sep 17 00:00:00 2001 From: shreyas Date: Thu, 5 May 2016 15:11:04 +0530 Subject: [PATCH 1/3] [Fix] Fetch due date for Sales/Purchase invoice in payment tool --- .../doctype/payment_tool/payment_tool.js | 2 +- .../doctype/payment_tool/payment_tool.py | 34 ++++++++-------- .../payment_tool_detail.json | 40 ++++++++++++++++++- 3 files changed, 57 insertions(+), 19 deletions(-) diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.js b/erpnext/accounts/doctype/payment_tool/payment_tool.js index e15694c931..c77fa7931a 100644 --- a/erpnext/accounts/doctype/payment_tool/payment_tool.js +++ b/erpnext/accounts/doctype/payment_tool/payment_tool.js @@ -202,7 +202,7 @@ frappe.ui.form.on("Payment Tool Detail", "against_voucher_no", function(frm, cdt } frappe.call({ - method: 'erpnext.accounts.doctype.payment_tool.payment_tool.get_against_voucher_amount', + method: 'erpnext.accounts.doctype.payment_tool.payment_tool.get_against_voucher_details', args: { "against_voucher_type": row.against_voucher_type, "against_voucher_no": row.against_voucher_no, diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.py b/erpnext/accounts/doctype/payment_tool/payment_tool.py index ef8ffb1b93..5c5b393963 100644 --- a/erpnext/accounts/doctype/payment_tool/payment_tool.py +++ b/erpnext/accounts/doctype/payment_tool/payment_tool.py @@ -20,15 +20,15 @@ class PaymentTool(Document): jv.company = self.company jv.cheque_no = self.reference_no jv.cheque_date = self.reference_date - - party_account_currency, party_account_type = frappe.db.get_value("Account", self.party_account, + + party_account_currency, party_account_type = frappe.db.get_value("Account", self.party_account, ["account_currency", "account_type"]) - + bank_account_currency, bank_account_type = None, None if self.payment_account: - bank_account_currency, bank_account_type = frappe.db.get_value("Account", self.payment_account, + bank_account_currency, bank_account_type = frappe.db.get_value("Account", self.payment_account, ["account_currency", "account_type"]) - + if not self.total_payment_amount: frappe.throw(_("Please enter Payment Amount in atleast one row")) @@ -36,11 +36,11 @@ class PaymentTool(Document): if not frappe.db.get_value(v.against_voucher_type, {"name": v.against_voucher_no}): frappe.throw(_("Row {0}: {1} is not a valid {2}").format(v.idx, v.against_voucher_no, v.against_voucher_type)) - + if v.payment_amount: exchange_rate = get_exchange_rate(self.party_account, party_account_currency, self.company, v.against_voucher_type, v.against_voucher_no) - + d1 = jv.append("accounts") d1.account = self.party_account d1.party_type = self.party_type @@ -56,7 +56,7 @@ class PaymentTool(Document): d1.reference_name = v.against_voucher_no d1.is_advance = 'Yes' \ if v.against_voucher_type in ['Sales Order', 'Purchase Order'] else 'No' - + amount = flt(d1.debit_in_account_currency) - flt(d1.credit_in_account_currency) if bank_account_currency == party_account_currency: total_payment_amount += amount @@ -65,27 +65,27 @@ class PaymentTool(Document): d2 = jv.append("accounts") if self.payment_account: - bank_account_currency, bank_account_type = frappe.db.get_value("Account", self.payment_account, + bank_account_currency, bank_account_type = frappe.db.get_value("Account", self.payment_account, ["account_currency", "account_type"]) - + d2.account = self.payment_account d2.account_currency = bank_account_currency d2.account_type = bank_account_type - d2.exchange_rate = get_exchange_rate(self.payment_account, bank_account_currency, self.company, - debit=(abs(total_payment_amount) if total_payment_amount < 0 else 0), + d2.exchange_rate = get_exchange_rate(self.payment_account, bank_account_currency, self.company, + debit=(abs(total_payment_amount) if total_payment_amount < 0 else 0), credit=(total_payment_amount if total_payment_amount > 0 else 0)) d2.account_balance = get_balance_on(self.payment_account) - + amount_field_bank = 'debit_in_account_currency' if total_payment_amount < 0 \ else 'credit_in_account_currency' - + d2.set(amount_field_bank, abs(total_payment_amount)) - + company_currency = frappe.db.get_value("Company", self.company, "default_currency") if party_account_currency != company_currency or \ (bank_account_currency and bank_account_currency != company_currency): jv.multi_currency = 1 - + jv.set_amounts_in_company_currency() jv.set_total_debit_credit() @@ -150,7 +150,7 @@ def get_orders_to_be_billed(party_type, party, party_account_currency, company_c return order_list @frappe.whitelist() -def get_against_voucher_amount(against_voucher_type, against_voucher_no, party_account, company): +def get_against_voucher_details(against_voucher_type, against_voucher_no, party_account, company): party_account_currency = get_account_currency(party_account) company_currency = frappe.db.get_value("Company", company, "default_currency") ref_field = "base_grand_total" if party_account_currency == company_currency else "grand_total" diff --git a/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json b/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json index 765aa9302d..ff34a4ac71 100644 --- a/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json +++ b/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json @@ -16,6 +16,7 @@ "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Against Voucher Type", @@ -24,6 +25,7 @@ "options": "DocType", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "print_width": "", "read_only": 0, "report_hide": 0, @@ -41,6 +43,7 @@ "fieldtype": "Dynamic Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Against Voucher No", @@ -49,6 +52,7 @@ "options": "against_voucher_type", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -56,6 +60,31 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "due_date", + "fieldtype": "Date", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Due Date", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -64,6 +93,7 @@ "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "length": 0, @@ -71,6 +101,7 @@ "permlevel": 0, "precision": "", "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -86,6 +117,7 @@ "fieldtype": "Currency", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Total Amount", @@ -94,6 +126,7 @@ "options": "party_account_currency", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 1, "report_hide": 0, "reqd": 0, @@ -109,6 +142,7 @@ "fieldtype": "Currency", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Outstanding Amount", @@ -117,6 +151,7 @@ "options": "party_account_currency", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 1, "report_hide": 0, "reqd": 0, @@ -132,6 +167,7 @@ "fieldtype": "Currency", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Payment Amount", @@ -140,6 +176,7 @@ "options": "party_account_currency", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 1, @@ -150,13 +187,14 @@ ], "hide_heading": 0, "hide_toolbar": 0, + "idx": 0, "in_create": 0, "in_dialog": 0, "is_submittable": 0, "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2015-11-16 06:29:51.626386", + "modified": "2016-05-05 05:37:41.206708", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Tool Detail", From 55cbd522003bb9015adec362ce70b2f82239264d Mon Sep 17 00:00:00 2001 From: shreyas Date: Thu, 5 May 2016 15:16:39 +0530 Subject: [PATCH 2/3] [Fix] Allocate leaves only to active employees --- .../leave_control_panel.json | 43 +++++++++++++++++-- .../leave_control_panel.py | 27 ++++++------ 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.json b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.json index c92fbb8de8..17e667ee22 100644 --- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.json +++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.json @@ -15,11 +15,14 @@ "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -33,17 +36,20 @@ "bold": 0, "collapsible": 0, "description": "Leave blank if considered for all employee types", - "fieldname": "employee_type", + "fieldname": "employment_type", "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, - "label": "Employee Type", + "label": "Employment Type", + "length": 0, "no_copy": 0, "options": "Employment Type", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -60,13 +66,16 @@ "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Branch", + "length": 0, "no_copy": 0, "options": "Branch", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -83,13 +92,16 @@ "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Department", + "length": 0, "no_copy": 0, "options": "Department", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -106,13 +118,16 @@ "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Designation", + "length": 0, "no_copy": 0, "options": "Designation", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -128,11 +143,14 @@ "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -149,13 +167,16 @@ "fieldtype": "Date", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "From Date", + "length": 0, "no_copy": 0, "permlevel": 0, "precision": "", "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 1, @@ -171,13 +192,16 @@ "fieldtype": "Date", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "To Date", + "length": 0, "no_copy": 0, "permlevel": 0, "precision": "", "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 1, @@ -193,13 +217,16 @@ "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Leave Type", + "length": 0, "no_copy": 0, "options": "Leave Type", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 1, @@ -216,12 +243,15 @@ "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Carry Forward", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -237,12 +267,15 @@ "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "New Leaves Allocated (In Days)", + "length": 0, "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 1, @@ -258,13 +291,16 @@ "fieldtype": "Button", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Allocate", + "length": 0, "no_copy": 0, "options": "allocate_leave", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -282,7 +318,8 @@ "is_submittable": 0, "issingle": 1, "istable": 0, - "modified": "2015-10-28 16:23:57.733900", + "max_attachments": 0, + "modified": "2016-05-05 05:45:33.355366", "modified_by": "Administrator", "module": "HR", "name": "Leave Control Panel", diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py index 77c7ad99ce..b4561f18a2 100644 --- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py +++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py @@ -10,27 +10,24 @@ from frappe.model.document import Document class LeaveControlPanel(Document): def get_employees(self): - lst1 = [[self.employee_type,"employment_type"],[self.branch,"branch"],[self.designation,"designation"],[self.department, "department"]] - condition = "where " - flag = 0 - for l in lst1: - if(l[0]): - if flag == 0: - condition += l[1] + "= '" + l[0] +"'" - else: - condition += " and " + l[1]+ "= '" +l[0] +"'" - flag = 1 - emp_query = "select name from `tabEmployee` " - if flag == 1: - emp_query += condition - e = frappe.db.sql(emp_query) + conditions, values = [], [] + for field in ["employment_type", "branch", "designation", "department"]: + if self.get(field): + conditions.append("{0}=%s".format(field)) + values.append(self.get(field)) + + condition_str = " and " + " and ".join(conditions) if len(conditions) else "" + + e = frappe.db.sql("select name from tabEmployee where status='Active' {condition}" + .format(condition=condition_str), tuple(values)) + return e def validate_values(self): for f in ["from_date", "to_date", "leave_type", "no_of_days"]: if not self.get(f): frappe.throw(_("{0} is required").format(self.meta.get_label(f))) - + def to_date_validation(self): if date_diff(self.to_date, self.from_date) <= 0: return "Invalid period" From c2a49211a5bdeb1d5ae4418fa8e0f793119c7d88 Mon Sep 17 00:00:00 2001 From: shreyas Date: Thu, 5 May 2016 15:56:48 +0530 Subject: [PATCH 3/3] [Fix] Payment Tool, Fetch due date when user does 'Get Outstanding Vouchers' --- erpnext/accounts/doctype/payment_tool/payment_tool.js | 4 ++++ .../doctype/payment_tool_detail/payment_tool_detail.json | 6 +++--- erpnext/accounts/utils.py | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.js b/erpnext/accounts/doctype/payment_tool/payment_tool.js index c77fa7931a..8d8e0ced0a 100644 --- a/erpnext/accounts/doctype/payment_tool/payment_tool.js +++ b/erpnext/accounts/doctype/payment_tool/payment_tool.js @@ -146,6 +146,10 @@ frappe.ui.form.on("Payment Tool", "get_outstanding_vouchers", function(frm) { c.total_amount = d.invoice_amount; c.outstanding_amount = d.outstanding_amount; + if (in_list(['Sales Invoice', 'Purchase Invoice'], d.voucher_type)){ + c.due_date = d.due_date + } + if (frm.doc.set_payment_amount) { c.payment_amount = d.outstanding_amount; } diff --git a/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json b/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json index ff34a4ac71..66447b00d1 100644 --- a/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json +++ b/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json @@ -18,7 +18,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, - "in_list_view": 1, + "in_list_view": 0, "label": "Against Voucher Type", "length": 0, "no_copy": 0, @@ -70,7 +70,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, - "in_list_view": 0, + "in_list_view": 1, "label": "Due Date", "length": 0, "no_copy": 0, @@ -194,7 +194,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2016-05-05 05:37:41.206708", + "modified": "2016-05-05 06:22:24.736160", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Tool Detail", diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 06197eb61f..48668fa679 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -473,7 +473,8 @@ def get_outstanding_invoices(party_type, party, account, condition=None): 'posting_date': d.posting_date, 'invoice_amount': flt(d.invoice_amount), 'payment_amount': flt(d.payment_amount), - 'outstanding_amount': flt(d.invoice_amount - d.payment_amount, precision) + 'outstanding_amount': flt(d.invoice_amount - d.payment_amount, precision), + 'due_date': frappe.db.get_value(d.voucher_type, d.voucher_no, "due_date") }) return outstanding_invoices