feat(inventory): informal quantity scale (number + unit) + seed/plant lots
Rework quantities the way seeds are actually described — a number of an informal
unit — and let a lot hold seeds or plants (plantel).
Quantity model (commons_core):
- Quantity is now { kind, count?, label } — "3 cobs", "2 packets", "a few".
Count is optional; uncountable vibes (a few, some, pinch) carry no number.
- QuantityKind reorganised into an ascending scale: vibes → containers
(teaspoon/spoon/cup/jar/sack) → seed & fruit forms → plant units, each tagged
countable/not. Stored by name; count reuses the existing numeric column.
Lot type (schema v2):
- Lots gain a `type` (seed | plant); germination stays meaningful for seeds.
schemaVersion 2 with a from1To2 migration (adds the column), drift_schema_v2
exported, migration test covers v1→v2.
UI:
- New QuantityPicker: a horizontal scale of large seed-glyph icons + a number
stepper (shown only for countable units), plus a seed/plant SegmentedButton.
Used in quick-add and add-lot. Lot lines render "3 cobs" / "a few".
- i18n: unit singular/plural (ES/EN, Weblate-friendly), lot-type labels.
Build: slang moved to its CLI (disabled in build_runner to avoid a multi-file
collision); CI runs `dart run slang` before build_runner. 38 tests green,
Linux migrates the existing v1 DB and runs.
This commit is contained in:
parent
48e9d15772
commit
3942975dba
26 changed files with 4220 additions and 315 deletions
|
|
@ -63,6 +63,7 @@ class GerminationEntry extends Equatable {
|
|||
class VarietyLot extends Equatable {
|
||||
const VarietyLot({
|
||||
required this.id,
|
||||
this.type = LotType.seed,
|
||||
this.harvestYear,
|
||||
this.quantity,
|
||||
this.storageLocation,
|
||||
|
|
@ -70,6 +71,7 @@ class VarietyLot extends Equatable {
|
|||
});
|
||||
|
||||
final String id;
|
||||
final LotType type;
|
||||
final int? harvestYear;
|
||||
final Quantity? quantity;
|
||||
final String? storageLocation;
|
||||
|
|
@ -82,6 +84,7 @@ class VarietyLot extends Equatable {
|
|||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
type,
|
||||
harvestYear,
|
||||
quantity,
|
||||
storageLocation,
|
||||
|
|
@ -216,6 +219,7 @@ class VarietyRepository {
|
|||
Future<String> addQuickVariety({
|
||||
required String label,
|
||||
String? category,
|
||||
LotType lotType = LotType.seed,
|
||||
Quantity? quantity,
|
||||
Uint8List? photoBytes,
|
||||
}) async {
|
||||
|
|
@ -246,8 +250,9 @@ class VarietyRepository {
|
|||
createdAt: created,
|
||||
updatedAt: updated,
|
||||
lastAuthor: nodeId,
|
||||
type: Value(lotType),
|
||||
quantityKind: Value(quantity.kind.name),
|
||||
quantityPrecise: Value(quantity.precise),
|
||||
quantityPrecise: Value(quantity.count?.toDouble()),
|
||||
quantityLabel: Value(quantity.label),
|
||||
),
|
||||
);
|
||||
|
|
@ -423,6 +428,7 @@ class VarietyRepository {
|
|||
/// Adds a lot (a held batch) to a variety. Returns the new lot id.
|
||||
Future<String> addLot({
|
||||
required String varietyId,
|
||||
LotType type = LotType.seed,
|
||||
int? harvestYear,
|
||||
Quantity? quantity,
|
||||
String? storageLocation,
|
||||
|
|
@ -438,9 +444,10 @@ class VarietyRepository {
|
|||
createdAt: created,
|
||||
updatedAt: updated,
|
||||
lastAuthor: nodeId,
|
||||
type: Value(type),
|
||||
harvestYear: Value(harvestYear),
|
||||
quantityKind: Value(quantity?.kind.name),
|
||||
quantityPrecise: Value(quantity?.precise),
|
||||
quantityPrecise: Value(quantity?.count?.toDouble()),
|
||||
quantityLabel: Value(quantity?.label),
|
||||
storageLocation: Value(storageLocation),
|
||||
),
|
||||
|
|
@ -496,13 +503,14 @@ class VarietyRepository {
|
|||
l.quantityLabel != null;
|
||||
return VarietyLot(
|
||||
id: l.id,
|
||||
type: l.type,
|
||||
harvestYear: l.harvestYear,
|
||||
storageLocation: l.storageLocation,
|
||||
germinationTests: germinationTests,
|
||||
quantity: hasQuantity
|
||||
? Quantity(
|
||||
kind: _parseKind(l.quantityKind),
|
||||
precise: l.quantityPrecise,
|
||||
count: l.quantityPrecise,
|
||||
label: l.quantityLabel,
|
||||
)
|
||||
: null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue