Payment Tool changes due to multi currency
This commit is contained in:
parent
76bb927337
commit
bac9b8eef6
@ -93,7 +93,7 @@
|
|||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Balance in Account Currency",
|
"label": "Balance in Account Currency",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "currency",
|
"options": "account_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
@ -231,7 +231,7 @@
|
|||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Party Balance in Account Currency",
|
"label": "Party Balance in Account Currency",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "currency",
|
"options": "account_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
@ -269,13 +269,13 @@
|
|||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "debit_in_account_currency",
|
"fieldname": "debit_in_account_currency",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"hidden": 1,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 1,
|
||||||
"label": "Debit in Account Currency",
|
"label": "Debit in Account Currency",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "currency",
|
"options": "account_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@ -295,7 +295,7 @@
|
|||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 0,
|
||||||
"label": "Debit in Company Currency",
|
"label": "Debit in Company Currency",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "debit",
|
"oldfieldname": "debit",
|
||||||
@ -336,13 +336,13 @@
|
|||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "credit_in_account_currency",
|
"fieldname": "credit_in_account_currency",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"hidden": 1,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 1,
|
||||||
"label": "Credit in Account Currency",
|
"label": "Credit in Account Currency",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "currency",
|
"options": "account_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@ -362,7 +362,7 @@
|
|||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 0,
|
||||||
"label": "Credit in Company Currency",
|
"label": "Credit in Company Currency",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "credit",
|
"oldfieldname": "credit",
|
||||||
@ -520,7 +520,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-08-28 17:15:25.180681",
|
"modified": "2015-08-31 17:50:04.145031",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Journal Entry Account",
|
"name": "Journal Entry Account",
|
||||||
|
|||||||
@ -55,6 +55,25 @@ frappe.ui.form.on("Payment Tool", "party", function(frm) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
frappe.ui.form.on("Payment Tool", "party_account", function(frm) {
|
||||||
|
if(frm.doc.party_account) {
|
||||||
|
frm.call({
|
||||||
|
method: "frappe.client.get_value",
|
||||||
|
args: {
|
||||||
|
doctype: "Account",
|
||||||
|
fieldname: "account_currency",
|
||||||
|
filters: { name: frm.doc.party_account },
|
||||||
|
},
|
||||||
|
callback: function(r, rt) {
|
||||||
|
if(r.message) {
|
||||||
|
frm.set_value("party_account_currency", r.message.account_currency);
|
||||||
|
erpnext.payment_tool.check_mandatory_to_set_button(frm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
frappe.ui.form.on("Payment Tool", "company", function(frm) {
|
frappe.ui.form.on("Payment Tool", "company", function(frm) {
|
||||||
erpnext.payment_tool.check_mandatory_to_set_button(frm);
|
erpnext.payment_tool.check_mandatory_to_set_button(frm);
|
||||||
});
|
});
|
||||||
@ -63,10 +82,6 @@ frappe.ui.form.on("Payment Tool", "received_or_paid", function(frm) {
|
|||||||
erpnext.payment_tool.check_mandatory_to_set_button(frm);
|
erpnext.payment_tool.check_mandatory_to_set_button(frm);
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Payment Tool", "party", function(frm) {
|
|
||||||
erpnext.payment_tool.check_mandatory_to_set_button(frm);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Fetch bank/cash account based on payment mode
|
// Fetch bank/cash account based on payment mode
|
||||||
frappe.ui.form.on("Payment Tool", "payment_mode", function(frm) {
|
frappe.ui.form.on("Payment Tool", "payment_mode", function(frm) {
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
@ -158,7 +173,9 @@ frappe.ui.form.on("Payment Tool Detail", "against_voucher_no", function(frm, cdt
|
|||||||
method: 'erpnext.accounts.doctype.payment_tool.payment_tool.get_against_voucher_amount',
|
method: 'erpnext.accounts.doctype.payment_tool.payment_tool.get_against_voucher_amount',
|
||||||
args: {
|
args: {
|
||||||
"against_voucher_type": row.against_voucher_type,
|
"against_voucher_type": row.against_voucher_type,
|
||||||
"against_voucher_no": row.against_voucher_no
|
"against_voucher_no": row.against_voucher_no,
|
||||||
|
"party_account": self.party_account,
|
||||||
|
"company": self.company
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
@ -216,4 +233,4 @@ erpnext.payment_tool.check_mandatory_to_fetch = function(doc) {
|
|||||||
$.each(["Company", "Party Type", "Party", "Received or Paid"], function(i, field) {
|
$.each(["Company", "Party Type", "Party", "Received or Paid"], function(i, field) {
|
||||||
if(!doc[frappe.model.scrub(field)]) frappe.throw(__("Please select {0} first", [field]));
|
if(!doc[frappe.model.scrub(field)]) frappe.throw(__("Please select {0} first", [field]));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@
|
|||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Column Break 1",
|
"label": "",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@ -162,6 +162,29 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "party_account_currency",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 1,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Party Account Currency",
|
||||||
|
"no_copy": 1,
|
||||||
|
"options": "Currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -306,6 +329,7 @@
|
|||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Total Payment Amount",
|
"label": "Total Payment Amount",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
|
"options": "party_account_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
@ -450,7 +474,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"modified": "2015-06-05 11:17:33.843334",
|
"modified": "2015-08-31 18:58:21.813054",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Payment Tool",
|
"name": "Payment Tool",
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _, scrub
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
import json
|
import json
|
||||||
@ -38,7 +38,8 @@ class PaymentTool(Document):
|
|||||||
d1.set("reference_type", v.against_voucher_type)
|
d1.set("reference_type", v.against_voucher_type)
|
||||||
d1.set("reference_name", v.against_voucher_no)
|
d1.set("reference_name", v.against_voucher_no)
|
||||||
d1.set('is_advance', 'Yes' if v.against_voucher_type in ['Sales Order', 'Purchase Order'] else 'No')
|
d1.set('is_advance', 'Yes' if v.against_voucher_type in ['Sales Order', 'Purchase Order'] else 'No')
|
||||||
total_payment_amount = flt(total_payment_amount) + flt(d1.debit) - flt(d1.credit)
|
total_payment_amount = flt(total_payment_amount) + \
|
||||||
|
flt(d1.debit_in_account_currency) - flt(d1.credit_in_account_currency)
|
||||||
|
|
||||||
d2 = jv.append("accounts")
|
d2 = jv.append("accounts")
|
||||||
d2.account = self.payment_account
|
d2.account = self.payment_account
|
||||||
@ -57,11 +58,14 @@ def get_outstanding_vouchers(args):
|
|||||||
frappe.throw(_("No permission to use Payment Tool"), frappe.PermissionError)
|
frappe.throw(_("No permission to use Payment Tool"), frappe.PermissionError)
|
||||||
|
|
||||||
args = json.loads(args)
|
args = json.loads(args)
|
||||||
|
|
||||||
|
party_account_currency = frappe.db.get_value("Account", args.get("party_account"), "account_currency")
|
||||||
|
company_currency = frappe.db.get_value("Company", args.get("company"), "default_currency")
|
||||||
|
|
||||||
if args.get("party_type") == "Customer" and args.get("received_or_paid") == "Received":
|
if args.get("party_type") == "Customer" and args.get("received_or_paid") == "Received":
|
||||||
amount_query = "ifnull(debit, 0) - ifnull(credit, 0)"
|
amount_query = "ifnull(debit_in_account_currency, 0) - ifnull(credit_in_account_currency, 0)"
|
||||||
elif args.get("party_type") == "Supplier" and args.get("received_or_paid") == "Paid":
|
elif args.get("party_type") == "Supplier" and args.get("received_or_paid") == "Paid":
|
||||||
amount_query = "ifnull(credit, 0) - ifnull(debit, 0)"
|
amount_query = "ifnull(credit_in_account_currency, 0) - ifnull(debit_in_account_currency, 0)"
|
||||||
else:
|
else:
|
||||||
frappe.throw(_("Please enter the Against Vouchers manually"))
|
frappe.throw(_("Please enter the Against Vouchers manually"))
|
||||||
|
|
||||||
@ -70,27 +74,34 @@ def get_outstanding_vouchers(args):
|
|||||||
args.get("party_type"), args.get("party"))
|
args.get("party_type"), args.get("party"))
|
||||||
|
|
||||||
# Get all SO / PO which are not fully billed or aginst which full advance not paid
|
# Get all SO / PO which are not fully billed or aginst which full advance not paid
|
||||||
orders_to_be_billed = get_orders_to_be_billed(args.get("party_type"), args.get("party"))
|
orders_to_be_billed = get_orders_to_be_billed(args.get("party_type"), args.get("party"),
|
||||||
|
party_account_currency, company_currency)
|
||||||
return outstanding_invoices + orders_to_be_billed
|
return outstanding_invoices + orders_to_be_billed
|
||||||
|
|
||||||
def get_orders_to_be_billed(party_type, party):
|
def get_orders_to_be_billed(party_type, party, party_account_currency, company_currency):
|
||||||
voucher_type = 'Sales Order' if party_type == "Customer" else 'Purchase Order'
|
voucher_type = 'Sales Order' if party_type == "Customer" else 'Purchase Order'
|
||||||
|
|
||||||
|
ref_field = "base_grand_total" if party_account_currency == company_currency else "grand_total"
|
||||||
|
|
||||||
orders = frappe.db.sql("""
|
orders = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
name as voucher_no,
|
name as voucher_no,
|
||||||
ifnull(base_grand_total, 0) as invoice_amount,
|
ifnull({ref_field}, 0) as invoice_amount,
|
||||||
(ifnull(base_grand_total, 0) - ifnull(advance_paid, 0)) as outstanding_amount,
|
(ifnull({ref_field}, 0) - ifnull(advance_paid, 0)) as outstanding_amount,
|
||||||
transaction_date as posting_date
|
transaction_date as posting_date
|
||||||
from
|
from
|
||||||
`tab%s`
|
`tab{voucher_type}`
|
||||||
where
|
where
|
||||||
%s = %s
|
{party_type} = %s
|
||||||
and docstatus = 1
|
and docstatus = 1
|
||||||
and ifnull(status, "") != "Stopped"
|
and ifnull(status, "") != "Stopped"
|
||||||
and ifnull(base_grand_total, 0) > ifnull(advance_paid, 0)
|
and ifnull({ref_field}, 0) > ifnull(advance_paid, 0)
|
||||||
and abs(100 - ifnull(per_billed, 0)) > 0.01
|
and abs(100 - ifnull(per_billed, 0)) > 0.01
|
||||||
""" % (voucher_type, 'customer' if party_type == "Customer" else 'supplier', '%s'),
|
""".format(**{
|
||||||
party, as_dict = True)
|
"ref_field": ref_field,
|
||||||
|
"voucher_type": voucher_type,
|
||||||
|
"party_type": scrub(party_type)
|
||||||
|
}), party, as_dict = True)
|
||||||
|
|
||||||
order_list = []
|
order_list = []
|
||||||
for d in orders:
|
for d in orders:
|
||||||
@ -100,13 +111,19 @@ def get_orders_to_be_billed(party_type, party):
|
|||||||
return order_list
|
return order_list
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_against_voucher_amount(against_voucher_type, against_voucher_no):
|
def get_against_voucher_amount(against_voucher_type, against_voucher_no, party_account, company):
|
||||||
|
party_account_currency = frappe.db.get_value("Account", party_account, "account_currency")
|
||||||
|
company_currency = frappe.db.get_value("Company", company, "default_currency")
|
||||||
|
ref_field = "base_grand_total" if party_account_currency == company_currency else "grand_total"
|
||||||
|
|
||||||
if against_voucher_type in ["Sales Order", "Purchase Order"]:
|
if against_voucher_type in ["Sales Order", "Purchase Order"]:
|
||||||
select_cond = "base_grand_total as total_amount, ifnull(base_grand_total, 0) - ifnull(advance_paid, 0) as outstanding_amount"
|
select_cond = "{0} as total_amount, ifnull({0}, 0) - ifnull(advance_paid, 0) as outstanding_amount"\
|
||||||
|
.format(ref_field)
|
||||||
elif against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
|
elif against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
|
||||||
select_cond = "base_grand_total as total_amount, outstanding_amount"
|
select_cond = "{0} as total_amount, outstanding_amount".format(ref_field)
|
||||||
elif against_voucher_type == "Journal Entry":
|
elif against_voucher_type == "Journal Entry":
|
||||||
select_cond = "total_debit as total_amount"
|
ref_field = "total_debit" if party_account_currency == company_currency else "total_debit/exchange_rate"
|
||||||
|
select_cond = "{0} as total_amount".format(ref_field)
|
||||||
|
|
||||||
details = frappe.db.sql("""select {0} from `tab{1}` where name = %s"""
|
details = frappe.db.sql("""select {0} from `tab{1}` where name = %s"""
|
||||||
.format(select_cond, against_voucher_type), against_voucher_no, as_dict=1)
|
.format(select_cond, against_voucher_type), against_voucher_no, as_dict=1)
|
||||||
|
|||||||
@ -87,6 +87,7 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Total Amount",
|
"label": "Total Amount",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
|
"options": "party_account_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
@ -108,6 +109,7 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Outstanding Amount",
|
"label": "Outstanding Amount",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
|
"options": "party_account_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
@ -129,6 +131,7 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Payment Amount",
|
"label": "Payment Amount",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
|
"options": "party_account_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
@ -146,7 +149,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2014-09-11 08:55:34.384017",
|
"modified": "2015-08-31 18:58:35.537060",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Payment Tool Detail",
|
"name": "Payment Tool Detail",
|
||||||
|
|||||||
@ -83,12 +83,12 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
|||||||
method: "frappe.client.get_value",
|
method: "frappe.client.get_value",
|
||||||
args: {
|
args: {
|
||||||
doctype: "Account",
|
doctype: "Account",
|
||||||
fieldname: "currency",
|
fieldname: "account_currency",
|
||||||
filters: { name: me.frm.doc.credit_to },
|
filters: { name: me.frm.doc.credit_to },
|
||||||
},
|
},
|
||||||
callback: function(r, rt) {
|
callback: function(r, rt) {
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
me.frm.set_value("party_account_currency", r.message.currency);
|
me.frm.set_value("party_account_currency", r.message.account_currency);
|
||||||
me.set_dynamic_labels();
|
me.set_dynamic_labels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,13 +91,16 @@ class PurchaseInvoice(BuyingController):
|
|||||||
throw(_("Conversion rate cannot be 0 or 1"))
|
throw(_("Conversion rate cannot be 0 or 1"))
|
||||||
|
|
||||||
def validate_credit_to_acc(self):
|
def validate_credit_to_acc(self):
|
||||||
account = frappe.db.get_value("Account", self.credit_to, ["account_type", "report_type"], as_dict=True)
|
account = frappe.db.get_value("Account", self.credit_to,
|
||||||
|
["account_type", "report_type", "account_currency"], as_dict=True)
|
||||||
|
|
||||||
if account.report_type != "Balance Sheet":
|
if account.report_type != "Balance Sheet":
|
||||||
frappe.throw(_("Credit To account must be a Balance Sheet account"))
|
frappe.throw(_("Credit To account must be a Balance Sheet account"))
|
||||||
|
|
||||||
if self.supplier and account.account_type != "Payable":
|
if self.supplier and account.account_type != "Payable":
|
||||||
frappe.throw(_("Credit To account must be a Payable account"))
|
frappe.throw(_("Credit To account must be a Payable account"))
|
||||||
|
|
||||||
|
self.party_account_currency = account.account_currency
|
||||||
|
|
||||||
def check_for_stopped_status(self):
|
def check_for_stopped_status(self):
|
||||||
check_list = []
|
check_list = []
|
||||||
|
|||||||
@ -183,12 +183,12 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
method: "frappe.client.get_value",
|
method: "frappe.client.get_value",
|
||||||
args: {
|
args: {
|
||||||
doctype: "Account",
|
doctype: "Account",
|
||||||
fieldname: "currency",
|
fieldname: "account_currency",
|
||||||
filters: { name: me.frm.doc.debit_to },
|
filters: { name: me.frm.doc.debit_to },
|
||||||
},
|
},
|
||||||
callback: function(r, rt) {
|
callback: function(r, rt) {
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
me.frm.set_value("party_account_currency", r.message.currency);
|
me.frm.set_value("party_account_currency", r.message.account_currency);
|
||||||
me.set_dynamic_labels();
|
me.set_dynamic_labels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -271,13 +271,16 @@ class SalesInvoice(SellingController):
|
|||||||
reconcile_against_document(lst)
|
reconcile_against_document(lst)
|
||||||
|
|
||||||
def validate_debit_to_acc(self):
|
def validate_debit_to_acc(self):
|
||||||
account = frappe.db.get_value("Account", self.debit_to, ["account_type", "report_type"], as_dict=True)
|
account = frappe.db.get_value("Account", self.debit_to,
|
||||||
|
["account_type", "report_type", "account_currency"], as_dict=True)
|
||||||
|
|
||||||
if account.report_type != "Balance Sheet":
|
if account.report_type != "Balance Sheet":
|
||||||
frappe.throw(_("Debit To account must be a Balance Sheet account"))
|
frappe.throw(_("Debit To account must be a Balance Sheet account"))
|
||||||
|
|
||||||
if self.customer and account.account_type != "Receivable":
|
if self.customer and account.account_type != "Receivable":
|
||||||
frappe.throw(_("Debit To account must be a Receivable account"))
|
frappe.throw(_("Debit To account must be a Receivable account"))
|
||||||
|
|
||||||
|
self.party_account_currency = account.account_currency
|
||||||
|
|
||||||
def validate_fixed_asset_account(self):
|
def validate_fixed_asset_account(self):
|
||||||
"""Validate Fixed Asset and whether Income Account Entered Exists"""
|
"""Validate Fixed Asset and whether Income Account Entered Exists"""
|
||||||
|
|||||||
@ -525,7 +525,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
var outstanding_amount = flt(total_amount_to_pay, precision("outstanding_amount"));
|
var outstanding_amount = flt(total_amount_to_pay, precision("outstanding_amount"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.frm.doc.party_account_currency == this.frm.doc.currency) {
|
if(this.frm.doc.party_account_currency == this.frm.doc.currency) {
|
||||||
this.frm.set_value("outstanding_amount", outstanding_amount);
|
this.frm.set_value("outstanding_amount", outstanding_amount);
|
||||||
} else {
|
} else {
|
||||||
this.frm.set_value("outstanding_amount",
|
this.frm.set_value("outstanding_amount",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user