From 7f940f3954d8a7d75538e2c9a1fdf8da905acb96 Mon Sep 17 00:00:00 2001 From: Tyler Matteson Date: Wed, 1 Mar 2023 08:54:11 -0500 Subject: [PATCH] V14 party lookup (#68) * fix: remove check_digit argument in ACH generation * feat: look up party on PE submission to avoid renaming problems --- .../check_run/doctype/check_run/check_run.py | 17 ++++++++++++++--- check_run/public/js/check_run/CheckRun.vue | 12 +++++++++--- docs/exampledata.md | 2 ++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/check_run/check_run/doctype/check_run/check_run.py b/check_run/check_run/doctype/check_run/check_run.py index a4b715f3..a708e0a5 100644 --- a/check_run/check_run/doctype/check_run/check_run.py +++ b/check_run/check_run/doctype/check_run/check_run.py @@ -103,7 +103,8 @@ def validate_transactions(self): for t in selected: if not t['mode_of_payment']: frappe.throw(frappe._(f"Mode of Payment Required: {t['party_name']} {t['ref_number']}")) - if frappe.get_value(t['doctype'], filters=t['name'], fieldname='docstatus') != 1: + filters = {'name': t['name'] if t['doctype'] != 'Journal Entry' else t['ref_number']} + if frappe.get_value(t['doctype'], filters, 'docstatus') != 1: wrong_status.append({'party_name': t['party_name'], 'ref_number': t['ref_number'] or '', 'name': t['name']}) if len(wrong_status) < 1: return @@ -208,6 +209,12 @@ def create_payment_entries(self, transactions): continue for group in groups: _references = [] + if group[0].doctype == 'Purchase Invoice': + party = frappe.db.get_value('Purchase Invoice', group[0].name, 'supplier') + elif group[0].doctype == 'Expense Claim': + party = frappe.db.get_value('Expense Claim', group[0].name, 'employee') + elif group[0].doctype == 'Journal Entry': + party = frappe.db.get_value('Journal Entry Account', group[0].name, 'party') pe = frappe.new_doc("Payment Entry") pe.payment_type = "Pay" pe.posting_date = nowdate() @@ -236,9 +243,13 @@ def create_payment_entries(self, transactions): if settings.automatically_release_on_hold_invoices and reference.doctype == 'Purchase Invoice': if frappe.get_value(reference.doctype, reference.name, 'on_hold'): frappe.db.set_value(reference.doctype, reference.name, 'on_hold', 0) + if reference.doctype == 'Journal Entry': + reference_name = reference.ref_number + else: + reference_name = reference.name or reference.ref_number pe.append('references', { "reference_doctype": reference.doctype, - "reference_name": reference.name or reference.ref_number, + "reference_name": reference_name, "due_date": reference.get("due_date"), "outstanding_amount": flt(reference.amount), "allocated_amount": flt(reference.amount), @@ -445,7 +456,7 @@ def get_entries(doc): .select( ConstantColumn('Journal Entry').as_('doctype'), je_accounts.party_type, - journal_entries.name, + je_accounts.name, (journal_entries.name).as_('ref_number'), je_accounts.party, (je_accounts.party).as_('party_name'), diff --git a/check_run/public/js/check_run/CheckRun.vue b/check_run/public/js/check_run/CheckRun.vue index 03f40fe2..3777a888 100644 --- a/check_run/public/js/check_run/CheckRun.vue +++ b/check_run/public/js/check_run/CheckRun.vue @@ -135,9 +135,15 @@ export default { }, methods: { transactionUrl: transaction => { - return encodeURI( - `${frappe.urllib.get_base_url()}/app/${transaction.doctype.toLowerCase().replace(' ', '-')}/${transaction.name}` - ) + if(transaction.doctype !== 'Journal Entry'){ + return encodeURI( + `${frappe.urllib.get_base_url()}/app/${transaction.doctype.toLowerCase().replace(' ', '-')}/${transaction.name}` + ) + } else { + return encodeURI( + `${frappe.urllib.get_base_url()}/app/${transaction.doctype.toLowerCase().replace(' ', '-')}/${transaction.ref_number}` + ) + } }, paymentEntryUrl: transaction => { if (!transaction.payment_entry) { diff --git a/docs/exampledata.md b/docs/exampledata.md index f9d48de8..cc1fc568 100644 --- a/docs/exampledata.md +++ b/docs/exampledata.md @@ -8,6 +8,8 @@ With `bench start` running in the background, run the following command to insta ```shell bench execute 'check_run.test_setup.before_test' +# to reinstall from scratch and setup test data +bench reinstall --yes --admin-password admin --mariadb-root-password admin && bench execute 'check_run.test_setup.before_test' ``` Refer to the [installation guide](./installationguide.md) for detailed instructions for how to set up a bench, a new site, and installing ERPNext and the Check Run application.