feat(inventory): month/year harvest date picker (schema v3)

Replace the free-text harvest year with a themed month/year picker:
a tappable field opens a green-styled dialog with month and year grids
(navigable, paginated years), month optional. Lots now read e.g.
"September 2021" or just "Year 2021".

- schema v3: add nullable Lot.harvest_month (1..12) + migration + tests
- repo/cubit propagate harvestMonth; localized month names (en/es) via slang
This commit is contained in:
vjrj 2026-07-08 12:09:38 +02:00
parent 9e5c82184b
commit 5d4053157f
17 changed files with 3799 additions and 57 deletions

View file

@ -11,19 +11,30 @@ void main() {
verifier = SchemaVerifier(GeneratedHelper());
});
test('freshly created database matches the exported schema v2', () async {
final schema = await verifier.schemaAt(2);
test('freshly created database matches the exported schema v3', () async {
final schema = await verifier.schemaAt(3);
final db = AppDatabase(schema.newConnection());
await verifier.migrateAndValidate(db, 2);
await verifier.migrateAndValidate(db, 3);
await db.close();
});
test(
'upgrades v1 → v2 (adds Lot.type) and matches the fresh schema',
'upgrades v1 → v3 (adds Lot.type, then harvestMonth) and matches the '
'fresh schema',
() async {
final connection = await verifier.startAt(1);
final db = AppDatabase(connection);
await verifier.migrateAndValidate(db, 2);
await verifier.migrateAndValidate(db, 3);
await db.close();
},
);
test(
'upgrades v2 → v3 (adds Lot.harvestMonth) and matches the fresh schema',
() async {
final connection = await verifier.startAt(2);
final db = AppDatabase(connection);
await verifier.migrateAndValidate(db, 3);
await db.close();
},
);

View file

@ -6,6 +6,7 @@ import 'package:drift/drift.dart';
import 'package:drift/internal/migrations.dart';
import 'schema_v1.dart' as v1;
import 'schema_v2.dart' as v2;
import 'schema_v3.dart' as v3;
class GeneratedHelper implements SchemaInstantiationHelper {
@override
@ -15,10 +16,12 @@ class GeneratedHelper implements SchemaInstantiationHelper {
return v1.DatabaseAtV1(db);
case 2:
return v2.DatabaseAtV2(db);
case 3:
return v3.DatabaseAtV3(db);
default:
throw MissingSchemaException(version, versions);
}
}
static const versions = const [1, 2];
static const versions = const [1, 2, 3];
}

File diff suppressed because it is too large Load diff