Updated invoice number generation #18
|
|
@ -1,2 +1,2 @@
|
|||
Branch: main
|
||||
Commit: 29279bfd72a6fa296d1aa05a825bd88ca1f36c91
|
||||
Branch: invoice-update
|
||||
Commit: 50538bb64faa7f46d643ed60b9f0f272d5624a39
|
||||
|
|
|
|||
|
|
@ -2636,6 +2636,12 @@ create table if not exists commerce.invoices (
|
|||
)
|
||||
);
|
||||
|
||||
create table if not exists commerce.invoice_monthly_sequences (
|
||||
year_month varchar(7) primary key,
|
||||
last_serial integer not null default 0,
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
do $$
|
||||
begin
|
||||
if not exists (
|
||||
|
|
|
|||
|
|
@ -113,6 +113,26 @@ async def lifespan(
|
|||
"Redis caching disabled"
|
||||
)
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# Ensure commerce.invoice_monthly_sequences table exists
|
||||
# -------------------------------------------------------------
|
||||
try:
|
||||
from app.db.session import engine
|
||||
from sqlalchemy import text
|
||||
async with engine.begin() as conn:
|
||||
await conn.execute(text(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS commerce.invoice_monthly_sequences (
|
||||
year_month VARCHAR(7) PRIMARY KEY,
|
||||
last_serial INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
"""
|
||||
))
|
||||
logger.info("Commerce invoice sequence table verified")
|
||||
except Exception as exc:
|
||||
logger.warning("Could not auto-verify invoice sequence table on startup: %s", exc)
|
||||
|
||||
yield
|
||||
|
||||
finally:
|
||||
|
|
|
|||
|
|
@ -2638,6 +2638,12 @@ create table if not exists commerce.invoices (
|
|||
)
|
||||
);
|
||||
|
||||
create table if not exists commerce.invoice_monthly_sequences (
|
||||
year_month varchar(7) primary key,
|
||||
last_serial integer not null default 0,
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
do $$
|
||||
begin
|
||||
if not exists (
|
||||
|
|
|
|||
Loading…
Reference in New Issue