Skip to content

feat(blender): add a line as a free amount or a priced gas fill - #2310

Open
alpheios-one wants to merge 5 commits into
submersion-app:mainfrom
alpheios-one:github-issue-2302-blender-add-line
Open

alpheios-one wants to merge 5 commits into
submersion-app:mainfrom
alpheios-one:github-issue-2302-blender-add-line

Conversation

@alpheios-one

Copy link
Copy Markdown
Contributor

Related Issue

Closes #2302

Summary

"Add a line" on the Trimix blender's running bill used to ask for a description, a cylinder, O2 %, He % and an amount typed by hand. The mix fields had no effect on the amount, so billing a single gas meant working the price out by hand even though the gas prices are already configured.

The line form now switches between two kinds and shows only the fields the chosen kind needs:

  • Gas fill: pick O2, Helium or Top-up, the cylinder volume, a start pressure and an end pressure. The end pressure is seeded from the cylinder preset's working pressure and stays editable. The amount is cylinder volume x (end - start) / 100 x price per 100 l, the same ideal-gas pricing computeBlendCost uses, and is shown as text only.
  • Free amount: a description and an amount typed by hand, for lump sums such as an O2 analyser cell.

Changes

  • manualGasFillCost in blend_billing.dart prices one hand-entered gas fill. It rejects a missing cylinder, a negative start, an end not above the start and non-finite input. A gas without a price is charged at 0, as agreed in the issue.
  • BilledGasLine gets optional role and startBar fields. A gas fill is stored as a BilledFill with exactly one such line, so the running bill, the invoice archive and the Excel export itemise it like any computed fill. BilledFill.manualGasLine recognises it and copyWith can now replace lines.
  • BilledCustomMix is retired. Older blobs that still carry customMix decode without it, and no migration is needed.
  • The line form moves out of blender_invoice_card.dart into blender_line_edit_sheet.dart. The invoice card shrinks by about 320 lines.
  • Reopening a gas fill restores its gas, cylinder and pressures:
    • If only the description changes, the fill keeps the amount and gas name it was billed with, so a later tariff change does not reprice it.
    • Pressures reopen with two decimals, so an untouched save cannot move them.
    • A generated description is regenerated when the fill changes, in whatever unit it was created.
  • A cylinder preset picked in cubic feet bills its exact water volume, not the rounded value shown in the field.
  • Switching a gas fill to a free amount starts from its cost and label.
  • Fills computed by the blender itself are unchanged: no kind switch, and their amount stays editable.
  • New strings in all 11 locales. The "needs a description" message now only asks for a description.

How to Test

  1. Gas Calculators > Trimix blender. Set the gas prices first under Settings > Trimix Mixer.
  2. In the invoice card, tap Add a line. The form opens as Gas fill.
  3. Pick Helium, enter 12 l, start 50 bar and end 200 bar. With helium at 1.50 per 100 l, the form shows "Fill pressure: 150 bar" and "Amount: CHF 27.00".
  4. Pick a cylinder preset. The volume and the end pressure follow it, and the end pressure can still be overwritten.
  5. Switch to Free amount. Only the description and the amount remain.

Test Plan

  • flutter test test/features/gas_calculators passes (416 tests), including new unit tests for the pricing and the model and widget tests for:
    • the kind switch
    • live pricing
    • a missing price
    • invalid and empty pressures
    • presets, including cubic feet
    • psi entry
    • reopening, repricing and description-only edits
    • switching a gas fill to a free amount
  • flutter analyze passes
  • Manual testing on: Windows

The line form now switches between a free amount and a gas fill. A gas fill picks O2, helium or the topup gas, takes the cylinder volume, a start pressure and an end pressure seeded from the cylinder preset's working pressure, and prices the pressure filled at that gas's configured rate. The amount is shown as text and saved as a fixed value; a gas without a price is charged at 0. The fill is stored as a single itemised gas line carrying its role and start pressure, so it can be reopened with its values. The informational custom mix is retired.

Refs submersion-app#2302
An untouched gas fill keeps the amount and gas name it was billed with when only its description changes, pressures reopen with two decimals, a cubic-foot preset bills its exact water volume, switching a gas fill to a free amount starts from its cost, and an empty pressure gets its own message.

