-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: utility to repost accounting ledgers without cancellation (#36469)
* feat: introduce doctypes for repost * refactor: basic filters and validations * chore: basic validations * chore: added barebones function to generate ledger entries * chore: repost on submit * chore: repost in background * chore: include payment entry and journal entry * chore: ignore repost doc on cancel * chore: preview method * chore: rudimentary form of preview * refactor: preview template * refactor: basic background colors to differentiate old and new * chore: remove commented code * test: basic functionality * chore: fix conflict * chore: prevent repost on invoices with deferred accounting * refactor(test): rename and test basic validations and methods * refactor(test): test all validations * fix(test): use proper name account name * refactor(test): fix failing test case * refactor(test): clear old entries * refactor(test): simpler logic to clear old records * refactor(test): make use of deletion flag * refactor(test): split into multiple test cases (cherry picked from commit e64b004) # Conflicts: # erpnext/accounts/doctype/journal_entry/journal_entry.js
- Loading branch information
1 parent
67c8350
commit f8d6fe6
Showing
18 changed files
with
663 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
44 changes: 44 additions & 0 deletions
44
erpnext/accounts/doctype/repost_accounting_ledger/repost_accounting_ledger.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<style> | ||
.print-format { | ||
padding: 4mm; | ||
font-size: 8.0pt !important; | ||
} | ||
.print-format td { | ||
vertical-align:middle !important; | ||
} | ||
.old { | ||
background-color: #FFB3C0; | ||
} | ||
.new { | ||
background-color: #B3FFCC; | ||
} | ||
</style> | ||
|
||
|
||
<table class="table table-bordered table-condensed"> | ||
<colgroup> | ||
{% for col in gl_columns%} | ||
<col style="width: 18mm;"> | ||
{% endfor %} | ||
</colgroup> | ||
<thead> | ||
<tr> | ||
{% for col in gl_columns%} | ||
<td>{{ col.label }}</td> | ||
{% endfor %} | ||
</tr> | ||
</thead> | ||
{% for gl in gl_data%} | ||
{% if gl["old"]%} | ||
<tr class="old"> | ||
{% else %} | ||
<tr class="new"> | ||
{% endif %} | ||
{% for col in gl_columns %} | ||
<td class="text-right"> | ||
{{ gl[col.fieldname] }} | ||
</td> | ||
{% endfor %} | ||
</tr> | ||
{% endfor %} | ||
</table> |
50 changes: 50 additions & 0 deletions
50
erpnext/accounts/doctype/repost_accounting_ledger/repost_accounting_ledger.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors | ||
// For license information, please see license.txt | ||
|
||
frappe.ui.form.on("Repost Accounting Ledger", { | ||
setup: function(frm) { | ||
frm.fields_dict['vouchers'].grid.get_field('voucher_type').get_query = function(doc) { | ||
return { | ||
filters: { | ||
name: ['in', ['Purchase Invoice', 'Sales Invoice', 'Payment Entry', 'Journal Entry']], | ||
} | ||
} | ||
} | ||
|
||
frm.fields_dict['vouchers'].grid.get_field('voucher_no').get_query = function(doc) { | ||
if (doc.company) { | ||
return { | ||
filters: { | ||
company: doc.company, | ||
docstatus: 1 | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
refresh: function(frm) { | ||
frm.add_custom_button(__('Show Preview'), () => { | ||
frm.call({ | ||
method: 'generate_preview', | ||
doc: frm.doc, | ||
freeze: true, | ||
freeze_message: __('Generating Preview'), | ||
callback: function(r) { | ||
if (r && r.message) { | ||
let content = r.message; | ||
let opts = { | ||
title: "Preview", | ||
subtitle: "preview", | ||
content: content, | ||
print_settings: {orientation: "landscape"}, | ||
columns: [], | ||
data: [], | ||
} | ||
frappe.render_grid(opts); | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
}); |
81 changes: 81 additions & 0 deletions
81
erpnext/accounts/doctype/repost_accounting_ledger/repost_accounting_ledger.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"actions": [], | ||
"allow_rename": 1, | ||
"autoname": "format:ACC-REPOST-{#####}", | ||
"creation": "2023-07-04 13:07:32.923675", | ||
"default_view": "List", | ||
"doctype": "DocType", | ||
"editable_grid": 1, | ||
"engine": "InnoDB", | ||
"field_order": [ | ||
"company", | ||
"column_break_vpup", | ||
"delete_cancelled_entries", | ||
"section_break_metl", | ||
"vouchers", | ||
"amended_from" | ||
], | ||
"fields": [ | ||
{ | ||
"fieldname": "company", | ||
"fieldtype": "Link", | ||
"label": "Company", | ||
"options": "Company" | ||
}, | ||
{ | ||
"fieldname": "amended_from", | ||
"fieldtype": "Link", | ||
"label": "Amended From", | ||
"no_copy": 1, | ||
"options": "Repost Accounting Ledger", | ||
"print_hide": 1, | ||
"read_only": 1 | ||
}, | ||
{ | ||
"fieldname": "vouchers", | ||
"fieldtype": "Table", | ||
"label": "Vouchers", | ||
"options": "Repost Accounting Ledger Items" | ||
}, | ||
{ | ||
"fieldname": "column_break_vpup", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fieldname": "section_break_metl", | ||
"fieldtype": "Section Break" | ||
}, | ||
{ | ||
"default": "0", | ||
"fieldname": "delete_cancelled_entries", | ||
"fieldtype": "Check", | ||
"label": "Delete Cancelled Ledger Entries" | ||
} | ||
], | ||
"index_web_pages_for_search": 1, | ||
"is_submittable": 1, | ||
"links": [], | ||
"modified": "2023-07-27 15:47:58.975034", | ||
"modified_by": "Administrator", | ||
"module": "Accounts", | ||
"name": "Repost Accounting Ledger", | ||
"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 | ||
} | ||
], | ||
"sort_field": "modified", | ||
"sort_order": "DESC", | ||
"states": [] | ||
} |
Oops, something went wrong.