Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions check_run/check_run/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import json

import frappe

from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import PurchaseInvoice
from erpnext.accounts.doctype.journal_entry.journal_entry import JournalEntry
from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import PurchaseInvoice
from hrms.hr.doctype.expense_claim.expense_claim import ExpenseClaim


Expand Down
13 changes: 13 additions & 0 deletions check_run/check_run/doctype/check_run/check_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ frappe.ui.form.on('Check Run', {
e.stopPropagation()
})
}
change_amount_label(frm)
settings_button(frm)
permit_first_user(frm)
get_defaults(frm)
Expand Down Expand Up @@ -445,3 +446,15 @@ function check_settings(frm) {
})
}
}

function change_amount_label(frm) {
frappe
.xcall('check_run.check_run.doctype.check_run.check_run.get_default_currency', { company: frm.doc.company })
.then(r => {
if (r) {
if (r != frm.pay_to_account_currency) {
cur_frm.fields_dict.amount_check_run.set_label('Estimated Amount in Check Run')
}
}
})
}
5 changes: 5 additions & 0 deletions check_run/check_run/doctype/check_run/check_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,3 +921,8 @@ def get_authorized_role_for_ach(doc):
"role_allowed_to_download_ach_file_multiple_times",
)
return role


@frappe.whitelist()
def get_default_currency(company):
return frappe.db.get_value("Company", company, "default_currency")
3 changes: 2 additions & 1 deletion check_run/check_run/doctype/check_run/test_check_run.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright (c) 2022, AgriTheory and Contributors
# See license.txt

import frappe
import unittest

import frappe


class TestCheckRun(unittest.TestCase):
pass
11 changes: 6 additions & 5 deletions check_run/overrides/payment_entry.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Copyright (c) 2023, AgriTheory and contributors
# For license information, please see license.txt

import json

import frappe
from frappe.utils import get_link_to_form, comma_and, flt
from erpnext.accounts.general_ledger import make_gl_entries, process_gl_map
from frappe.utils.data import getdate
from erpnext.accounts.doctype.payment_entry.payment_entry import (
PaymentEntry,
get_outstanding_reference_documents,
)
from erpnext.accounts.general_ledger import make_gl_entries, process_gl_map
from frappe import _
import json
from frappe.utils import comma_and, flt, get_link_to_form
from frappe.utils.data import getdate


class CheckRunPaymentEntry(PaymentEntry):
Expand Down Expand Up @@ -60,7 +61,7 @@ def get_valid_reference_doctypes(self):
"""
Because Check Run processes multiple payment entries in a background queue, errors generally do not include
enough data to identify the problem since there were written and remain appropriate for the context of an individual
Payment Entry. This code is copied from:
Payment Entry. This code is copied from:

https://github.com/frappe/erpnext/blob/version-14/erpnext/accounts/doctype/payment_entry/payment_entry.py#L164

Expand Down
15 changes: 13 additions & 2 deletions check_run/public/js/check_run/check_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,22 @@ check_run.mount = frm => {
frm.$check_run.provide('$check_run', check_run)
}

check_run.total = frm => {
check_run.total = async frm => {
let _frm = unref(frm)
let r = Object.values(check_run.transactions).reduce((partialSum, t) => {
return t.pay ? partialSum + t.amount : partialSum
}, 0)
_frm.set_value('amount_check_run', r)

var company_currency = frappe.get_doc(':Company', _frm.doc.company).default_currency

var amount_check_run = await frappe.xcall('erpnext.setup.utils.get_exchange_rate', {
from_currency: _frm.pay_to_account_currency,
to_currency: company_currency,
})
if (r > 0) {
_frm.set_value('amount_check_run', r * amount_check_run)
} else {
_frm.set_value('amount_check_run', r)
}
return r
}
7 changes: 3 additions & 4 deletions check_run/tests/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import types

import frappe
from frappe.utils.data import add_days, flt
from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
from erpnext.setup.utils import enable_all_roles_and_domains, set_defaults_for_tests
from erpnext.accounts.doctype.account.account import update_account_number
from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import make_debit_note

from erpnext.setup.utils import enable_all_roles_and_domains, set_defaults_for_tests
from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
from frappe.utils.data import add_days, flt

from check_run.tests.fixtures import employees, suppliers, tax_authority

Expand Down