feat: Accounting Ledger Preview

This commit is contained in:
Deepesh Garg 2023-06-04 19:20:28 +05:30
parent 781c93c0e6
commit 2e52a63b0d
3 changed files with 49 additions and 1 deletions

View File

@ -88,6 +88,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
}
this.show_general_ledger();
this.show_ledger_preview();
if(doc.update_stock) this.show_stock_ledger();

View File

@ -15,6 +15,7 @@ from erpnext.accounts.general_ledger import (
make_reverse_gl_entries,
process_gl_map,
)
from erpnext.accounts.report.general_ledger.general_ledger import get_columns
from erpnext.accounts.utils import get_fiscal_year
from erpnext.controllers.accounts_controller import AccountsController
from erpnext.stock import get_warehouse_account_map
@ -824,6 +825,18 @@ class StockController(AccountsController):
gl_entries.append(self.get_gl_dict(gl_entry, item=item))
@frappe.whitelist()
def show_ledger_preview(company, doctype, docname):
filters = {"company": company}
doc = frappe.get_doc(doctype, docname)
columns = get_columns(filters)
data = doc.get_gl_entries()
return {
"columns": columns,
"data": data,
}
def repost_required_for_queue(doc: StockController) -> bool:
"""check if stock document contains repeated item-warehouse with queue based valuation.

View File

@ -66,7 +66,7 @@ erpnext.stock.StockController = class StockController extends frappe.ui.form.Con
}
show_general_ledger() {
var me = this;
let me = this;
if(this.frm.doc.docstatus > 0) {
cur_frm.add_custom_button(__('Accounting Ledger'), function() {
frappe.route_options = {
@ -81,4 +81,38 @@ erpnext.stock.StockController = class StockController extends frappe.ui.form.Con
}, __("View"));
}
}
show_ledger_preview() {
let me = this
if(this.frm.doc.docstatus == 0) {
cur_frm.add_custom_button(__('Accounting Ledger Preview'), function() {
frappe.call({
"method": "erpnext.controllers.stock_controller.show_ledger_preview",
"args": {
"company": me.frm.doc.company,
"doctype": me.frm.doc.doctype,
"docname": me.frm.doc.name
},
"callback": function(response) {
me.get_datatable(response);
}
})
}, __("View"));
}
}
get_datatable(response) {
const datatable_options = {
columns: response.columns,
data: response.data,
dynamicRowHeight: true,
checkboxColumn: false,
inlineFilters: true,
};
this.datatable = new frappe.DataTable(
this.frm.page.main.parent,
datatable_options
);
}
};