Calculations and saved indents
← Open engine · Calculation and deployment guide
Saved-copy behavior
A saved indent contains a separate copy of dated inputs, holidays, item rules and original calculated results. Later changes do not modify it. Multiple revisions are retained. Incomplete calculations remain labelled drafts. Saved results are read only; Use as draft creates an editable working copy while preserving saved originals.
JSON backups include current work and all saved history. Old backups without history remain supported. Archives are validated for item identities, numeric values, statuses, date coverage and summaries. Duplicate IDs, recursive snapshots and malformed archives are rejected. Existing history is not silently evicted when browser storage is full.
Browser checks and fix
- An existing browser draft loaded after the upgrade without losing inputs or item rules.
- Save indent opened a named-copy dialog and labelled the incomplete 89-item calculation as a draft.
- The first browser test found an identifier-generation incompatibility on the non-HTTPS preview. The ID generator was changed to work in this context and saving was retested successfully.
- Saved Indents listed the preparation date, coverage, IST saved timestamp, requested-line count and draft status.
- After live Glucose stock changed from 0 to 10 packets, the saved copy retained original stock 0 and To Indent 1.
- The archived report was labelled read only and contained no rule-edit controls.
- Saved CSV export downloaded successfully from the archived report.
- The saved copy remained in history after a full browser reload.
- Use as draft restored the saved input/rules after confirmation while leaving the archive intact.
- Export backup with history completed successfully.
- No application-origin console errors were observed.
- Desktop Saved Indents layout was visually reviewed; dates and timestamps display dd/mm/yyyy.
Automated checks
| Suite | Check | Result |
|---|---|---|
| Calculations | Date display is dd/mm/yyyy with leading zeroes | PASS |
| Calculations | Date entry parses dd/mm/yyyy to an unambiguous internal value | PASS |
| Calculations | US date entry rejected | PASS |
| Calculations | Impossible calendar date rejected | PASS |
| Calculations | Single-digit dates rejected to enforce requested format | PASS |
| Calculations | Leap date accepted | PASS |
| Calculations | Tuesday maps to upcoming Wednesday–Tuesday across month boundary | PASS |
| Calculations | Normal chemistry baseline is 6.5 day loads | PASS |
| Calculations | Saturday remains full load | PASS |
| Calculations | Sunday selected twice never double-counts the reduction | PASS |
| Calculations | Normal immunoassay baseline is six days; Sunday zero | PASS |
| Calculations | One extra holiday reduces chemistry by half a day | PASS |
| Calculations | One extra holiday removes one immunoassay day | PASS |
| Calculations | Calendar-day consumable demand unaffected by holiday | PASS |
| Calculations | Weekly need rounds upward to 20 before pack conversion | PASS |
| Calculations | Glucose zero-stock example now needs one pack, without an added bridge | PASS |
| Calculations | Exact weekly multiple of 20 stays unchanged | PASS |
| Calculations | Zero demand stays zero | PASS |
| Calculations | Pack rounding occurs before stock subtraction | PASS |
| Calculations | In Lab is the entered supply-unit balance, with no time deduction | PASS |
| Calculations | To Indent equals rounded packs needed minus In Lab | PASS |
| Calculations | Excess stock never gives negative order | PASS |
| Calculations | Fractional supply stock rounds the remaining request upward | PASS |
| Calculations | Permitted half-unit supply increment respected | PASS |
| Calculations | Loose reagent balance is labelled bottles | PASS |
| Calculations | R1 bottles per pack determine tests per loose bottle | PASS |
| Calculations | Two loose Glucose bottles equal 0.4 packet | PASS |
| Calculations | Half a loose bottle is supported | PASS |
| Calculations | Total Protein loose bottle equals one bottle supply unit | PASS |
| Calculations | Unknown bottle conversion blocks positive loose stock | PASS |
| Calculations | Unknown bottle conversion does not block a verified zero loose balance | PASS |
| Calculations | QC loose balance remains in aliquots | PASS |
| Calculations | Consumable loose pieces remain pieces | PASS |
| Calculations | Cobas opening shots counted directly without hour interpolation | PASS |
| Calculations | Before-loading packs count exactly once | PASS |
| Calculations | After-loading mode does not add loaded packs again | PASS |
| Calculations | Before-loading mode requires loading entry | PASS |
| Calculations | Cobas missing shots stays incomplete | PASS |
| Calculations | Zero stock generates no before-receipt risk field or summary count | PASS |
| Calculations | Blank stock remains unknown | PASS |
| Calculations | Negative stock rejected | PASS |
| Calculations | Missing consumption is not treated as zero | PASS |
| Calculations | Missing pack yield is not treated as zero | PASS |
| Calculations | Dept zero flags NA without reducing request | PASS |
| Calculations | Positive insufficient Dept stock flags short supply, not NA | PASS |
| Calculations | Unknown Dept stock creates no invented NA | PASS |
| Calculations | Target-stock rule retains exact target before supply conversion | PASS |
| Calculations | Amylase loose bottles and stock pool into a single ordering row | PASS |
| Calculations | Unknown nonzero Erba yield blocks the pooled result | PASS |
| Calculations | Inactive preferred Amylase does not silently drop demand | PASS |
| Calculations | Duplicate CSV item IDs rejected | PASS |
| Calculations | Negative import rejected without mutating current stock | PASS |
| Calculations | Positive loose-bottle CSV validates its unit | PASS |
| Calculations | Legacy loose-tests CSV is rejected instead of reinterpreted as bottles | PASS |
| Calculations | Ambiguous nonzero loose CSV without unit is rejected | PASS |
| Calculations | Legacy zero loose CSV is safely accepted | PASS |
| Calculations | Quoted CSV cells round-trip | PASS |
| Calculations | CSV spreadsheet-formula prefixes neutralized | PASS |
| Calculations | Version-1 backup loose tests convert to bottles without losing capacity | PASS |
| Calculations | Version-1 master uses known seed bottles-per-pack during migration | PASS |
| Calculations | Unconvertible legacy loose test balance is cleared with an explicit notice | PASS |
| Calculations | Version-2 loose bottles are not migrated a second time | PASS |
| Calculations | Duplicate backup IDs rejected | PASS |
| Calculations | Invalid bottles-per-pack backup rejected | PASS |
| Calculations | Updated master has 95 rows / 93 enabled / known reagent bottle metadata | PASS |
| Calculations | Corrected Hitachi supply remains 200 pieces | PASS |
| Calculations | New plan has no stale stock entries | PASS |
| Calculations | 52 consecutive planning weeks retain six full days plus reduced Sunday | PASS |
| Calculations | 5000 independent randomized cases: pack-first formula, bottles, shots, holidays and monotonicity | PASS |
| History | Save includes a dated calculation and complete inputs | PASS |
| History | Saving makes a deep snapshot, independent of current stock | PASS |
| History | Saving preserves original rules after later live edits | PASS |
| History | Changing current holidays leaves saved needs and dates unchanged | PASS |
| History | Incomplete calculations save explicitly as drafts | PASS |
| History | A new revision adds another saved copy without overwriting | PASS |
| History | Archive addition does not mutate the old workspace | PASS |
| History | Snapshot does not recursively include prior history | PASS |
| History | Backup round-trip retains all saved snapshots and their calculated values | PASS |
| History | Old backup without history upgrades to an empty archive | PASS |
| History | Old schema-one backup still migrates loose tests to bottles | PASS |
| History | Use as draft restores old input and rules while retaining all saved originals | PASS |
| History | A result saved by an earlier engine version keeps its original numbers and version | PASS |
| History | Saved time uses dd/mm/yyyy and Indian Standard Time | PASS |
| History | Default saved IDs are unique | PASS |
| History | Duplicate history IDs rejected atomically | PASS |
| History | Duplicate archive insertion rejected | PASS |
| History | Recursive snapshots rejected | PASS |
| History | Negative saved quantities rejected | PASS |
| History | Contradictory status and quantity rejected | PASS |
| History | Tampered summary counts rejected | PASS |
| History | Tampered saved coverage dates rejected | PASS |
| History | Missing saved result rows rejected | PASS |
| History | Changed saved item identity rejected | PASS |
| History | Malformed saved timestamps rejected | PASS |
| History | Overlong saved names rejected | PASS |
| History | Blank saved name gets a nonempty default | PASS |
| History | Invalid current plan cannot be archived | PASS |
| History | Archive bounds enforced without deleting existing records | PASS |
| History | 200 consecutive weekly snapshots survive changes and JSON restore | PASS |
Scope
History is browser-local, not shared server storage. Export backups before clearing browser data. The 200-snapshot exercise used representative small calculation records to test retention and restore; it does not guarantee storage capacity for 200 full laboratory registers. Actual capacity depends on the browser.
No account deployment, physical printer, actual phone, or browser file-import action was tested. Saved-copy creation, reload, immutable viewing, working-copy restoration and CSV/JSON downloads were tested in desktop Chrome. Backup restore and malformed archive rejection were tested through the same validation module used by the application.
Re-run node verification/engine.test.mjs and node verification/history.test.mjs from the extracted package. No dependencies are required. These checks validate software behavior, not actual consumption, expiry or QC performance.