Fix: Product query was giving the version id and not product id.
The product ledger query needs to be uniqued.
This commit is contained in:
@ -511,7 +511,7 @@ async def show_term_product(
|
|||||||
for item in db.execute(query_).unique().scalars().all():
|
for item in db.execute(query_).unique().scalars().all():
|
||||||
list_.append(
|
list_.append(
|
||||||
ProductSku(
|
ProductSku(
|
||||||
id_=item.id,
|
id_=item.product_id,
|
||||||
name=item.name,
|
name=item.name,
|
||||||
fraction_units=item.fraction_units,
|
fraction_units=item.fraction_units,
|
||||||
cost_price=Decimal(0),
|
cost_price=Decimal(0),
|
||||||
|
|||||||
@ -86,7 +86,8 @@ def build_report(
|
|||||||
SkuVersion.valid_till >= Voucher.date_,
|
SkuVersion.valid_till >= Voucher.date_,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
query: list[tuple[Voucher, Inventory, Journal, SkuVersion]] = db.execute( # type: ignore[assignment]
|
query: list[tuple[Voucher, Inventory, Journal, SkuVersion]] = (
|
||||||
|
db.execute( # type: ignore[assignment]
|
||||||
select(Voucher, Inventory, Journal, SkuVersion)
|
select(Voucher, Inventory, Journal, SkuVersion)
|
||||||
.select_from(Voucher)
|
.select_from(Voucher)
|
||||||
.join(Voucher.journals)
|
.join(Voucher.journals)
|
||||||
@ -108,7 +109,10 @@ def build_report(
|
|||||||
Voucher.date_ <= finish_date,
|
Voucher.date_ <= finish_date,
|
||||||
)
|
)
|
||||||
.order_by(Voucher.date_, Voucher.last_edit_date)
|
.order_by(Voucher.date_, Voucher.last_edit_date)
|
||||||
).all()
|
)
|
||||||
|
.unique()
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
|
||||||
for voucher, inventory, journal, stockKeepingUnit in query:
|
for voucher, inventory, journal, stockKeepingUnit in query:
|
||||||
journal_debit = journal.debit * -1
|
journal_debit = journal.debit * -1
|
||||||
|
|||||||
Reference in New Issue
Block a user