Skip to content

Commit

Permalink
Per supplier invoices per voucher (#165)
Browse files Browse the repository at this point in the history
* feat: allow per-supplier override for number of invoices per voucher

* docs: add docs for per supplier invoices per voucher
  • Loading branch information
agritheory authored Oct 4, 2023
1 parent 371a693 commit 567762c
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 155 deletions.
339 changes: 212 additions & 127 deletions check_run/check_run/custom/supplier.json
Original file line number Diff line number Diff line change
@@ -1,128 +1,213 @@
{
"custom_fields": [
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"creation": "2022-06-30 11:20:02.666689",
"default": null,
"depends_on": "",
"description": "<a id=\"bank-account\">Show Bank Account Number</a>",
"docstatus": 0,
"dt": "Supplier",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "bank_account",
"fieldtype": "Password",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 36,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "bank",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Bank Account",
"length": 0,
"mandatory_depends_on": null,
"modified": "2022-06-30 11:20:02.666689",
"modified_by": "Administrator",
"module": "Check Run",
"name": "Supplier-bank_account",
"no_copy": 0,
"non_negative": 0,
"options": null,
"owner": "Administrator",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"translatable": 0,
"unique": 0,
"width": null
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"creation": "2022-06-30 11:20:02.666689",
"default": null,
"depends_on": null,
"description": null,
"docstatus": 0,
"dt": "Supplier",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "supplier_default_mode_of_payment",
"fieldtype": "Link",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 32,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "payment_terms",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Supplier Default Mode of Payment",
"length": 0,
"mandatory_depends_on": null,
"modified": "2022-06-30 11:20:02.666689",
"modified_by": "Administrator",
"module": "Check Run",
"name": "Supplier-supplier_default_mode_of_payment",
"no_copy": 0,
"non_negative": 0,
"options": "Mode of Payment",
"owner": "Administrator",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"translatable": 0,
"unique": 0,
"width": null
}
],
"custom_perms": [],
"doctype": "Supplier",
"property_setters": [],
"sync_on_migrate": 1
}
"custom_fields": [
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"creation": "2022-06-30 11:20:02.666689",
"default": null,
"depends_on": "",
"description": "<a id=\"bank-account\">Show Bank Account Number</a>",
"docstatus": 0,
"dt": "Supplier",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "bank_account",
"fieldtype": "Password",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 62,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "release_date",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Bank Account",
"length": 0,
"mandatory_depends_on": null,
"modified": "2022-06-30 11:20:02.666689",
"modified_by": "Administrator",
"module": "Check Run",
"name": "Supplier-bank_account",
"no_copy": 0,
"non_negative": 0,
"options": null,
"owner": "Administrator",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"sort_options": 0,
"translatable": 0,
"unique": 0,
"width": null
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"creation": "2022-06-30 11:20:02.666689",
"default": null,
"depends_on": null,
"description": null,
"docstatus": 0,
"dt": "Supplier",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "supplier_default_mode_of_payment",
"fieldtype": "Link",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 15,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "payment_terms",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Supplier Default Mode of Payment",
"length": 0,
"mandatory_depends_on": null,
"modified": "2022-06-30 11:20:02.666689",
"modified_by": "Administrator",
"module": "Check Run",
"name": "Supplier-supplier_default_mode_of_payment",
"no_copy": 0,
"non_negative": 0,
"options": "Mode of Payment",
"owner": "Administrator",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"sort_options": 0,
"translatable": 0,
"unique": 0,
"width": null
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"creation": "2023-09-27 14:04:57.166489",
"default": null,
"depends_on": null,
"description": null,
"docstatus": 0,
"dt": "Supplier",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "number_of_invoices_per_check_voucher",
"fieldtype": "Int",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 15,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "supplier_default_mode_of_payment",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Number of Invoices Per Check Voucher",
"length": 0,
"mandatory_depends_on": null,
"modified": "2023-09-27 14:05:17.695804",
"modified_by": "Administrator",
"module": "Check Run",
"name": "Supplier-number_of_invoices_per_check_voucher",
"no_copy": 0,
"non_negative": 0,
"options": null,
"owner": "Administrator",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"sort_options": 0,
"translatable": 0,
"unique": 0,
"width": null
}
],
"custom_perms": [],
"doctype": "Supplier",
"links": [
{
"creation": "2013-01-10 16:34:11",
"custom": 0,
"docstatus": 0,
"group": "Allowed Items",
"hidden": 0,
"idx": 1,
"is_child_table": 0,
"link_doctype": "Party Specific Item",
"link_fieldname": "party",
"modified": "2023-09-14 19:51:06.084944",
"modified_by": "Administrator",
"name": "22db288d07",
"owner": "Administrator",
"parent": "Supplier",
"parent_doctype": null,
"parentfield": "links",
"parenttype": "DocType",
"table_fieldname": null
}
],
"property_setters": [],
"sync_on_migrate": 1
}
10 changes: 7 additions & 3 deletions check_run/check_run/doctype/check_run/check_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ def create_payment_entries(self: Self, transactions: list[frappe._dict]) -> list
)
for party, __group in groupby(transactions, key=key_lookup):
_group = list(__group)
if _group[0].party_type == "Supplier":
supplier_split = frappe.db.get_value("Supplier", party, "number_of_invoices_per_check_voucher")
split = supplier_split if supplier_split else split
if frappe.db.get_value("Mode of Payment", _group[0].mode_of_payment, "type") == "Bank":
groups = list(zip_longest(*[iter(_group)] * split))
else:
Expand Down Expand Up @@ -610,9 +613,10 @@ def get_entries(doc: CheckRun | str) -> dict:
for transaction in transactions:
doc_name = transaction.ref_number if transaction.ref_number else transaction.name
transaction.attachments = [
attachment for attachment in get_attachments(transaction.doctype, doc_name)
if attachment.file_url.endswith('.pdf')
] or [{'file_name': doc_name, 'file_url': f'/app/Form/{transaction.doctype}/{doc_name}'}]
attachment
for attachment in get_attachments(transaction.doctype, doc_name)
if attachment.file_url.endswith(".pdf")
] or [{"file_name": doc_name, "file_url": f"/app/Form/{transaction.doctype}/{doc_name}"}]

if settings and settings.pre_check_overdue_items:
if transaction.due_date < doc.posting_date:
Expand Down
Loading

0 comments on commit 567762c

Please sign in to comment.