Skip to content

Commit

Permalink
fix: rename report to ICUtility
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Aug 10, 2024
1 parent fb9bae3 commit 5070a9c
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,27 @@ frappe.ui.form.on("Purchase Reconciliation Tool", {
await frappe.require("purchase_reconciliation_tool.bundle.js");
frm.trigger("company");
frm.doc.__reconciliation_data = null;
set_date_range_description(frm);
add_gstr2b_alert(frm);
set_date_range_description(frm);
setup_filter_onchange_events(frm);
frm.purchase_reconciliation_tool = new PurchaseReconciliationTool(frm);

frappe.realtime.on("report_generated", message => {
frm.call("attachment_data", {
frm.call("publish_reconciliation_data", {
name: message.name,
});
});

frappe.realtime.on("data_reconciliation", message => {
const { data, filters, creation, report_name} = message;
const { data, filters, creation, report_name } = message;

frm.report_name = report_name
frm.is_latest_data = true
frm.report_name = report_name;
frm.is_latest_data = true;

const same_filter = filter_fields.every(
const is_filter_same = filter_fields.every(
field => frm.doc[field] === filters[field]
);
if (!same_filter) return;
if (!is_filter_same) return;

frappe.after_ajax(() => {
frm.doc.__reconciliation_data = JSON.stringify(
Expand Down Expand Up @@ -166,14 +166,14 @@ frappe.ui.form.on("Purchase Reconciliation Tool", {
method: "frappe.core.doctype.prepared_report.prepared_report.get_reports_in_queued_state",
args: {
filters: filetrs_to_pass,
report_name: "Purchase Reconciliation Tool",
report_name: "ICUtility",
},
});
if (message.length) {
frappe.msgprint("A report is alerady in queued");
frappe.msgprint(__("A report is alerady in queued"));
return;
}
frm.call("generate_reconciliation_data", {
frm.call("get_reconciliation_data", {
force_update: force_update,
});
});
Expand Down Expand Up @@ -220,10 +220,6 @@ frappe.ui.form.on("Purchase Reconciliation Tool", {
}
},

before_save(frm) {
frm.doc.__unsaved = true;
},

async purchase_period(frm) {
await fetch_date_range(frm, "purchase");
set_date_range_description(frm, "purchase");
Expand Down Expand Up @@ -298,7 +294,9 @@ frappe.ui.form.on("Purchase Reconciliation Tool", {
setTimeout(() => {
frm.dashboard.clear_headline();
}, 2000);
frm.save();
frm.call("get_reconciliation_data", {
force_update: true,
});
}, 1000);
}
});
Expand Down Expand Up @@ -335,7 +333,6 @@ class PurchaseReconciliationTool {
this.tabs[`${tab}_tab`].refresh(this[`get_${tab}_data`]());
});

this.rendered_data = this.filtered_data;
this.setup_footer(data_reconciled_on);
}

Expand Down Expand Up @@ -1127,13 +1124,22 @@ class DetailViewDialog {
}
}

update_report_status(){
if(this.frm.is_latest_data == false) return;
frappe.call({
method: "india_compliance.gst_india.doctype.purchase_reconciliation_tool.purchase_reconciliation_tool.update_report_filters",
args : { report_name : this.frm.report_name },
})
this.frm.is_latest_data = false
async update_report_status() {
if (this.frm.is_latest_data == false) return;

const filters = {};
filter_fields.forEach(field => {
filters[field] = this.frm.doc[field];
});
filters["is_latest_data"] = 1;

await frappe.db.set_value(
"Prepared Report",
this.frm.report_name,
"filters",
JSON.stringify(filters)
);
this.frm.is_latest_data = false;
}

_get_button_css(action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"not_reconciled",
"no_reconciliation_data",
"is_modified",
"section_break_cmfa"
"section_break_cmfa",
"__reconciliation_data"
],
"fields": [
{
Expand Down Expand Up @@ -126,6 +127,10 @@
"fieldtype": "Section Break",
"hidden": 1
},
{
"fieldname": "__reconciliation_data",
"fieldtype": "JSON"
},
{
"default": "0",
"fieldname": "is_modified",
Expand All @@ -138,17 +143,13 @@
"fieldname": "include_ignored",
"fieldtype": "Check",
"label": "Include Ignored"
},
{
"fieldname": "__reconciliation_data",
"fieldtype": "JSON"
}
],
"hide_toolbar": 1,
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2024-06-20 13:19:57.316043",
"modified": "2024-08-10 16:20:48.790753",
"modified_by": "Administrator",
"module": "GST India",
"name": "Purchase Reconciliation Tool",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) 2022, Resilient Tech and contributors
# For license information, please see license.txt
import gzip
import json
import re
from collections import defaultdict
from typing import List
Expand Down Expand Up @@ -66,23 +65,20 @@ def get_reco_doc(self):
return {field: self.get(field) for field in fields}

@frappe.whitelist()
def generate_reconciliation_data(self, force_update=False):
# reconcile purchases and inward supplies
def get_reconciliation_data(self, force_update=False):
if frappe.flags.in_install or frappe.flags.in_migrate:
return
frappe.enqueue(self.reconcile, queue="short", force_update=force_update)

def reconcile(self, force_update=False):
doc_name = get_completed_prepared_report(
self.get_reco_doc(), frappe.session.user, "Purchase Reconciliation Tool"
self.get_reco_doc(), frappe.session.user, "ICUtility"
)
if doc_name and not force_update:
self.attachment_data(doc_name)
self.publish_reconciliation_data(doc_name)
else:
make_prepared_report("Purchase Reconciliation Tool", self.get_reco_doc())
frappe.enqueue(make_prepared_report("ICUtility", self.get_reco_doc()))

@frappe.whitelist()
def attachment_data(self, name):
def publish_reconciliation_data(self, name):
attachments = frappe.get_all(
"File",
fields=["name", "file_name", "file_url", "is_private", "creation"],
Expand All @@ -91,14 +87,16 @@ def attachment_data(self, name):
"attached_to_doctype": "Prepared Report",
},
)

self.reconciliation_data = None
self.file_name = None

if attachments:
attached_file = frappe.get_doc("File", attachments[0].name)
self.reconciliation_data = frappe.parse_json(
frappe.safe_decode(gzip.decompress(attached_file.get_content()))
)
self.file_name = attachments[0].name
else:
self.reconciliation_data = None

frappe.publish_realtime(
"data_reconciliation",
Expand Down Expand Up @@ -455,14 +453,6 @@ def _get_link_options(self, data):
return data


@frappe.whitelist()
def update_report_filters(report_name):
filters = frappe.db.get_value("Prepared Report", report_name, "filters")
filters = json.loads(filters)
filters["is_latest_data"] = 1
frappe.db.set_value("Prepared Report", report_name, "filters", json.dumps(filters))


def download_gstr(
company_gstins,
date_range,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2024, Resilient Tech and contributors
// For license information, please see license.txt

frappe.query_reports["Purchase Reconciliation Tool"] = {
frappe.query_reports["ICUtility"] = {
"filters": [

]
Expand Down
33 changes: 33 additions & 0 deletions india_compliance/gst_india/report/icutility/icutility.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"add_total_row": 0,
"columns": [],
"creation": "2024-08-07 15:29:53.228497",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"filters": [],
"idx": 0,
"is_standard": "Yes",
"letter_head": "",
"letterhead": null,
"modified": "2024-08-07 15:31:18.427400",
"modified_by": "Administrator",
"module": "GST India",
"name": "ICUtility",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "Purchase Reconciliation Tool",
"report_name": "ICUtility",
"report_type": "Script Report",
"roles": [
{
"role": "System Manager"
},
{
"role": "Accounts Manager"
},
{
"role": "Accounts User"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


def execute(filters=None):
# reconcile purchases and inward supplies
_Reconciler = Reconciler(**filters)
for row in ORIGINAL_VS_AMENDED:
_Reconciler.reconcile(row["original"], row["amended"])
Expand Down
Loading

0 comments on commit 5070a9c

Please sign in to comment.