fix: permission error after submitting exchange rate revaluation (#25432)
This commit is contained in:
parent
e3b8057eb4
commit
3d4acf9e5c
@ -21,21 +21,17 @@ frappe.ui.form.on('Exchange Rate Revaluation', {
|
|||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
if(frm.doc.docstatus==1) {
|
if(frm.doc.docstatus==1) {
|
||||||
frappe.db.get_value("Journal Entry Account", {
|
frappe.call({
|
||||||
'reference_type': 'Exchange Rate Revaluation',
|
method: 'check_journal_entry_condition',
|
||||||
'reference_name': frm.doc.name,
|
doc: frm.doc,
|
||||||
'docstatus': 1
|
callback: function(r) {
|
||||||
}, "sum(debit) as sum", (r) =>{
|
if (r.message) {
|
||||||
let total_amt = 0;
|
frm.add_custom_button(__('Journal Entry'), function() {
|
||||||
frm.doc.accounts.forEach(d=> {
|
return frm.events.make_jv(frm);
|
||||||
total_amt = total_amt + d['new_balance_in_base_currency'];
|
}, __('Create'));
|
||||||
});
|
}
|
||||||
if(total_amt !== r.sum) {
|
|
||||||
frm.add_custom_button(__('Journal Entry'), function() {
|
|
||||||
return frm.events.make_jv(frm);
|
|
||||||
}, __('Create'));
|
|
||||||
}
|
}
|
||||||
}, 'Journal Entry');
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -27,6 +27,23 @@ class ExchangeRateRevaluation(Document):
|
|||||||
if not (self.company and self.posting_date):
|
if not (self.company and self.posting_date):
|
||||||
frappe.throw(_("Please select Company and Posting Date to getting entries"))
|
frappe.throw(_("Please select Company and Posting Date to getting entries"))
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def check_journal_entry_condition(self):
|
||||||
|
total_debit = frappe.db.get_value("Journal Entry Account", {
|
||||||
|
'reference_type': 'Exchange Rate Revaluation',
|
||||||
|
'reference_name': self.name,
|
||||||
|
'docstatus': 1
|
||||||
|
}, "sum(debit) as sum")
|
||||||
|
|
||||||
|
total_amt = 0
|
||||||
|
for d in self.accounts:
|
||||||
|
total_amt = total_amt + d.new_balance_in_base_currency
|
||||||
|
|
||||||
|
if total_amt != total_debit:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_accounts_data(self, account=None):
|
def get_accounts_data(self, account=None):
|
||||||
accounts = []
|
accounts = []
|
||||||
|
Loading…
Reference in New Issue
Block a user