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

@ -83,9 +83,13 @@ void main() {
await tester.tap(find.byKey(const Key('detail.addLot')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('addLot.year')));
await tester.tap(find.byKey(const Key('addLot.year'))); // open the picker
await tester.pumpAndSettle();
await tester.tap(find.text('2023').last); // pick the year from the dropdown
await tester.tap(find.byKey(const Key('harvestPicker.yearToggle')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('harvestPicker.year.2023')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('harvestPicker.ok')));
await tester.pumpAndSettle();
await tester.tap(find.text('spoon')); // pick the unit from the scale
await tester.pumpAndSettle();
@ -222,9 +226,13 @@ void main() {
await tester.tap(find.text('Year 2020 · 1 packet')); // open the lot
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('addLot.year')));
await tester.tap(find.byKey(const Key('addLot.year'))); // open the picker
await tester.pumpAndSettle();
await tester.tap(find.text('2024').last);
await tester.tap(find.byKey(const Key('harvestPicker.yearToggle')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('harvestPicker.year.2024')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('harvestPicker.ok')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('addLot.save')));
await tester.pumpAndSettle();
@ -233,6 +241,44 @@ void main() {
await disposeTree(tester);
});
testWidgets('picking a harvest month shows month + year on the lot', (
tester,
) async {
final repo = newTestRepository(db);
final id = await repo.addQuickVariety(label: 'Maize');
await tester.pumpWidget(
wrapDetail(
repository: repo,
varietyId: id,
species: newTestSpeciesRepository(db),
),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('detail.addLot')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('addLot.year'))); // open the picker
await tester.pumpAndSettle();
// Pick year 2022
await tester.tap(find.byKey(const Key('harvestPicker.yearToggle')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('harvestPicker.year.2022')));
await tester.pumpAndSettle();
// then September (month 9).
await tester.tap(find.byKey(const Key('harvestPicker.month.9')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('harvestPicker.ok')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('addLot.save')));
await tester.pumpAndSettle();
expect(find.text('September 2022'), findsOneWidget);
await disposeTree(tester);
});
testWidgets('deleting a lot removes it', (tester) async {
final repo = newTestRepository(db);
final id = await repo.addQuickVariety(label: 'Maize');