Merge pull request #6973 from RobertSchouten/bankrecon

[fix] layout for bank reconciliation
This commit is contained in:
Nabin Hait 2016-11-18 12:49:16 +05:30 committed by GitHub
commit a3a59ea895
3 changed files with 30 additions and 17 deletions

View File

@ -46,6 +46,12 @@ frappe.ui.form.on("Bank Reconciliation", {
callback: function(r, rt) { callback: function(r, rt) {
frm.refresh_field("payment_entries"); frm.refresh_field("payment_entries");
frm.refresh_fields(); frm.refresh_fields();
$(frm.fields_dict.payment_entries.wrapper).find("[data-fieldname=amount]").each(function(i,v){
if (i !=0){
$(v).addClass("text-right")
}
})
} }
}); });
} }

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import flt, getdate, nowdate from frappe.utils import flt, getdate, nowdate, fmt_money
from frappe import msgprint, _ from frappe import msgprint, _
from frappe.model.document import Document from frappe.model.document import Document
@ -26,8 +26,8 @@ class BankReconciliation(Document):
select select
"Journal Entry" as payment_document, t1.name as payment_entry, "Journal Entry" as payment_document, t1.name as payment_entry,
t1.cheque_no as cheque_number, t1.cheque_date, t1.cheque_no as cheque_number, t1.cheque_date,
abs(t2.debit_in_account_currency - t2.credit_in_account_currency) as amount, t2.debit_in_account_currency as debit, t2.credit_in_account_currency as credit,
t1.posting_date, t2.against_account, t1.clearance_date t1.posting_date, t2.against_account, t1.clearance_date, t2.account_currency
from from
`tabJournal Entry` t1, `tabJournal Entry Account` t2 `tabJournal Entry` t1, `tabJournal Entry Account` t2
where where
@ -41,16 +41,18 @@ class BankReconciliation(Document):
select select
"Payment Entry" as payment_document, name as payment_entry, "Payment Entry" as payment_document, name as payment_entry,
reference_no as cheque_number, reference_date as cheque_date, reference_no as cheque_number, reference_date as cheque_date,
if(paid_from=%s, paid_amount, received_amount) as amount, if(paid_from=%(account)s, paid_amount, "") as credit,
posting_date, party as against_account, clearance_date if(paid_from=%(account)s, "", received_amount) as debit,
posting_date, ifnull(party,if(paid_from=%(account)s,paid_to,paid_from)) as against_account, clearance_date,
if(paid_to=%(account)s, paid_to_account_currency, paid_from_account_currency) as account_currency
from `tabPayment Entry` from `tabPayment Entry`
where where
(paid_from=%s or paid_to=%s) and docstatus=1 (paid_from=%(account)s or paid_to=%(account)s) and docstatus=1
and posting_date >= %s and posting_date <= %s {0} and posting_date >= %(from)s and posting_date <= %(to)s {0}
order by order by
posting_date ASC, name DESC posting_date ASC, name DESC
""".format(condition), """.format(condition),
(self.bank_account, self.bank_account, self.bank_account, self.from_date, self.to_date), as_dict=1) {"account":self.bank_account, "from":self.from_date, "to":self.to_date}, as_dict=1)
entries = sorted(list(payment_entries)+list(journal_entries), entries = sorted(list(payment_entries)+list(journal_entries),
key=lambda k: k['posting_date'] or getdate(nowdate())) key=lambda k: k['posting_date'] or getdate(nowdate()))
@ -60,6 +62,11 @@ class BankReconciliation(Document):
for d in entries: for d in entries:
row = self.append('payment_entries', {}) row = self.append('payment_entries', {})
d.amount = fmt_money(d.debit if d.debit else d.credit, 2, d.account_currency) + " " + (_("Dr") if d.debit else _("Cr"))
d.pop("credit")
d.pop("debit")
d.pop("account_currency")
row.update(d) row.update(d)
self.total_amount += flt(d.amount) self.total_amount += flt(d.amount)

View File

@ -40,14 +40,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 1,
"fieldname": "payment_entry", "fieldname": "payment_entry",
"fieldtype": "Dynamic Link", "fieldtype": "Dynamic Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 1,
"label": "Payment Entry", "label": "Payment Entry",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -69,7 +69,7 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 3, "columns": 2,
"fieldname": "against_account", "fieldname": "against_account",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@ -99,7 +99,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 2, "columns": 2,
"fieldname": "amount", "fieldname": "amount",
"fieldtype": "Currency", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
@ -110,7 +110,7 @@
"no_copy": 0, "no_copy": 0,
"oldfieldname": "debit", "oldfieldname": "debit",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "account_currency", "options": "",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
@ -151,7 +151,7 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 2,
"fieldname": "posting_date", "fieldname": "posting_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
@ -178,7 +178,7 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 3, "columns": 1,
"fieldname": "cheque_number", "fieldname": "cheque_number",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@ -267,7 +267,7 @@
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2016-08-26 01:51:36.123941", "modified": "2016-11-17 11:39:00.308624",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Bank Reconciliation Detail", "name": "Bank Reconciliation Detail",