Add Phase 18 automatic stock item voucher preparation
This commit is contained in:
@@ -310,7 +310,7 @@ def create_draft(
|
||||
def get_draft(db, *, tenant_id: int, client_id: int, draft_id: int):
|
||||
return db.execute(
|
||||
select(AccountingVoucherDraft)
|
||||
.options(selectinload(AccountingVoucherDraft.lines))
|
||||
.options(selectinload(AccountingVoucherDraft.lines), selectinload(AccountingVoucherDraft.items))
|
||||
.where(
|
||||
AccountingVoucherDraft.id == int(draft_id),
|
||||
AccountingVoucherDraft.tenant_id == int(tenant_id),
|
||||
@@ -335,7 +335,7 @@ def list_drafts(db, *, tenant_id: int, client_id: int, status: str = "", page: i
|
||||
rows = list(
|
||||
db.execute(
|
||||
select(AccountingVoucherDraft)
|
||||
.options(selectinload(AccountingVoucherDraft.lines))
|
||||
.options(selectinload(AccountingVoucherDraft.lines), selectinload(AccountingVoucherDraft.items))
|
||||
.where(*where)
|
||||
.order_by(AccountingVoucherDraft.id.desc())
|
||||
.offset((page - 1) * per_page)
|
||||
@@ -440,6 +440,21 @@ def _payload(draft: AccountingVoucherDraft):
|
||||
}
|
||||
for line in draft.lines
|
||||
],
|
||||
"items": [
|
||||
{
|
||||
"stock_item_name": item.stock_item_name,
|
||||
"hsn_sac": item.hsn_sac,
|
||||
"quantity": float(item.quantity),
|
||||
"unit": item.unit,
|
||||
"rate": float(item.rate),
|
||||
"amount": float(item.amount),
|
||||
"dr_cr": item.dr_cr,
|
||||
"accounting_ledger_name": item.accounting_ledger_name,
|
||||
"godown_name": item.godown_name,
|
||||
"source_item_json": item.source_item_json,
|
||||
}
|
||||
for item in draft.items
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user