From eaf4cfedbab535f1417eab13d46aea319f1077d4 Mon Sep 17 00:00:00 2001 From: Tyler Matteson Date: Wed, 3 Aug 2022 16:40:29 -0400 Subject: [PATCH 1/3] wip: quick entry improvements, general refactoring --- README.md | 30 +---------- check_run/__init__.py | 2 +- .../doctype/check_run/check_run.json | 13 +++-- .../check_run/doctype/check_run/check_run.py | 24 +++------ .../js/check_run/check_run_quick_entry.js | 53 +++++++------------ check_run/test_setup.py | 40 +++++++++++--- 6 files changed, 68 insertions(+), 94 deletions(-) diff --git a/README.md b/README.md index 9b2d5469..1f9756a9 100644 --- a/README.md +++ b/README.md @@ -43,33 +43,7 @@ nano site_config.json "developer_mode": 1 ``` -Restore the database +Setup demo data or test data ``` -mysql -u root -p {{ site name }} < {{data base file path}}.sql +bench execute 'check_run.check_run.doctype.check_run.test_data.create_test_data' ``` -Set a new password for the local Administrator that is not the same as the production Administrator password -``` -bench set-admin-password {{local password}} -``` - -Migrate, build and get the site ready -``` -bench start -``` -In a new terminal window -``` -bench update -``` -### Testing -#### Running Cypress tests -To set up local Cypress tests; -```bash -cd apps/check_run -yarn -``` -Additional steps may be required on WSL, use Nicky's guide: -https://nickymeuleman.netlify.app/blog/gui-on-wsl2-cypress - -```bash -yarn run cypress open -``` \ No newline at end of file diff --git a/check_run/__init__.py b/check_run/__init__.py index 7a0660b4..12ab10eb 100644 --- a/check_run/__init__.py +++ b/check_run/__init__.py @@ -1,3 +1,3 @@ -__version__ = '0.0.1' +__version__ = '13.0.0' diff --git a/check_run/check_run/doctype/check_run/check_run.json b/check_run/check_run/doctype/check_run/check_run.json index 85a92149..6c6f67a1 100644 --- a/check_run/check_run/doctype/check_run/check_run.json +++ b/check_run/check_run/doctype/check_run/check_run.json @@ -22,7 +22,6 @@ "pay_to_account", "section_break_9", "check_run_table", - "html_15", "transactions", "amended_from", "print_count", @@ -48,6 +47,7 @@ "allow_on_submit": 1, "fieldname": "initial_check_number", "fieldtype": "Int", + "in_list_view": 1, "label": "Initial Check Number" }, { @@ -74,6 +74,7 @@ "allow_in_quick_entry": 1, "fieldname": "company", "fieldtype": "Link", + "in_standard_filter": 1, "label": "Company", "options": "Company", "remember_last_selected_value": 1, @@ -94,6 +95,7 @@ "default": "company.default_payable_account", "fieldname": "pay_to_account", "fieldtype": "Link", + "in_standard_filter": 1, "label": "Accounts Payable", "options": "Account", "remember_last_selected_value": 1, @@ -123,6 +125,8 @@ { "fieldname": "check_run_date", "fieldtype": "Date", + "in_list_view": 1, + "in_standard_filter": 1, "label": "Check Run Date" }, { @@ -149,16 +153,11 @@ { "fieldname": "check_run_table", "fieldtype": "HTML" - }, - { - "default": "", - "fieldname": "html_15", - "fieldtype": "HTML" } ], "is_submittable": 1, "links": [], - "modified": "2022-07-10 16:16:03.289288", + "modified": "2022-08-03 16:34:50.373207", "modified_by": "Administrator", "module": "Check Run", "name": "Check Run", 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 780cdc08..cee5b918 100644 --- a/check_run/check_run/doctype/check_run/check_run.py +++ b/check_run/check_run/doctype/check_run/check_run.py @@ -106,7 +106,6 @@ def ach_only(self): def create_payment_entries(self, transactions): check_count = 0 _transactions = [] - account_currency = frappe.get_value('Account', self.pay_to_account, 'account_currency') gl_account = frappe.get_value('Bank Account', self.bank_account, 'account') for party_ref, _group in groupby(transactions, key=lambda x: x.party_ref): _group = list(_group) @@ -119,16 +118,12 @@ def create_payment_entries(self, transactions): pe = frappe.new_doc("Payment Entry") pe.payment_type = "Pay" pe.posting_date = nowdate() - project = self.get_dimensions_from_references(group, 'project') - if project != 'None' and project: - pe.project = project - cost_center = self.get_dimensions_from_references(group, 'cost_center') - if cost_center != 'None' and project: - pe.cost_center = cost_center pe.mode_of_payment = group[0].mode_of_payment pe.company = self.company pe.paid_from = gl_account pe.paid_to = self.pay_to_account + pe.paid_to_account_currency = frappe.db.get_value("Account", self.bank_account, "account_currency") + pe.paid_from_account_currency = pe.paid_to_account_currency pe.reference_date = self.check_run_date pe.party = party_ref pe.party_type = 'Supplier' if group[0].doctype == 'Purchase Invoice' else 'Employee' @@ -139,7 +134,7 @@ def create_payment_entries(self, transactions): check_count += 1 else: pe.reference_no = self.name - + for reference in group: if not reference: continue @@ -147,21 +142,17 @@ def create_payment_entries(self, transactions): "reference_doctype": reference.doctype, "reference_name": reference.name or reference.ref_number, "due_date": reference.get("due_date"), - "outstanding_amount": flt(reference.amount), - "allocated_amount": flt(reference.amount), - "total_amount": flt(reference.amount), + "outstanding_amount": flt(reference.outstanding_amount), + "allocated_amount": flt(reference.outstanding_amount), + "total_amount": flt(reference.outstanding_amount), }) - total_amount += reference.amount + total_amount += reference.outstanding_amount reference.check_number = pe.reference_no _references.append(reference) pe.received_amount = total_amount pe.base_received_amount = total_amount pe.paid_amount = total_amount pe.base_paid_amount = total_amount - pe.paid_from_account_currency = account_currency - pe.paid_to_account_currency = account_currency - pe.target_exchange_rate = 1.0 - pe.source_exchange_rate = 1.0 pe.save() pe.submit() for reference in _references: @@ -169,6 +160,7 @@ def create_payment_entries(self, transactions): _transactions.append(reference) return _transactions + def get_dimensions_from_references(self, references, dimension): dimensions, default_dimensions = get_dimensions(with_cost_center_and_project=True) parents = [reference.get('name') for reference in references if reference] diff --git a/check_run/public/js/check_run/check_run_quick_entry.js b/check_run/public/js/check_run/check_run_quick_entry.js index 96339e97..b35fbed8 100644 --- a/check_run/public/js/check_run/check_run_quick_entry.js +++ b/check_run/public/js/check_run/check_run_quick_entry.js @@ -4,7 +4,7 @@ frappe.ui.form.CheckRunQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ init: function (doctype, after_insert) { this._super(doctype, after_insert) }, - render_dialog: function () { + render_dialog: function() { this.mandatory = this.get_fields() this._super() this.dialog.$wrapper.find('.btn-secondary').hide() @@ -23,40 +23,12 @@ frappe.ui.form.CheckRunQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ } } } - frappe.db.get_value('Bank Account', { - company: frappe.defaults.get_default('company'), - is_default: 1, - is_company_account: 1 - }, 'name') - .then(r => { - this.dialog.fields_dict["bank_account"].set_value(r.message.name) - }) - frappe.db.get_value('Company', { - name: frappe.defaults.get_default('company'), - }, 'default_payable_account') - .then(r => { - this.dialog.fields_dict["pay_to_account"].set_value(r.message.default_payable_account) - }) this.dialog.fields_dict["company"].df.onchange = () => { - const values = dialog.get_values() - if(!values.company){ return } - frappe.db.get_value('Bank Account', { - company: values.company, - is_default: 1, - is_company_account: 1 - }, 'name') - .then(r => { - this.dialog.fields_dict["bank_account"].set_value(r.message.name) - }) - frappe.db.get_value('Company', { - company: values.company, - }, 'default_payable_account') - .then(r => { - this.dialog.fields_dict["pay_to_account"].set_value(r.message.default_payable_account) - }) + this.default_accounts() } + this.default_accounts() }, - get_fields: () => { + get_fields: function() { return [ { label: __("Company"), @@ -66,7 +38,7 @@ frappe.ui.form.CheckRunQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ reqd: 1, }, { - label: __("Paid From (Bank Account)"), + label: __("Paid From (Bank Account"), fieldname: "bank_account", fieldtype: "Link", options: "Bank Account", @@ -84,12 +56,23 @@ frappe.ui.form.CheckRunQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ register_primary_action: function() { const me = this this.dialog.set_primary_action(__('Start Check Run'), () => { - const values = me.dialog.get_values() + let values = me.dialog.get_values() frappe.xcall("check_run.check_run.doctype.check_run.check_run.check_for_draft_check_run", - { company: values.company, bank_account: values.bank_account, payable_account: values.pay_to_account } + { company: values.company, bank_account: values.bank_account } ).then(r => { frappe.set_route("Form", "Check Run", r) }) }) }, + default_accounts: function() { + let company = this.dialog.fields_dict.company.get_value() + frappe.db.get_value('Company', company, 'default_payable_account') + .then(r => { + this.dialog.fields_dict["pay_to_account"].set_value(r.message.default_payable_account) + }) + frappe.db.get_value('Bank Account', {company: company, is_default: 1, is_company_account: 1}, 'name') + .then(r => { + this.dialog.fields_dict["bank_account"].set_value(r.message.name) + }) + } }) diff --git a/check_run/test_setup.py b/check_run/test_setup.py index d06a1955..021ddca5 100644 --- a/check_run/test_setup.py +++ b/check_run/test_setup.py @@ -44,6 +44,7 @@ def before_test(): ("Local Tax Authority", "Payroll Taxes", "Check", 0.00), ] +<<<<<<< Updated upstream:check_run/test_setup.py settings = frappe._dict({}) def create_test_data(): @@ -61,9 +62,26 @@ def create_test_data(): create_employees() create_expense_claim() create_payroll_journal_entry() +======= +def create_test_data(): + settings = frappe._dict({ + 'day': datetime.date(int(frappe.defaults.get_defaults().get('fiscal_year')), 1 ,1), + 'company': frappe.defaults.get_defaults().get('company'), + 'company_account': frappe.get_value("Account", + {"account_type": "Bank", "company": frappe.defaults.get_defaults().get('company'), "is_group": 0}), + }) + create_bank_and_bank_account(settings) + create_suppliers(settings) + create_items(settings) + create_invoices(settings) + config_expense_claim(settings) + create_employees(settings) + create_expense_claim(settings) + create_payroll_journal_entry(settings) +>>>>>>> Stashed changes:check_run/check_run/doctype/check_run/test_data.py -def create_bank_and_bank_account(): +def create_bank_and_bank_account(settings): if not frappe.db.exists('Mode of Payment', 'ACH/EFT'): mop = frappe.new_doc('Mode of Payment') mop.mode_of_payment = 'ACH/EFT' @@ -94,12 +112,16 @@ def create_bank_and_bank_account(): doc.company = settings.company opening_balance = 10000.00 doc.append("accounts", {"account": settings.company_account, "debit_in_account_currency": opening_balance}) +<<<<<<< Updated upstream:check_run/test_setup.py retained_earnings = frappe.get_value('Account', {'account_name': "Retained Earnings"}) +======= + retained_earnings = frappe.get_value('Account', {'account_name': "Retained Earnings", 'company': settings.company}) +>>>>>>> Stashed changes:check_run/check_run/doctype/check_run/test_data.py doc.append("accounts", {"account": retained_earnings, "credit_in_account_currency": opening_balance}) doc.save() doc.submit() -def create_suppliers(): +def create_suppliers(settings): for supplier in suppliers + tax_authority: biz = frappe.new_doc("Supplier") biz.supplier_name = supplier[0] @@ -110,7 +132,7 @@ def create_suppliers(): biz.default_price_list = "Standard Buying" biz.save() -def create_items(): +def create_items(settings): for supplier in suppliers + tax_authority: item = frappe.new_doc("Item") item.item_code = item.item_name = supplier[1] @@ -124,7 +146,7 @@ def create_items(): item.append("item_defaults", {"company": settings.company, "default_warehouse": "", "default_supplier": supplier[0]}) item.save() -def create_invoices(): +def create_invoices(settings): # first month - already paid for supplier in suppliers: pi = frappe.new_doc('Purchase Invoice') @@ -183,7 +205,7 @@ def create_invoices(): pi.submit() -def config_expense_claim(): +def config_expense_claim(settings): try: travel_expense_account = frappe.get_value('Account', {'account_name': 'Travel Expenses', 'company': settings.company}) travel = frappe.get_doc('Expense Claim Type', 'Travel') @@ -203,7 +225,7 @@ def config_expense_claim(): pta.save() -def create_employees(): +def create_employees(settings): for employee_number in range(1, 13): emp = frappe.new_doc('Employee') emp.first_name = "Test" @@ -222,7 +244,7 @@ def create_employees(): emp.save() -def create_expense_claim(): +def create_expense_claim(settings): # first month - paid ec = frappe.new_doc('Expense Claim') ec.employee = "Test Employee 2" @@ -272,7 +294,11 @@ def create_expense_claim(): ec.submit() +<<<<<<< Updated upstream:check_run/test_setup.py def create_payroll_journal_entry(): +======= +def create_payroll_journal_entry(settings): +>>>>>>> Stashed changes:check_run/check_run/doctype/check_run/test_data.py emps = frappe.get_list('Employee', {'company': settings.company}) cost_center = frappe.get_value('Company', settings.company, 'cost_center') payroll_account = frappe.get_value('Account', {'company': settings.company, 'account_name': 'Payroll Payable', 'is_group': 0}) From ba6029a6ccf843acd70393a505fc1ff885cba206 Mon Sep 17 00:00:00 2001 From: Tyler Matteson Date: Wed, 3 Aug 2022 17:28:25 -0400 Subject: [PATCH 2/3] feat: add mop alert --- check_run/public/js/check_run/CheckRun.vue | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/check_run/public/js/check_run/CheckRun.vue b/check_run/public/js/check_run/CheckRun.vue index 073c6894..a68c4674 100644 --- a/check_run/public/js/check_run/CheckRun.vue +++ b/check_run/public/js/check_run/CheckRun.vue @@ -62,8 +62,14 @@ class="mop-onclick" :data-mop-index="i" > - - + {{ transactions[i].mode_of_payment }} @@ -74,7 +80,7 @@ type="checkbox" class="input-with-feedback checkrun-check-box" data-fieldtype="Check" - @change="onPayChange()" + @change="onPayChange(i)" :data-checkbox-index="i" v-model="item.pay" :id="item.id" />Pay @@ -116,7 +122,7 @@ export default { cur_frm.doc.amount_check_run = cur_frm.check_run_state.check_run_total() cur_frm.refresh_field("amount_check_run") cur_frm.dirty(); - }, + } }, methods: { transactionUrl: transactionId => { @@ -145,17 +151,21 @@ export default { markDirty() { cur_frm.dirty() }, - onPayChange() { + onPayChange(selectedRow) { cur_frm.doc.amount_check_run = cur_frm.check_run_state.check_run_total() cur_frm.refresh_field("amount_check_run") this.markDirty() + console.log(this.transactions[selectedRow].pay == true) + if(this.transactions[selectedRow].pay && !this.transactions[selectedRow].mode_of_payment){ + frappe.show_alert(__('Please add a Mode of Payment for this row')) + } }, checkPay() { if(this.state.docstatus >= 1 || !this.transactions.length) { return } this.transactions[this.state.selectedRow].pay = !this.transactions[this.state.selectedRow].pay - this.onPayChange() + this.onPayChange(this.state.selectedRow) }, openMopWithSearch(keycode) { From 219ea34b926162829971b1b6dd23587a95e8f45a Mon Sep 17 00:00:00 2001 From: Tyler Matteson Date: Fri, 5 Aug 2022 10:56:55 -0400 Subject: [PATCH 3/3] wip: testing and setup --- .../check_run/doctype/check_run/check_run.py | 25 ++++++----- check_run/public/js/check_run/CheckRun.vue | 43 +++++++------------ check_run/public/js/check_run/check_run.js | 10 ++--- .../js/check_run/check_run_quick_entry.js | 2 +- check_run/test_setup.py | 31 +------------ 5 files changed, 36 insertions(+), 75 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 cee5b918..5d37784b 100644 --- a/check_run/check_run/doctype/check_run/check_run.py +++ b/check_run/check_run/doctype/check_run/check_run.py @@ -97,6 +97,7 @@ def ach_only(self): ach_only.ach_only = False ach_only.print_checks_only = False return ach_only + # TODO: refactor to use bank flag on MoPs if any([t.get('mode_of_payment') == 'Check' for t in transactions]): ach_only.ach_only = False if any([t.get('mode_of_payment') in ('ACH/EFT', 'ECheck') for t in transactions]): @@ -107,7 +108,7 @@ def create_payment_entries(self, transactions): check_count = 0 _transactions = [] gl_account = frappe.get_value('Bank Account', self.bank_account, 'account') - for party_ref, _group in groupby(transactions, key=lambda x: x.party_ref): + for party, _group in groupby(transactions, key=lambda x: x.party): _group = list(_group) # split checks in groups of 5 if first reference is a check groups = list(zip_longest(*[iter(_group)] * 5)) if _group[0].mode_of_payment == 'Check' else [_group] @@ -125,8 +126,8 @@ def create_payment_entries(self, transactions): pe.paid_to_account_currency = frappe.db.get_value("Account", self.bank_account, "account_currency") pe.paid_from_account_currency = pe.paid_to_account_currency pe.reference_date = self.check_run_date - pe.party = party_ref - pe.party_type = 'Supplier' if group[0].doctype == 'Purchase Invoice' else 'Employee' + pe.party_type = group[0].party_type + pe.party = group[0].party pe.check_run = self.name total_amount = 0 if pe.mode_of_payment == 'Check': @@ -142,17 +143,18 @@ def create_payment_entries(self, transactions): "reference_doctype": reference.doctype, "reference_name": reference.name or reference.ref_number, "due_date": reference.get("due_date"), - "outstanding_amount": flt(reference.outstanding_amount), - "allocated_amount": flt(reference.outstanding_amount), - "total_amount": flt(reference.outstanding_amount), + "outstanding_amount": flt(reference.amount), + "allocated_amount": flt(reference.amount), + "total_amount": flt(reference.amount), }) - total_amount += reference.outstanding_amount + total_amount += reference.amount reference.check_number = pe.reference_no _references.append(reference) pe.received_amount = total_amount pe.base_received_amount = total_amount pe.paid_amount = total_amount pe.base_paid_amount = total_amount + print(pe.as_json()) pe.save() pe.submit() for reference in _references: @@ -267,7 +269,6 @@ def get_entries(doc): `tabPurchase Invoice`.name, `tabPurchase Invoice`.bill_no AS ref_number, `tabPurchase Invoice`.supplier_name AS party, - `tabPurchase Invoice`.supplier AS party_ref, `tabPurchase Invoice`.outstanding_amount AS amount, `tabPurchase Invoice`.due_date, `tabPurchase Invoice`.posting_date, @@ -288,7 +289,6 @@ def get_entries(doc): `tabExpense Claim`.name, `tabExpense Claim`.name AS ref_number, `tabExpense Claim`.employee_name AS party, - `tabExpense Claim`.employee AS party_ref, `tabExpense Claim`.grand_total AS amount, `tabExpense Claim`.posting_date AS due_date, `tabExpense Claim`.posting_date, @@ -303,13 +303,12 @@ def get_entries(doc): UNION ( SELECT 'Journal Entry' AS doctype, + `tabJournal Entry Account`.party_type, `tabJournal Entry`.name, `tabJournal Entry`.name AS ref_number, - `tabJournal Entry Account`.party AS party, - `tabJournal Entry Account`.party AS party_ref, - `tabJournal Entry Account`.party_type, + `tabJournal Entry Account`.party, `tabJournal Entry Account`.credit_in_account_currency AS amount, - `tabJournal Entry`.due_date AS due_date, + `tabJournal Entry`.due_date, `tabJournal Entry`.posting_date, COALESCE(`tabJournal Entry`.mode_of_payment, '\n') AS mode_of_payment FROM `tabJournal Entry`, `tabJournal Entry Account` diff --git a/check_run/public/js/check_run/CheckRun.vue b/check_run/public/js/check_run/CheckRun.vue index a68c4674..27c8ae9d 100644 --- a/check_run/public/js/check_run/CheckRun.vue +++ b/check_run/public/js/check_run/CheckRun.vue @@ -51,7 +51,7 @@ {{ item.party }} {{ item.ref_number || item.name}} @@ -86,7 +86,7 @@ :id="item.id" />Pay - + {{ item.check_number }} @@ -121,32 +121,27 @@ export default { cur_frm.check_run_state.transactions.forEach(row => { row.pay = val }) cur_frm.doc.amount_check_run = cur_frm.check_run_state.check_run_total() cur_frm.refresh_field("amount_check_run") - cur_frm.dirty(); + cur_frm.dirty() } }, methods: { - transactionUrl: transactionId => { - if(!this.transactions) { - return "" - } - return encodeURI(frappe.urllib.get_base_url() + "/app/" + this.transactions[transactionId].doctype.toLowerCase().replace(" ", "-") + "/" + this.transactions[transactionId].name) + transactionUrl: transaction => { + return encodeURI(`${frappe.urllib.get_base_url()}/app/${transaction.doctype.toLowerCase().replace(" ", "-")}/${transaction.name}`) }, - paymentEntryUrl: transactionId => { - if(!this.transactions) { - return ""; - } - return encodeURI(frappe.urllib.get_base_url() + "/app/payment-entry/" + this.transactions[i].payment_entry ); + paymentEntryUrl: transaction => { + if(transaction.payment_entry) { return "" } + return encodeURI(`${frappe.urllib.get_base_url()}/app/payment-entry/${transaction.payment_entry}`) }, sortTransactions(key) { - this.transactions.sort((a, b) => (a[key] > b[key] ? this.sort_order[key] : this.sort_order[key] * -1)); - this.sort_order[key] *= -1; + this.transactions.sort((a, b) => (a[key] > b[key] ? this.sort_order[key] : this.sort_order[key] * -1)) + this.sort_order[key] *= -1 }, partyIsInFilter(party) { - return cur_frm.check_run_state.party_filter.length < 1 || party.toLowerCase().includes(cur_frm.check_run_state.party_filter.toLowerCase()); + return cur_frm.check_run_state.party_filter.length < 1 || party.toLowerCase().includes(cur_frm.check_run_state.party_filter.toLowerCase()) }, toggleShowPartyFilter() { - cur_frm.check_run_state.party_filter = ""; - cur_frm.check_run_state.show_party_filter = !cur_frm.check_run_state.show_party_filter; + cur_frm.check_run_state.party_filter = "" + cur_frm.check_run_state.show_party_filter = !cur_frm.check_run_state.show_party_filter }, markDirty() { cur_frm.dirty() @@ -155,7 +150,6 @@ export default { cur_frm.doc.amount_check_run = cur_frm.check_run_state.check_run_total() cur_frm.refresh_field("amount_check_run") this.markDirty() - console.log(this.transactions[selectedRow].pay == true) if(this.transactions[selectedRow].pay && !this.transactions[selectedRow].mode_of_payment){ frappe.show_alert(__('Please add a Mode of Payment for this row')) } @@ -168,20 +162,16 @@ export default { this.onPayChange(this.state.selectedRow) }, openMopWithSearch(keycode) { - if(!this.transactions.length) { return } - this.$refs.dropdowns[this.state.selectedRow].openWithSearch() - } }, beforeMount() { - let amountInCheckRun = 0.0 - this.moment = moment; - this.format_currency = format_currency; - cur_frm.check_run_component = this; + this.moment = moment + this.format_currency = format_currency + cur_frm.check_run_component = this } } @@ -203,5 +193,4 @@ export default { .table tr.selectedRow { background-color: var(--yellow-highlight-color); } - diff --git a/check_run/public/js/check_run/check_run.js b/check_run/public/js/check_run/check_run.js index cae0ef3f..bc80912e 100644 --- a/check_run/public/js/check_run/check_run.js +++ b/check_run/public/js/check_run/check_run.js @@ -17,14 +17,14 @@ check_run.mount_table = frm => { show_party_filter: false, check_run_total: function() { return this.transactions.reduce((partialSum, t) => { - return t.pay ? partialSum + t.amount : partialSum; + return t.pay ? partialSum + t.amount : partialSum }, 0); }, selectedRow: 0, mopsOpen: 0 }) if (frm.$check_run instanceof Vue) { - frm.$check_run.$destroy(); + frm.$check_run.$destroy() } $('#check-run-vue').remove() $(frm.fields_dict['check_run_table'].wrapper).html($("
").get(0)); @@ -71,7 +71,7 @@ check_run.keyDownHandler = e => { if(e.keyCode == 32 && check_run.frm.check_run_state.selectedRow != null && check_run.frm.check_run_state.transactions.length){ e.preventDefault() if(check_run.frm.check_run_component) { - check_run.frm.check_run_component.checkPay(); + check_run.frm.check_run_component.checkPay() } } @@ -81,5 +81,5 @@ check_run.keyDownHandler = e => { } -window.removeEventListener('keydown', check_run.keyDownHandler); -window.addEventListener('keydown', check_run.keyDownHandler); +window.removeEventListener('keydown', check_run.keyDownHandler) +window.addEventListener('keydown', check_run.keyDownHandler) diff --git a/check_run/public/js/check_run/check_run_quick_entry.js b/check_run/public/js/check_run/check_run_quick_entry.js index b35fbed8..0201b7f4 100644 --- a/check_run/public/js/check_run/check_run_quick_entry.js +++ b/check_run/public/js/check_run/check_run_quick_entry.js @@ -58,7 +58,7 @@ frappe.ui.form.CheckRunQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ this.dialog.set_primary_action(__('Start Check Run'), () => { let values = me.dialog.get_values() frappe.xcall("check_run.check_run.doctype.check_run.check_run.check_for_draft_check_run", - { company: values.company, bank_account: values.bank_account } + { company: values.company, bank_account: values.bank_account, payable_account: values.pay_to_account } ).then(r => { frappe.set_route("Form", "Check Run", r) }) diff --git a/check_run/test_setup.py b/check_run/test_setup.py index 021ddca5..9989b4f9 100644 --- a/check_run/test_setup.py +++ b/check_run/test_setup.py @@ -44,25 +44,6 @@ def before_test(): ("Local Tax Authority", "Payroll Taxes", "Check", 0.00), ] -<<<<<<< Updated upstream:check_run/test_setup.py -settings = frappe._dict({}) - -def create_test_data(): - settings.day = datetime.date(int(frappe.defaults.get_defaults().get('fiscal_year')), 1 ,1) - settings.company = frappe.defaults.get_defaults().get('company') - company_account = frappe.get_value("Account", {"account_type": "Bank", "company": settings.company, "is_group": 0}) - settings.company_account = update_account_number(company_account, 'Primary Checking', account_number="1201", from_descendant=False) - payroll_account = frappe.get_value('Account', {'account_name': 'Payroll Payable'}) - frappe.db.set_value('Account', payroll_account, 'account_type', 'Payable') - create_bank_and_bank_account() - create_suppliers() - create_items() - create_invoices() - config_expense_claim() - create_employees() - create_expense_claim() - create_payroll_journal_entry() -======= def create_test_data(): settings = frappe._dict({ 'day': datetime.date(int(frappe.defaults.get_defaults().get('fiscal_year')), 1 ,1), @@ -78,7 +59,6 @@ def create_test_data(): create_employees(settings) create_expense_claim(settings) create_payroll_journal_entry(settings) ->>>>>>> Stashed changes:check_run/check_run/doctype/check_run/test_data.py def create_bank_and_bank_account(settings): @@ -112,11 +92,7 @@ def create_bank_and_bank_account(settings): doc.company = settings.company opening_balance = 10000.00 doc.append("accounts", {"account": settings.company_account, "debit_in_account_currency": opening_balance}) -<<<<<<< Updated upstream:check_run/test_setup.py - retained_earnings = frappe.get_value('Account', {'account_name': "Retained Earnings"}) -======= retained_earnings = frappe.get_value('Account', {'account_name': "Retained Earnings", 'company': settings.company}) ->>>>>>> Stashed changes:check_run/check_run/doctype/check_run/test_data.py doc.append("accounts", {"account": retained_earnings, "credit_in_account_currency": opening_balance}) doc.save() doc.submit() @@ -294,11 +270,7 @@ def create_expense_claim(settings): ec.submit() -<<<<<<< Updated upstream:check_run/test_setup.py -def create_payroll_journal_entry(): -======= def create_payroll_journal_entry(settings): ->>>>>>> Stashed changes:check_run/check_run/doctype/check_run/test_data.py emps = frappe.get_list('Employee', {'company': settings.company}) cost_center = frappe.get_value('Company', settings.company, 'cost_center') payroll_account = frappe.get_value('Account', {'company': settings.company, 'account_name': 'Payroll Payable', 'is_group': 0}) @@ -359,4 +331,5 @@ def create_payroll_journal_entry(settings): 'debit_in_account_currency': 0.0, }) je.save() - je.submit() \ No newline at end of file + je.submit() + \ No newline at end of file