Unlock once for this shift. Your phone can fill the saved login with Face ID, Touch ID, or fingerprint. Scanning does not ask again.
Tap a tile to open it.
Type a quote number, customer or part. Last 7 days and From–To use Chicago time. An empty search with no dates does not list everything.
| Name / Part # | Qty | Value | Status |
|---|
Scan a QR, or type part of a name or part #. Commit before qty updates.
Keep names ≤ 32 characters so the label stays large.
No spaces. The QR uses a separate ID, so editing this later does not require a reprint.
Used = salvage from paid-off systems. Tracked, not valued.
Low flags only when this is above 0 and new qty is at or below it.
Wynn = £ · FFS = € · Alu = kr. Sell = list × factor, up to $5.
Buy = list × exchange rate − 30%. Sell uses the sell factor.
New qty × buy. Used qty is excluded.
Who changed what, and when. Needs the adjustments table (More → SQL).
Generate to load adjustments.
Buy / sell / list changes over time.
Uses the method set on More. New stock only.
Tap a chip to filter.
Cost = new qty × buy (or LIFO/FIFO layers). Used/salvage qty is not valued.
QR opens this app to the part. Name/part # can change later without reprinting.
At least 8 characters. They save it again on their phone.
Existing part numbers are skipped.
Wynn £ and FFS €. Sell rounds up to $5.
Buy = list × rate − 30%. Wynn £, FFS €, Alu kr.
Ending inventory of new stock. Used/salvage is $0.
Checking…
Columns and tables only. Shop access is signed-in users. Do not add open policies.
-- Do not add "allow all" or anon policies. Shop access is signed-in only.
-- The lock already lives in schema/auth_lock_after_merge.sql (already applied on live).
-- Inventory extras
alter table inventory add column if not exists category text;
alter table inventory add column if not exists barcode text;
alter table inventory add column if not exists exclude_from_valuation boolean default false;
alter table inventory add column if not exists list_price numeric;
alter table inventory add column if not exists list_currency text;
alter table inventory add column if not exists sell_factor numeric;
create unique index if not exists inventory_barcode_uidx on inventory (barcode) where barcode is not null;
create index if not exists inventory_category_idx on inventory (category);
create index if not exists inventory_source_idx on inventory (source);
create table if not exists inventory_adjustments (
id uuid primary key default gen_random_uuid(),
inventory_id uuid, part_number text, name text, action text not null,
qty_before integer, qty_after integer, changed_by text, details text,
created_at timestamptz default now()
);
alter table inventory_adjustments enable row level security;
-- Phase 1 quotes (NEW tables only — does not alter inventory rows)
create table if not exists customers (
id uuid primary key default gen_random_uuid(),
name text not null, company text, email text, phone text, notes text,
created_at timestamptz default now(), updated_at timestamptz default now()
);
create table if not exists quotes (
id uuid primary key default gen_random_uuid(),
number text not null unique,
customer_id uuid references customers(id) on delete set null,
customer_name text,
status text not null default 'draft',
quote_date date, valid_until date, prepared_by text, notes text, created_by text,
created_at timestamptz default now(), updated_at timestamptz default now()
);
create index if not exists quotes_status_idx on quotes (status);
create table if not exists quote_lines (
id uuid primary key default gen_random_uuid(),
quote_id uuid not null references quotes(id) on delete cascade,
line_no integer not null default 1,
inventory_id uuid, part_number text, name text not null,
qty numeric not null default 1, unit_price numeric not null default 0
);
create index if not exists quote_lines_quote_id_idx on quote_lines (quote_id);
create table if not exists document_counters (
doc_type text not null, year integer not null, last_value integer not null default 0,
primary key (doc_type, year)
);
alter table customers enable row level security;
alter table quotes enable row level security;
alter table quote_lines enable row level security;
alter table document_counters enable row level security;
grant select, insert, update, delete on table customers to authenticated;
grant select, update on table quotes to authenticated;
grant select, insert, update, delete on table quote_lines to authenticated;
grant select on table document_counters to authenticated;
grant select, insert, update, delete on table inventory_adjustments to authenticated;
-- Phase 2 quote extras / packing lists / invoices (additive)
alter table quotes add column if not exists project text;
alter table quotes add column if not exists rfq_number text;
alter table quotes add column if not exists fob_point text;
alter table quotes add column if not exists payment_terms text;
alter table quotes add column if not exists lead_time text;
alter table customers add column if not exists payment_terms text;
create index if not exists quotes_customer_id_idx on quotes (customer_id);
create table if not exists app_settings (key text primary key, value text, updated_at timestamptz default now());
create table if not exists app_lookups (kind text not null, value text not null, created_at timestamptz default now(), primary key (kind, value));
create table if not exists packing_lists (
id uuid primary key default gen_random_uuid(), number text not null unique,
quote_id uuid references quotes(id) on delete set null, customer_name text, project text,
pack_date date, prepared_by text, notes text, created_by text, created_at timestamptz default now());
create table if not exists packing_list_lines (
id uuid primary key default gen_random_uuid(), packing_list_id uuid not null references packing_lists(id) on delete cascade,
line_no integer not null default 1, inventory_id uuid, part_number text, name text not null, qty numeric not null default 1);
create table if not exists invoices (
id uuid primary key default gen_random_uuid(), number text not null unique,
quote_id uuid references quotes(id) on delete set null,
customer_name text, project text, po_number text, ship_to text, invoice_date date, due_date date,
fob_point text, payment_terms text, cc_used boolean default false, cc_fee_rate numeric default 0.035,
cc_fee_amount numeric default 0, shipping_fee numeric default 0, duty numeric default 0, tariffs numeric default 0,
subtotal numeric default 0, total numeric default 0, prepared_by text, notes text,
status text not null default 'draft', created_by text,
created_at timestamptz default now(), updated_at timestamptz default now());
create table if not exists invoice_lines (
id uuid primary key default gen_random_uuid(), invoice_id uuid not null references invoices(id) on delete cascade,
line_no integer not null default 1, inventory_id uuid, part_number text, name text not null,
qty numeric not null default 1, unit_price numeric not null default 0);
create index if not exists packing_lists_quote_id_idx on packing_lists (quote_id);
create index if not exists packing_list_lines_pl_id_idx on packing_list_lines (packing_list_id);
create index if not exists invoices_quote_id_idx on invoices (quote_id);
create index if not exists invoice_lines_invoice_id_idx on invoice_lines (invoice_id);
insert into app_lookups (kind, value) values
('fob','Origin'),('fob','Destination'),
('payment_terms','Due on receipt'),('payment_terms','Net 15'),
('payment_terms','Net 30'),('payment_terms','Net 45'),('payment_terms','Net 60')
on conflict do nothing;
alter table app_settings enable row level security;
alter table app_lookups enable row level security;
alter table packing_lists enable row level security;
alter table packing_list_lines enable row level security;
alter table invoices enable row level security;
alter table invoice_lines enable row level security;
grant select, insert, update, delete on table app_settings to authenticated;
grant select, insert, update, delete on table app_lookups to authenticated;
grant select, insert, update, delete on table packing_lists to authenticated;
grant select, insert, update, delete on table packing_list_lines to authenticated;
grant select, insert, update, delete on table invoices to authenticated;
grant select, insert, update, delete on table invoice_lines to authenticated;
notify pgrst, 'reload schema';
-- Phase 3: used qty, price history, LIFO/FIFO layers
alter table inventory add column if not exists qty_used integer default 0;
create index if not exists inventory_location_idx on inventory (location);
create table if not exists inventory_price_history (
id uuid primary key default gen_random_uuid(), inventory_id uuid, part_number text, name text,
recorded_at timestamptz default now(), buy_price numeric, sell_price numeric, list_price numeric,
list_currency text, qty integer, qty_used integer, note text, changed_by text);
create index if not exists inventory_price_history_part_idx on inventory_price_history (part_number, recorded_at desc);
create table if not exists inventory_cost_layers (
id uuid primary key default gen_random_uuid(), inventory_id uuid, part_number text,
acquired_at timestamptz default now(), unit_cost numeric not null default 0,
qty_original numeric not null default 0, qty_remaining numeric not null default 0,
condition text not null default 'new', source text, changed_by text);
create index if not exists inventory_cost_layers_inv_idx on inventory_cost_layers (inventory_id, condition, acquired_at);
alter table inventory_price_history enable row level security;
alter table inventory_cost_layers enable row level security;
grant select, insert, update, delete on table inventory_price_history to authenticated;
grant select, insert, update, delete on table inventory_cost_layers to authenticated;
notify pgrst, 'reload schema';
Deletes every part. Export a backup first.