Commit Graph

20 Commits

Author SHA1 Message Date
66e15dee1f change default unit to liter
Since the inventory is mostly containing enginge oils, which are sold per liter, the default unit for a new part is set to liter
2026-05-23 16:43:39 +05:00
aac71becfc remove the invetory sale value from report
Since product prices can be negotiated with every client, the inventory value at sale cannot be determined. Removing the number from the report but keeping the placeholder.
2026-05-23 16:16:49 +05:00
8cbaa55b48 Soft-delete parts and hide SKU/location/description from the UI
Deleting a part used to be impossible. Hard delete would cascade
stock_movements (FK ON DELETE CASCADE) and orphan invoice_lines, losing
the audit trail. Instead, the part detail page now has a Delete button
that flips active=0; listParts and categoriesWithParts filter on active,
but historical joins (recentMovements, linesFor, topSellingParts) stay
unfiltered so old movements and invoices still render the part name.
The existing active checkbox on the detail page doubles as a reactivate
switch.

SKU, location, and description fields are removed from every UI surface
(forms, /parts table, dashboard, movement/invoice pickers, invoice line
labels, top-sellers report). None were load-bearing — barcode + name +
category already cover lookup. The SKU column is kept in the DB
(NOT NULL UNIQUE) and auto-stamped server-side as `SKU-{id}` after
insert, so the change is reversible without a migration. updatePart no
longer writes SKU, freezing it after creation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 20:49:53 +05:00
82bb456103 Run dev on host Node 16 and add deploy patch script
Switch make install/run/build/db-* off docker compose onto the host's
Node (via nvm + .nvmrc). better-sqlite3 7.6.2 doesn't build against
Node 20, and the Dockerfile was still pinned to node:20 while the
rest of the project was downgraded to Node 16 in the Win7 bundle
commit; host execution avoids that mismatch.

Also adds scripts/make-patch.sh (make patch) to produce a small
build-only update zip for an already-installed Win7 target, ignores
dist/, and points start.bat at the installed Chrome PWA shortcut
instead of opening a normal browser tab.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 20:34:41 +05:00
d5a80bb104 Show sale, COG, and profit on /admin/reports
Each summary card now leads with profit (large, green, bold), with
sale and COG shown underneath as a breakdown. The "Top selling parts"
and "Recent sales" tables get Sale/COG/Profit columns, with profit
emphasized; negative profit flips both styles to red. Top parts is
now ordered by profit. COG is computed from each part's current
cost_price for inventory-affecting lines only — custom lines
contribute to sale with zero COG.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 20:34:30 +05:00
83a59f1677 Add Windows 7 deploy bundle pipeline
Self-contained zip (dist/avtoambor-deploy.zip) for end users on Windows 7:
double-click install.bat to install Node 16, then start.bat to launch the
server. start.bat self-relaunches minimized so the console window stays out
of the way. Node is pinned to 16.x and several deps downgraded for Win7
compatibility; the unsupported View Transitions hook is dropped from the
root layout. make bundle wraps scripts/make-bundle.sh.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 09:38:20 +05:00
c882ab5d43 Restructure /admin into tabbed area with password gate
Backups moves under /admin/backups; new Reports and Categories tabs join
it (categories migrated from the top-level /categories route). The
dashboard's SKU/low-stock/inventory-value cards move into Reports, which
also adds sales totals and a top-selling parts list.

A 5-minute sliding-cookie password gate (27182818) now wraps every
/admin request, including the backup download endpoint, via a
hooks.server.js auth check. The login page sits at /admin/login and
escapes the admin tab chrome via a layout reset.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 15:47:42 +05:00
df64de4255 Rename brand to Zamena Masla GP and prefix new backups accordingly
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 15:14:47 +05:00
f42219b442 Add /categories CRUD admin page and localize remaining English strings
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 13:42:51 +05:00
d7dfad9a24 Use PNG instead of JPG for the payment QR image
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 13:21:18 +05:00
00ee9fb1fe Add multi-line sale builder with pending-draft safeguard
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 12:57:49 +05:00
9d756e2940 Add category filters and live search to parts page
- Filter chips for in-use categories with OR semantics; "All" chip shown
  when nothing is selected.
- Search input filters as the user types (150 ms debounce, replaceState
  so back-button stays useful).
- Fix sort indicators: the `arrow()` helper read `sort`/`dir` from a
  plain function, which Svelte's static dep tracking doesn't trace —
  the ▲/▼ never updated on client-side sorts. Made it a reactive `$:`
  declaration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 12:08:47 +05:00
b22630a870 Preset out/qty=1 and use button group for movement type
When arriving at /movements/new with ?part_id=…, default to an 'out'
movement of 1 — recording a sale is the common reason to follow that
link from a part page. Also fix the part option not appearing selected
in the listbox (option value was a number, bound value a string).

Replace the type <select> with three large segmented buttons so the
most-used choice on this page is a single click.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 11:52:58 +05:00
6b78fc7593 write instructions for porting to windows 2026-05-16 07:54:15 +05:00
def8f1d78f Add diagonal view-transition wipe between pages
Hooks SvelteKit's onNavigate into the View Transitions API and styles the
old/new root pseudos with a scaled fade-out and a clip-path diagonal reveal
trimmed by a green drop-shadow accent. Honors prefers-reduced-motion.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 07:49:33 +05:00
8817b5bc07 Switch dev port to 3000, drop dashboard quick actions and header active highlight
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 07:41:38 +05:00
83030bff3a Style header nav as pill buttons with clearer active state
Give nav links a visible translucent pill background and border so they
read as buttons by default, and make the active tab solid white with
the brand red text to clearly indicate the current page.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 07:27:53 +05:00
f65fca09e4 Add automatic backups and an admin restore page
Scheduler ticks every 5 minutes and snapshots data/avtoambor.db (via
better-sqlite3's online backup API) when the DB file's mtime has advanced.
After each new backup, prune older snapshots: keep everything from the last
7 days, then one per calendar day. New /admin page lists backups with
Download and Restore actions, plus a Back-up-now button. Restore takes a
safety snapshot first, closes the live connection, swaps the .db file, and
lets the next request reopen.

Also: TZ=Asia/Dushanbe in the container so backup filenames use local time,
and tzdata added to the image so TZ takes effect.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 07:25:18 +05:00
2bb51940f0 ignore things 2026-05-16 07:06:36 +05:00
05be5b03aa Initial scaffold for AvtoAmbor parts inventory
SvelteKit 2 + Svelte 4 + adapter-node, SQLite via better-sqlite3 (WAL,
foreign keys on). Bilingual EN/Тоҷикӣ throughout, locale persisted in
localStorage.

Pages: dashboard (totals, low stock, recent movements), parts list with
search and sort, part create/edit, record movement (in/out/adjust with
smart unit-price and adjust-quantity prefill), suppliers list with
inline add.

Schema: categories, suppliers, parts (with _en/_tg name+description
columns, dirams for money), stock_movements with check on movement_type.
On-hand updates are done in JS inside a transaction with the movement
insert.

Dockerized dev: docker compose, named project, bind-mounted data/ for
DB persistence. Seed contains 6 categories, 4 suppliers, 31 realistic
parts (Lada / Nexia / Opel / Toyota bias).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 07:05:24 +05:00