Merge pull request #5636 from nabinhait/payment_entry_fix
Payment entry fix
This commit is contained in:
commit
1e42a05c2d
@ -848,32 +848,6 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"depends_on": "difference_amount",
|
||||
"fieldname": "write_off_difference_amount",
|
||||
"fieldtype": "Button",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Write Off Difference Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@ -976,6 +950,32 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"depends_on": "difference_amount",
|
||||
"fieldname": "write_off_difference_amount",
|
||||
"fieldtype": "Button",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Write Off Difference Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@ -1372,7 +1372,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-07-01 17:14:17.562924",
|
||||
"modified": "2016-07-04 15:00:53.731584",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Payment Entry",
|
||||
|
@ -49,6 +49,7 @@ class PaymentEntry(AccountsController):
|
||||
self.set_remarks()
|
||||
|
||||
def on_submit(self):
|
||||
self.setup_party_account_field()
|
||||
if self.difference_amount:
|
||||
frappe.throw(_("Difference Amount must be zero"))
|
||||
self.make_gl_entries()
|
||||
@ -127,7 +128,7 @@ class PaymentEntry(AccountsController):
|
||||
def validate_account_type(self, account, account_types):
|
||||
account_type = frappe.db.get_value("Account", account, "account_type")
|
||||
if account_type not in account_types:
|
||||
frappe.throw(_("Account Type for {0} must be {1}").format(comma_or(account_types)))
|
||||
frappe.throw(_("Account Type for {0} must be {1}").format(account, comma_or(account_types)))
|
||||
|
||||
def set_exchange_rate(self):
|
||||
if self.paid_from and not self.source_exchange_rate:
|
||||
@ -194,7 +195,7 @@ class PaymentEntry(AccountsController):
|
||||
""", (self.party_account, self.party, d.reference_name), as_dict=True)
|
||||
|
||||
if not je_accounts:
|
||||
frappe.throw(_("Row #{0}: Journal Entry {0} does not have account {1} or already matched against another voucher")
|
||||
frappe.throw(_("Row #{0}: Journal Entry {1} does not have account {2} or already matched against another voucher")
|
||||
.format(d.idx, d.reference_name, self.party_account))
|
||||
else:
|
||||
dr_or_cr = "debit" if self.payment_type == "Receive" else "credit"
|
||||
@ -270,6 +271,7 @@ class PaymentEntry(AccountsController):
|
||||
def validate_payment_against_negative_invoice(self):
|
||||
if ((self.payment_type=="Pay" and self.party_type=="Customer")
|
||||
or (self.payment_type=="Receive" and self.party_type=="Supplier")):
|
||||
|
||||
total_negative_outstanding = sum([abs(flt(d.outstanding_amount))
|
||||
for d in self.get("references") if flt(d.outstanding_amount) < 0])
|
||||
|
||||
@ -379,7 +381,7 @@ class PaymentEntry(AccountsController):
|
||||
gle = party_gl_dict.copy()
|
||||
|
||||
gle.update({
|
||||
dr_or_cr + "_in_account_currency": d.unallocated_amount,
|
||||
dr_or_cr + "_in_account_currency": self.unallocated_amount,
|
||||
dr_or_cr: base_unallocated_amount
|
||||
})
|
||||
|
||||
@ -535,6 +537,7 @@ def get_party_details(company, party_type, party, date):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_account_details(account, date):
|
||||
frappe.has_permission('Payment Entry', throw=True)
|
||||
return frappe._dict({
|
||||
"account_currency": get_account_currency(account),
|
||||
"account_balance": get_balance_on(account, date),
|
||||
|
@ -434,15 +434,13 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
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"
|
||||
|
||||
invoice_list = frappe.db.sql("""select
|
||||
voucher_no, voucher_type, posting_date,
|
||||
ifnull(sum({dr_or_cr}), 0) as invoice_amount,
|
||||
invoice_list = frappe.db.sql("""
|
||||
select
|
||||
voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount,
|
||||
(
|
||||
select
|
||||
ifnull(sum({payment_dr_or_cr}), 0)
|
||||
select ifnull(sum({payment_dr_or_cr}), 0)
|
||||
from `tabGL Entry` payment_gl_entry
|
||||
where
|
||||
payment_gl_entry.against_voucher_type = invoice_gl_entry.voucher_type
|
||||
where payment_gl_entry.against_voucher_type = invoice_gl_entry.voucher_type
|
||||
and payment_gl_entry.against_voucher = invoice_gl_entry.voucher_no
|
||||
and payment_gl_entry.party_type = invoice_gl_entry.party_type
|
||||
and payment_gl_entry.party = invoice_gl_entry.party
|
||||
@ -452,10 +450,8 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
from
|
||||
`tabGL Entry` invoice_gl_entry
|
||||
where
|
||||
party_type = %(party_type)s
|
||||
and party = %(party)s
|
||||
and account = %(account)s
|
||||
and {dr_or_cr} > 0
|
||||
party_type = %(party_type)s and party = %(party)s
|
||||
and account = %(account)s and {dr_or_cr} > 0
|
||||
{condition}
|
||||
and ((voucher_type = 'Journal Entry'
|
||||
and (against_voucher = '' or against_voucher is null))
|
||||
|
@ -21,10 +21,15 @@ def get_data():
|
||||
"name": "Payment Request",
|
||||
"description": _("Payment Request")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Payment Entry",
|
||||
"description": _("Bank/Cash transactions against party or for internal transfer")
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Accounts Receivable",
|
||||
"doctype": "Sales Invoice",
|
||||
"doctype": "Sales Invoice",
|
||||
"is_query_report": True
|
||||
},
|
||||
{
|
||||
@ -44,11 +49,6 @@ def get_data():
|
||||
"name": "Company",
|
||||
"description": _("Company (not Customer or Supplier) master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Payment Entry",
|
||||
"description": _("Payment entries against party or for internal transfer")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Journal Entry",
|
||||
|
Loading…
x
Reference in New Issue
Block a user