Skip to content

Commit 1599695

Browse files
Merge pull request #52152 from rohitwaghchaure/refactor-reposting-feature
Refactor reposting feature
2 parents f37b6fd + daa2420 commit 1599695

5 files changed

Lines changed: 461 additions & 362 deletions

File tree

erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,15 @@ frappe.ui.form.on("Repost Item Valuation", {
6969
}
7070

7171
if (frm.doc.status == "In Progress") {
72-
frm.doc.current_index = data.current_index;
73-
frm.doc.items_to_be_repost = data.items_to_be_repost;
74-
frm.doc.total_reposting_count = data.total_reposting_count;
72+
if (data.current_index) {
73+
frm.doc.current_index = data.current_index;
74+
frm.doc.items_to_be_repost = data.items_to_be_repost;
75+
}
76+
77+
if (data.vouchers_posted) {
78+
frm.doc.total_vouchers = data.total_vouchers;
79+
frm.doc.vouchers_posted = data.vouchers_posted;
80+
}
7581

7682
frm.dashboard.reset();
7783
frm.trigger("show_reposting_progress");
@@ -108,23 +114,39 @@ frappe.ui.form.on("Repost Item Valuation", {
108114

109115
show_reposting_progress: function (frm) {
110116
var bars = [];
111-
117+
let title = "";
118+
let progress = 0.0;
112119
let total_count = frm.doc.items_to_be_repost ? JSON.parse(frm.doc.items_to_be_repost).length : 0;
113120

114-
if (frm.doc?.total_reposting_count) {
115-
total_count = frm.doc.total_reposting_count;
121+
if (total_count > 1) {
122+
progress = flt((cint(frm.doc.current_index) / total_count) * 100, 2) || 0.5;
123+
title = __("Reposting for Item-Wh Completed {0}%", [progress]);
124+
125+
bars.push({
126+
title: title,
127+
width: progress + "%",
128+
progress_class: "progress-bar-success",
129+
});
130+
131+
frm.dashboard.add_progress(__("Reposting Progress"), bars);
132+
}
133+
134+
if (!frm.doc.vouchers_posted) {
135+
return;
116136
}
117137

118-
let progress = flt((cint(frm.doc.current_index) / total_count) * 100, 2) || 0.5;
119-
var title = __("Reposting Completed {0}%", [progress]);
138+
// Show voucher posting progress if vouchers are being reposted
139+
bars = [];
140+
progress = flt((cint(frm.doc.vouchers_posted) / cint(frm.doc.total_vouchers)) * 100, 2) || 0.5;
141+
title = __("Reposting for Vouchers Completed {0}%", [progress]);
120142

121143
bars.push({
122144
title: title,
123145
width: progress + "%",
124146
progress_class: "progress-bar-success",
125147
});
126148

127-
frm.dashboard.add_progress(__("Reposting Progress"), bars);
149+
frm.dashboard.add_progress(__("Reposting Vouchers Progress"), bars);
128150
},
129151

130152
restart_reposting: function (frm) {

erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.json

Lines changed: 91 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@
2727
"error_section",
2828
"error_log",
2929
"reposting_info_section",
30-
"reposting_data_file",
3130
"items_to_be_repost",
32-
"distinct_item_and_warehouse",
3331
"column_break_o1sj",
3432
"total_reposting_count",
3533
"current_index",
3634
"gl_reposting_index",
37-
"affected_transactions"
35+
"vouchers_based_on_item_and_warehouse_section",
36+
"total_vouchers",
37+
"column_break_yqwo",
38+
"vouchers_posted",
39+
"last_sle_posted_section",
40+
"reposted_item_code",
41+
"reposted_warehouse",
42+
"reposting_data_file",
43+
"column_break_miwc",
44+
"sle_posting_date",
45+
"sle_posting_time",
46+
"reposted_sle_creation"
3847
],
3948
"fields": [
4049
{
@@ -167,15 +176,6 @@
167176
"print_hide": 1,
168177
"read_only": 1
169178
},
170-
{
171-
"fieldname": "distinct_item_and_warehouse",
172-
"fieldtype": "Code",
173-
"hidden": 1,
174-
"label": "Distinct Item and Warehouse",
175-
"no_copy": 1,
176-
"print_hide": 1,
177-
"read_only": 1
178-
},
179179
{
180180
"fieldname": "current_index",
181181
"fieldtype": "Int",
@@ -185,14 +185,6 @@
185185
"print_hide": 1,
186186
"read_only": 1
187187
},
188-
{
189-
"fieldname": "affected_transactions",
190-
"fieldtype": "Code",
191-
"hidden": 1,
192-
"label": "Affected Transactions",
193-
"no_copy": 1,
194-
"read_only": 1
195-
},
196188
{
197189
"default": "0",
198190
"fieldname": "gl_reposting_index",
@@ -205,7 +197,7 @@
205197
{
206198
"fieldname": "reposting_info_section",
207199
"fieldtype": "Section Break",
208-
"label": "Reposting Info"
200+
"label": "Reposting Item and Warehouse"
209201
},
210202
{
211203
"fieldname": "column_break_o1sj",
@@ -214,14 +206,7 @@
214206
{
215207
"fieldname": "total_reposting_count",
216208
"fieldtype": "Int",
217-
"label": "Total Reposting Count",
218-
"no_copy": 1,
219-
"read_only": 1
220-
},
221-
{
222-
"fieldname": "reposting_data_file",
223-
"fieldtype": "Attach",
224-
"label": "Reposting Data File",
209+
"label": "No of Items to Repost",
225210
"no_copy": 1,
226211
"read_only": 1
227212
},
@@ -247,13 +232,89 @@
247232
"fieldname": "repost_only_accounting_ledgers",
248233
"fieldtype": "Check",
249234
"label": "Repost Only Accounting Ledgers"
235+
},
236+
{
237+
"fieldname": "vouchers_based_on_item_and_warehouse_section",
238+
"fieldtype": "Section Break",
239+
"label": "Reposting Vouchers"
240+
},
241+
{
242+
"fieldname": "total_vouchers",
243+
"fieldtype": "Int",
244+
"label": "Total Ledgers",
245+
"no_copy": 1,
246+
"read_only": 1
247+
},
248+
{
249+
"fieldname": "column_break_yqwo",
250+
"fieldtype": "Column Break"
251+
},
252+
{
253+
"fieldname": "vouchers_posted",
254+
"fieldtype": "Int",
255+
"label": "Ledgers Posted",
256+
"no_copy": 1,
257+
"read_only": 1
258+
},
259+
{
260+
"fieldname": "last_sle_posted_section",
261+
"fieldtype": "Section Break",
262+
"label": "Last SLE Posted"
263+
},
264+
{
265+
"fieldname": "reposted_item_code",
266+
"fieldtype": "Link",
267+
"label": "Reposted Item Code",
268+
"no_copy": 1,
269+
"options": "Item",
270+
"read_only": 1
271+
},
272+
{
273+
"fieldname": "reposted_warehouse",
274+
"fieldtype": "Link",
275+
"label": "Reposted Warehouse",
276+
"no_copy": 1,
277+
"options": "Warehouse",
278+
"read_only": 1
279+
},
280+
{
281+
"fieldname": "column_break_miwc",
282+
"fieldtype": "Column Break"
283+
},
284+
{
285+
"fieldname": "reposted_sle_creation",
286+
"fieldtype": "Datetime",
287+
"label": "Reposted SLE Creation",
288+
"no_copy": 1,
289+
"read_only": 1
290+
},
291+
{
292+
"fieldname": "sle_posting_date",
293+
"fieldtype": "Date",
294+
"label": "SLE Posting Date",
295+
"no_copy": 1,
296+
"read_only": 1
297+
},
298+
{
299+
"fieldname": "sle_posting_time",
300+
"fieldtype": "Time",
301+
"label": "SLE Posting Time",
302+
"no_copy": 1,
303+
"read_only": 1
304+
},
305+
{
306+
"fieldname": "reposting_data_file",
307+
"fieldtype": "Attach",
308+
"label": "Reposting Data File",
309+
"no_copy": 1,
310+
"read_only": 1
250311
}
251312
],
252313
"grid_page_length": 50,
253314
"index_web_pages_for_search": 1,
254315
"is_submittable": 1,
255316
"links": [],
256-
"modified": "2026-02-25 14:22:21.681549",
317+
"modified": "2026-03-26 13:52:51.895504",
257318
"modified_by": "Administrator",
258319
"module": "Stock",
259320
"name": "Repost Item Valuation",

erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ class RepostItemValuation(Document):
3535
if TYPE_CHECKING:
3636
from frappe.types import DF
3737

38-
affected_transactions: DF.Code | None
3938
allow_negative_stock: DF.Check
4039
allow_zero_rate: DF.Check
4140
amended_from: DF.Link | None
4241
based_on: DF.Literal["Transaction", "Item and Warehouse"]
4342
company: DF.Link | None
4443
current_index: DF.Int
45-
distinct_item_and_warehouse: DF.Code | None
4644
error_log: DF.LongText | None
4745
gl_reposting_index: DF.Int
4846
item_code: DF.Link | None
@@ -51,13 +49,20 @@ class RepostItemValuation(Document):
5149
posting_time: DF.Time | None
5250
recreate_stock_ledgers: DF.Check
5351
repost_only_accounting_ledgers: DF.Check
52+
reposted_item_code: DF.Link | None
53+
reposted_sle_creation: DF.Datetime | None
54+
reposted_warehouse: DF.Link | None
5455
reposting_data_file: DF.Attach | None
5556
reposting_reference: DF.Data | None
57+
sle_posting_date: DF.Date | None
58+
sle_posting_time: DF.Time | None
5659
status: DF.Literal["Queued", "In Progress", "Completed", "Skipped", "Failed", "Cancelled"]
5760
total_reposting_count: DF.Int
61+
total_vouchers: DF.Int
5862
via_landed_cost_voucher: DF.Check
5963
voucher_no: DF.DynamicLink | None
6064
voucher_type: DF.Link | None
65+
vouchers_posted: DF.Int
6166
warehouse: DF.Link | None
6267
# end: auto-generated types
6368

@@ -261,6 +266,13 @@ def restart_reposting(self):
261266
self.items_to_be_repost = None
262267
self.gl_reposting_index = 0
263268
self.total_reposting_count = 0
269+
self.total_vouchers = 0
270+
self.vouchers_posted = 0
271+
self.reposted_item_code = None
272+
self.reposted_warehouse = None
273+
self.sle_posting_date = None
274+
self.sle_posting_time = None
275+
self.reposted_sle_creation = None
264276
self.clear_attachment()
265277
self.db_update()
266278

@@ -435,7 +447,7 @@ def repost_sl_entries(doc):
435447
)
436448
else:
437449
repost_future_sle(
438-
args=[
450+
items_to_be_repost=[
439451
frappe._dict(
440452
{
441453
"item_code": doc.item_code,

erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,7 @@ def get_item_warehouse_combinations(filters: dict | None = None) -> dict:
248248
bin.warehouse,
249249
item.valuation_method,
250250
)
251-
.where(
252-
(item.is_stock_item == 1)
253-
& (item.has_serial_no == 0)
254-
& (warehouse.is_group == 0)
255-
& (warehouse.company == filters.company)
256-
)
251+
.where((item.is_stock_item == 1) & (warehouse.is_group == 0) & (warehouse.company == filters.company))
257252
)
258253

259254
if filters.item_code:

0 commit comments

Comments
 (0)