Skip to content

Commit

Permalink
Merge branch 'version-13-hotfix' into mergify/bp/version-13-hotfix/pr…
Browse files Browse the repository at this point in the history
…-32346
  • Loading branch information
s-aga-r authored Sep 26, 2022
2 parents a66002f + 9332e7f commit 9066009
Showing 1 changed file with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import frappe
from frappe import _
from frappe.query_builder import Field
from frappe.query_builder.functions import Min, Timestamp
from frappe.utils import add_days, getdate, today
from six import iteritems

Expand All @@ -29,7 +31,7 @@ def execute(filters=None):
def get_unsync_date(filters):
date = filters.from_date
if not date:
date = frappe.db.sql(""" SELECT min(posting_date) from `tabStock Ledger Entry`""")
date = (frappe.qb.from_("Stock Ledger Entry").select(Min(Field("posting_date")))).run()
date = date[0][0]

if not date:
Expand All @@ -55,22 +57,27 @@ def get_data(report_filters):
result = []

voucher_wise_dict = {}
data = frappe.db.sql(
"""
SELECT
name, posting_date, posting_time, voucher_type, voucher_no,
stock_value_difference, stock_value, warehouse, item_code
FROM
`tabStock Ledger Entry`
WHERE
posting_date
= %s and company = %s
and is_cancelled = 0
ORDER BY timestamp(posting_date, posting_time) asc, creation asc
""",
(from_date, report_filters.company),
as_dict=1,
)
sle = frappe.qb.DocType("Stock Ledger Entry")
data = (
frappe.qb.from_(sle)
.select(
sle.name,
sle.posting_date,
sle.posting_time,
sle.voucher_type,
sle.voucher_no,
sle.stock_value_difference,
sle.stock_value,
sle.warehouse,
sle.item_code,
)
.where(
(sle.posting_date == from_date)
& (sle.company == report_filters.company)
& (sle.is_cancelled == 0)
)
.orderby(Timestamp(sle.posting_date, sle.posting_time), sle.creation)
).run(as_dict=True)

for d in data:
voucher_wise_dict.setdefault((d.item_code, d.warehouse), []).append(d)
Expand Down

0 comments on commit 9066009

Please sign in to comment.