Refs submersion-app#2302
A label generated before the diver switched units is still regenerated when the fill changes, and switching a gas fill with a generated label to a free amount carries that label over.

Refs submersion-app#2302

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Four moderate issues remain in pricing validation, free-amount initialization, decimal parsing, and cubic-foot preset preservation.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds gas-fill and free-amount billing lines to the Trimix blender, including pricing, persistence, editing, localization, and tests.

Changes:

  • Adds unit-aware manual gas-fill pricing and validation.
  • Adds gas-line persistence, presets, and dedicated editing UI.
  • Retires legacy custom-mix metadata and updates translations/tests.
File Summary
test/​features/​gas_calculators/​domain/​blend_billing_test.dart Pricing and validation tests
test/​features/​gas_calculators/​blender_invoice_test.dart Widget, persistence, and editing tests
lib/​l10n/​arb/​app_zh.arb Chinese localization strings
lib/​l10n/​arb/​app_pt.arb Portuguese localization strings
lib/​l10n/​arb/​app_nl.arb Dutch localization strings
lib/​l10n/​arb/​app_localizations.dart Localization interface updates
lib/​l10n/​arb/​app_localizations_zh.dart Generated Chinese localization
lib/​l10n/​arb/​app_localizations_pt.dart Generated Portuguese localization
lib/​l10n/​arb/​app_localizations_nl.dart Generated Dutch localization
lib/​l10n/​arb/​app_localizations_it.dart Generated Italian localization
lib/​l10n/​arb/​app_localizations_hu.dart Generated Hungarian localization
lib/​l10n/​arb/​app_localizations_he.dart Generated Hebrew localization
lib/​l10n/​arb/​app_localizations_fr.dart Generated French localization
lib/​l10n/​arb/​app_localizations_es.dart Generated Spanish localization
lib/​l10n/​arb/​app_localizations_en.dart Generated English localization
lib/​l10n/​arb/​app_localizations_de.dart Generated German localization
lib/​l10n/​arb/​app_localizations_ar.dart Generated Arabic localization
lib/​l10n/​arb/​app_it.arb Italian localization strings
lib/​l10n/​arb/​app_hu.arb Hungarian localization strings
lib/​l10n/​arb/​app_he.arb Hebrew localization strings
lib/​l10n/​arb/​app_fr.arb French localization strings
lib/​l10n/​arb/​app_es.arb Spanish localization strings
lib/​l10n/​arb/​app_en.arb English localization strings
lib/​l10n/​arb/​app_de.arb German localization strings
lib/​l10n/​arb/​app_ar.arb Arabic localization strings
lib/​features/​gas_calculators/​presentation/​widgets/​blender/​blender_line_edit_sheet.dart Gas-fill and free-amount editor
lib/​features/​gas_calculators/​presentation/​widgets/​blender/​blender_invoice_card.dart Invoice integration
lib/​features/​gas_calculators/​presentation/​pages/​blender_invoice_archive_detail_page.dart Archived invoice display updates
lib/​features/​gas_calculators/​domain/​blending/​blend_billing.dart Manual gas-fill pricing
lib/​features/​gas_calculators/​domain/​blending/​billed_fill.dart Persisted gas-line metadata

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/features/gas_calculators/domain/blending/blend_billing.dart
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build artifacts for this PR · commit 84f7c99

Platform Download
Android (APK) android-apk
macOS macos-build
Windows windows-build
Linux linux-build

Artifacts expire in 7 days. Downloading requires being signed in to GitHub. macOS needs two extractions: unzip the downloaded artifact, then unzip the submersion-macos.zip inside it to get a runnable submersion.app. The build is ad-hoc signed — right-click → Open on first launch.

Updated automatically on each push.

@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.58703% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ation/widgets/blender/blender_line_edit_sheet.dart 96.29% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

@alpheios-one

Copy link
Copy Markdown
Contributor Author

@ericgriffin This is ready for testing. All checks are green, and the only review point is fixed. The "How to Test" section in the description has the shortest path through the new line form. Let me know how you like it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

Trimix blender: Add line with a free amount or a calculated gas fill

3 participants