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 6fc5d948..7cc47e1b 100644 --- a/check_run/check_run/doctype/check_run/check_run.py +++ b/check_run/check_run/doctype/check_run/check_run.py @@ -19,7 +19,7 @@ from frappe.utils.password import get_decrypted_password from frappe.contacts.doctype.address.address import get_default_address from frappe.query_builder.custom import ConstantColumn -from frappe.query_builder.functions import Coalesce, Sum +from frappe.query_builder.functions import Coalesce, Sum, NullIf from frappe.desk.form.load import get_attachments from erpnext.accounts.utils import get_balance_on @@ -523,8 +523,8 @@ def get_entries(doc: CheckRun | str) -> dict: purchase_invoices.posting_date, Coalesce( purchase_invoices.supplier_default_mode_of_payment, - supplier_mop_sub_query, # suppliers.supplier_default_mode_of_payment, - "\n", + NullIf(supplier_mop_sub_query, ""), # suppliers.supplier_default_mode_of_payment, + f"{settings.purchase_invoice}" or "\n", ).as_("mode_of_payment"), (payment_schedule.payment_term).as_("payment_term"), ) @@ -553,7 +553,11 @@ def get_entries(doc: CheckRun | str) -> dict: (exp_claims.grand_total).as_("amount"), (exp_claims.posting_date).as_("due_date"), exp_claims.posting_date, - Coalesce(exp_claims.mode_of_payment, employees.mode_of_payment, "\n").as_("mode_of_payment"), + Coalesce( + exp_claims.mode_of_payment, + NullIf(employees.mode_of_payment, ""), + f"{settings.expense_claim}" or "\n", + ).as_("mode_of_payment"), ConstantColumn("").as_("payment_term"), ) .where(exp_claims.grand_total > exp_claims.total_amount_reimbursed) @@ -593,7 +597,9 @@ def get_entries(doc: CheckRun | str) -> dict: (je_accounts.credit_in_account_currency).as_("amount"), journal_entries.due_date, journal_entries.posting_date, - Coalesce(journal_entries.mode_of_payment, "\n").as_("mode_of_payment"), + Coalesce(journal_entries.mode_of_payment, f"{settings.journal_entry}" or "\n").as_( + "mode_of_payment" + ), ConstantColumn("").as_("payment_term"), ) .where(journal_entries.company == company) @@ -623,7 +629,9 @@ def get_entries(doc: CheckRun | str) -> dict: query = query.orderby("due_date", "name").get_sql() transactions = frappe.db.sql( - query, {"company": company, "pay_to_account": pay_to_account, "end_date": end_date}, as_dict=True + query, + {"company": company, "pay_to_account": pay_to_account, "end_date": end_date}, + as_dict=True, ) for transaction in transactions: doc_name = transaction.ref_number if transaction.ref_number else transaction.name @@ -639,13 +647,14 @@ def get_entries(doc: CheckRun | str) -> dict: if transaction.doctype == "Journal Entry": if transaction.party_type == "Supplier": transaction.party_name = frappe.get_value("Supplier", transaction.party, "supplier_name") - transaction.mode_of_payment = frappe.get_value( - "Supplier", transaction.party, "supplier_default_mode_of_payment" + transaction.mode_of_payment = ( + frappe.get_value("Supplier", transaction.party, "supplier_default_mode_of_payment") + or settings.journal_entry ) if transaction.party_type == "Employee": transaction.party_name = frappe.get_value("Employee", transaction.party, "employee_name") - transaction.mode_of_payment = frappe.get_value( - "Employee", transaction.party, "mode_of_payment" + transaction.mode_of_payment = ( + frappe.get_value("Employee", transaction.party, "mode_of_payment") or settings.journal_entry ) return {"transactions": transactions, "modes_of_payment": modes_of_payment} diff --git a/check_run/check_run/doctype/check_run_settings/check_run_settings.json b/check_run/check_run/doctype/check_run_settings/check_run_settings.json index e81eda77..c685fd67 100644 --- a/check_run/check_run/doctype/check_run_settings/check_run_settings.json +++ b/check_run/check_run/doctype/check_run_settings/check_run_settings.json @@ -1,219 +1,253 @@ { - "actions": [], - "autoname": "format:ACC-CRS-{bank_account}-{pay_to_account}", - "creation": "2022-08-22 14:43:43.533105", - "doctype": "DocType", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "company", - "bank_account", - "column_break_3", - "pay_to_account", - "print_format", - "section_break_4", - "include_purchase_invoices", - "include_journal_entries", - "include_expense_claims", - "pre_check_overdue_items", - "allow_cancellation", - "cascade_cancellation", - "column_break_9", - "number_of_invoices_per_voucher", - "split_by_address", - "automatically_release_on_hold_invoices", - "ach_settings_section", - "ach_file_extension", - "ach_service_class_code", - "ach_standard_class_code", - "ach_description", - "column_break_21", - "immediate_origin", - "company_discretionary_data", - "custom_post_processing_hook" - ], - "fields": [ - { - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company" - }, - { - "fieldname": "bank_account", - "fieldtype": "Link", - "label": "Bank Account", - "options": "Bank Account" - }, - { - "fieldname": "section_break_4", - "fieldtype": "Section Break" - }, - { - "default": "1", - "fieldname": "include_purchase_invoices", - "fieldtype": "Check", - "label": "Include Purchase Invoices" - }, - { - "default": "1", - "fieldname": "include_journal_entries", - "fieldtype": "Check", - "label": "Include Journal Entries " - }, - { - "default": "1", - "fieldname": "include_expense_claims", - "fieldtype": "Check", - "label": "Include Expense Claims" - }, - { - "default": "0", - "description": "Payment Entries will be unlinked when Check Run is cancelled", - "fieldname": "allow_cancellation", - "fieldtype": "Check", - "label": "Allow Cancellation" - }, - { - "fieldname": "column_break_9", - "fieldtype": "Column Break" - }, - { - "default": "ach", - "description": "Common file extensions are 'ach', 'txt' and 'dat'. Your bank may require one of these.", - "fieldname": "ach_file_extension", - "fieldtype": "Data", - "label": "ACH File Extension" - }, - { - "default": "0", - "description": "Pre-Check all payables that have a due date greater than the Check Run's posting date", - "fieldname": "pre_check_overdue_items", - "fieldtype": "Check", - "label": "Pre-Check Overdue Items" - }, - { - "default": "0", - "description": "When a Check Run is cancelled, all Payment Entries linked to it will also be cancelled. This is not recommended.", - "fieldname": "cascade_cancellation", - "fieldtype": "Check", - "label": "Cascade Cancellation" - }, - { - "description": "Defaults to 5 if no value is provided", - "fieldname": "number_of_invoices_per_voucher", - "fieldtype": "Int", - "label": "Number of Invoices per Voucher", - "non_negative": 1 - }, - { - "fieldname": "column_break_3", - "fieldtype": "Column Break" - }, - { - "fieldname": "pay_to_account", - "fieldtype": "Link", - "label": "Payable Account", - "options": "Account" - }, - { - "fieldname": "ach_service_class_code", - "fieldtype": "Select", - "label": "ACH Service Class Code", - "options": "200\n220\n225" - }, - { - "description": "PPD is only supported Entry format at this time", - "fieldname": "ach_standard_class_code", - "fieldtype": "Select", - "label": "ACH Standard Class Code", - "options": "PPD" - }, - { - "fieldname": "ach_description", - "fieldtype": "Data", - "label": "ACH Description", - "length": 10 - }, - { - "fieldname": "print_format", - "fieldtype": "Link", - "label": "Print Format", - "options": "Print Format" - }, - { - "default": "0", - "fieldname": "split_by_address", - "fieldtype": "Check", - "label": "Split Invoices by Address" - }, - { - "fieldname": "ach_settings_section", - "fieldtype": "Section Break", - "label": "ACH Settings" - }, - { - "fieldname": "column_break_21", - "fieldtype": "Column Break" - }, - { - "default": "0", - "fieldname": "automatically_release_on_hold_invoices", - "fieldtype": "Check", - "label": "Automatically Release On Hold Invoices" - }, - { - "fieldname": "immediate_origin", - "fieldtype": "Data", - "label": "Immediate Origin" - }, - { - "fieldname": "company_discretionary_data", - "fieldtype": "Data", - "label": "Company Discretionary Data", - "length": 20 - }, - { - "fieldname": "custom_post_processing_hook", - "fieldtype": "Data", - "label": "Custom Post Processing Hook", - "read_only": 1 - } - ], - "links": [], - "modified": "2023-03-17 13:43:25.837467", - "modified_by": "Administrator", - "module": "Check Run", - "name": "Check Run Settings", - "owner": "Administrator", - "permissions": [ - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "share": 1, - "write": 1 - }, - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "Accounts Manager", - "share": 1, - "write": 1 - } - ], - "quick_entry": 1, - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 1 -} + "actions": [], + "autoname": "format:ACC-CRS-{bank_account}-{pay_to_account}", + "creation": "2022-08-22 14:43:43.533105", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "company", + "bank_account", + "column_break_3", + "pay_to_account", + "print_format", + "section_break_4", + "include_purchase_invoices", + "include_journal_entries", + "include_expense_claims", + "pre_check_overdue_items", + "allow_cancellation", + "cascade_cancellation", + "column_break_9", + "number_of_invoices_per_voucher", + "split_by_address", + "automatically_release_on_hold_invoices", + "default_modes_of_payment_section_section", + "purchase_invoice", + "journal_entry", + "column_break_21", + "expense_claim", + "ach_settings_section", + "ach_file_extension", + "ach_service_class_code", + "ach_standard_class_code", + "ach_description", + "column_break_27", + "immediate_origin", + "company_discretionary_data", + "custom_post_processing_hook" + ], + "fields": [ + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company" + }, + { + "fieldname": "bank_account", + "fieldtype": "Link", + "label": "Bank Account", + "options": "Bank Account" + }, + { + "fieldname": "section_break_4", + "fieldtype": "Section Break" + }, + { + "default": "1", + "fieldname": "include_purchase_invoices", + "fieldtype": "Check", + "label": "Include Purchase Invoices" + }, + { + "default": "1", + "fieldname": "include_journal_entries", + "fieldtype": "Check", + "label": "Include Journal Entries " + }, + { + "default": "1", + "fieldname": "include_expense_claims", + "fieldtype": "Check", + "label": "Include Expense Claims" + }, + { + "default": "0", + "description": "Payment Entries will be unlinked when Check Run is cancelled", + "fieldname": "allow_cancellation", + "fieldtype": "Check", + "label": "Allow Cancellation" + }, + { + "fieldname": "column_break_9", + "fieldtype": "Column Break" + }, + { + "default": "ach", + "description": "Common file extensions are 'ach', 'txt' and 'dat'. Your bank may require one of these.", + "fieldname": "ach_file_extension", + "fieldtype": "Data", + "label": "ACH File Extension" + }, + { + "default": "0", + "description": "Pre-Check all payables that have a due date greater than the Check Run's posting date", + "fieldname": "pre_check_overdue_items", + "fieldtype": "Check", + "label": "Pre-Check Overdue Items" + }, + { + "default": "0", + "description": "When a Check Run is cancelled, all Payment Entries linked to it will also be cancelled. This is not recommended.", + "fieldname": "cascade_cancellation", + "fieldtype": "Check", + "label": "Cascade Cancellation" + }, + { + "description": "Defaults to 5 if no value is provided", + "fieldname": "number_of_invoices_per_voucher", + "fieldtype": "Int", + "label": "Number of Invoices per Voucher", + "non_negative": 1 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break" + }, + { + "fieldname": "pay_to_account", + "fieldtype": "Link", + "label": "Payable Account", + "options": "Account" + }, + { + "fieldname": "ach_service_class_code", + "fieldtype": "Select", + "label": "ACH Service Class Code", + "options": "200\n220\n225" + }, + { + "description": "PPD is only supported Entry format at this time", + "fieldname": "ach_standard_class_code", + "fieldtype": "Select", + "label": "ACH Standard Class Code", + "options": "PPD" + }, + { + "fieldname": "ach_description", + "fieldtype": "Data", + "label": "ACH Description", + "length": 10 + }, + { + "fieldname": "print_format", + "fieldtype": "Link", + "label": "Print Format", + "options": "Print Format" + }, + { + "default": "0", + "fieldname": "split_by_address", + "fieldtype": "Check", + "label": "Split Invoices by Address" + }, + { + "fieldname": "ach_settings_section", + "fieldtype": "Section Break", + "label": "ACH Settings" + }, + { + "fieldname": "column_break_21", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "automatically_release_on_hold_invoices", + "fieldtype": "Check", + "label": "Automatically Release On Hold Invoices" + }, + { + "fieldname": "immediate_origin", + "fieldtype": "Data", + "label": "Immediate Origin" + }, + { + "fieldname": "company_discretionary_data", + "fieldtype": "Data", + "label": "Company Discretionary Data", + "length": 20 + }, + { + "fieldname": "custom_post_processing_hook", + "fieldtype": "Data", + "label": "Custom Post Processing Hook", + "read_only": 1 + }, + { + "fieldname": "default_modes_of_payment_section_section", + "fieldtype": "Section Break", + "label": "Default Modes of Payment Section" + }, + { + "fieldname": "purchase_invoice", + "fieldtype": "Link", + "label": "Purchase Invoice", + "options": "Mode of Payment" + }, + { + "fieldname": "journal_entry", + "fieldtype": "Link", + "label": "Journal Entry", + "options": "Mode of Payment" + }, + { + "fieldname": "expense_claim", + "fieldtype": "Link", + "label": "Expense Claim", + "options": "Mode of Payment" + }, + { + "fieldname": "column_break_27", + "fieldtype": "Column Break" + } + ], + "links": [], + "modified": "2023-12-11 16:08:19.536271", + "modified_by": "Administrator", + "module": "Check Run", + "name": "Check Run Settings", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "track_changes": 1 +} \ No newline at end of file diff --git a/check_run/tests/fixtures.py b/check_run/tests/fixtures.py index f4673b39..2129869c 100644 --- a/check_run/tests/fixtures.py +++ b/check_run/tests/fixtures.py @@ -16,7 +16,7 @@ ( "Liu & Loewen Accountants LLP", "Accounting Services", - "ACH/EFT", + None, 500.00, "Net 30", { @@ -117,7 +117,7 @@ ( "Local Tax Authority", "Payroll Taxes", - "Check", + None, 0.00, "Due on Receipt", { diff --git a/check_run/tests/setup.py b/check_run/tests/setup.py index 6945196f..39363c7d 100644 --- a/check_run/tests/setup.py +++ b/check_run/tests/setup.py @@ -527,6 +527,7 @@ def create_employees(settings): emp.date_of_joining = employee[3] emp.mode_of_payment = "Check" if employee_number % 3 == 0 else "ACH/EFT" emp.mode_of_payment = "Cash" if employee_number == 10 else emp.mode_of_payment + emp.mode_of_payment = None if employee_number % 4 == 0 else emp.mode_of_payment emp.expense_approver = "Administrator" if emp.mode_of_payment == "ACH/EFT": emp.bank = "Local Bank" diff --git a/docs/assets/SettingsDefaultScreen.png b/docs/assets/SettingsDefaultScreen.png deleted file mode 100644 index ab9356a2..00000000 Binary files a/docs/assets/SettingsDefaultScreen.png and /dev/null differ diff --git a/docs/assets/Settings_ACH.png b/docs/assets/Settings_ACH.png new file mode 100644 index 00000000..cd41e3a5 Binary files /dev/null and b/docs/assets/Settings_ACH.png differ diff --git a/docs/assets/Settings_MOP.png b/docs/assets/Settings_MOP.png new file mode 100644 index 00000000..ba2b03c4 Binary files /dev/null and b/docs/assets/Settings_MOP.png differ diff --git a/docs/assets/Settings_Main.png b/docs/assets/Settings_Main.png new file mode 100644 index 00000000..86dfe3b4 Binary files /dev/null and b/docs/assets/Settings_Main.png differ diff --git a/docs/settings.md b/docs/settings.md index 0ac7ed83..96fdf472 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -6,7 +6,7 @@ A `Check Run Setting` entry determines the behavior in a Check Run for a specifi If the system doesn't find settings for the account combination you're using in an initiated Check Run, it will automatically take you to the settings page to confirm the options. Alternatively, you can access the setting list directly by searching for "Check Run Settings List" in the AwesomeBar and clicking the `Add Check Run Settings` button. -![Screen shot showing the default settings for one Bank Account and Payable Account combination. A description of each setting and its default value is listed below.](./assets/SettingsDefaultScreen.png) +![Screen shot showing the top portion of default settings for one Bank Account and Payable Account combination. A description of each setting and its default value is listed below.](./assets/Settings_Main.png) - **Include Purchase Invoices:** - Selected by default @@ -37,9 +37,16 @@ If the system doesn't find settings for the account combination you're using in - **Automatically Release On Hold Invoices:** - By default, on hold invoices will not show if their 'release date' is not within the Check Run period. The checkbox allows invoices that _are_ on hold to be automatically released and paid in the Check Run. - ![Check Run output table showing a row for eight invoices paid (two for AgriTheory, two for Cooperative Ag Finance, and four for Exceptional Grid). The first two Exceptional Grid invoices have Check Reference Number ACC-PAY-2022-00003 and the next set of two invoices have Check Reference Number ACC-PAY-2022-00004. They were split into different vouchers because the setting limited two invoices per voucher.](./assets/VoucherGroup.png) +The next section of settings allow for an optional default Mode of Payment for Purchase Invoices, Expense Claims, and Journal Entries. If there isn't a Mode of Payment specified in the Purchase Invoice, Expense Claim, or Journal Entry itself, and there isn't a default set for the party (see the [Configuration page](./configuration.md) for more details), then this field is used to populate the Mode of Payment column in the Check Run. + +![Screen shot showing the Default Mode of Payment section in settings.](./assets/Settings_MOP.png) + +There is also a section for all settings related to ACH payments. + +![Screen shot showing the ACH Settings section. A description of each setting and its default value is listed below.](./assets/Settings_ACH.png) + - **ACH File Extension:** - Default value is "ach" - A Check Run automatically generates an ACH file if any Mode of Payment options used had a type of "Electronic". This setting is a text field to indicate the file extension the system will use when it creates these files. Your banking institution may require a certain extension