Bundle item has an option to not print in the bill.

Bills and Kots should print properly with bundles
This commit is contained in:
tanshu committed 2026-02-10 18:00:03 +00:00
1 parent 7382d487ac
commit 91b3740ec0
36 files changed
+290 -141

No files matched your search

@@ -28,6 +28,7 @@ def upgrade():
sa.Column("item_id", sa.Uuid(), nullable=False),
sa.Column("quantity", sa.Numeric(precision=15, scale=2), nullable=False),
sa.Column("sale_price", sa.Numeric(precision=15, scale=2), nullable=False),
sa.Column("print_in_bill", sa.Boolean(), server_default=sa.text("true"), nullable=False),
sa.Column("valid_from", sa.Date(), nullable=True),
sa.Column("valid_till", sa.Date(), nullable=True),
postgresql.ExcludeConstraint(
@@ -47,7 +48,7 @@ def upgrade():
)
inventory_type = sa.Enum("regular", "bundle", "bundle_item", name="inventorytype")
# inventory_type.create(op.get_bind())
inventory_type.create(op.get_bind())
op.add_column("inventories", sa.Column("type", inventory_type, server_default=sa.text("'regular'"), nullable=False))
op.add_column("inventories", sa.Column("parent_id", sa.Uuid(), nullable=True))
op.drop_constraint(op.f("uq_inventories_kot_id"), "inventories", type_="unique")
@@ -82,6 +83,45 @@ def upgrade():
)
)
customers = sa.table(
"customers",
sa.column("id", sa.Uuid),
sa.column("name", sa.Text),
sa.column("phone", sa.Text),
)
guest_book = sa.table(
"guest_book",
sa.column("customer_id", sa.Uuid),
)
voucher = sa.table(
"vouchers",
sa.column("customer_id", sa.Uuid),
)
bad_customer_ids = sa.select(customers.c.id).where(
sa.func.length(sa.func.trim(customers.c.phone)) == 0,
)
op.execute(guest_book.delete().where(guest_book.c.customer_id.in_(bad_customer_ids)))
op.execute(voucher.update().where(voucher.c.customer_id.in_(bad_customer_ids)).values(customer_id=None))
op.execute(customers.delete().where(customers.c.id.in_(bad_customer_ids)))
op.execute(
customers.update()
.where(
sa.func.length(sa.func.trim(customers.c.name)) == 0,
)
.values(name=customers.c.phone)
)
with op.batch_alter_table("customers") as batch_op:
batch_op.create_check_constraint("name_not_blank", sa.text("length(trim(both from name)) >= 1"))
batch_op.create_check_constraint("phone_not_blank", sa.text("length(trim(both from phone)) >= 1"))
def downgrade():
op.drop_table("bundle_items")
@@ -101,3 +141,7 @@ def downgrade():
sa.column("id", sa.Uuid()),
)
op.execute(mc.delete().where(mc.c.id == "6752ed9d-6f1a-4941-940a-17759dcc6720"))
with op.batch_alter_table("customers") as batch_op:
batch_op.drop_constraint("name_not_blank", type_="check")
batch_op.drop_constraint("phone_not_blank", type_="check")