Skip to content

Study Journal 14-11-2023

Published: at 12:00 AM

Where I’m at

Portal - Development

Onward - Finishing up the Stocktake Form - Initialisation, Completion and Submission

Status update - update in bold (14 / 11 / 2023)

  1. Initialisation - nearly complete - done
  2. Completion - about halfway - underway
  3. Submission - not much progress — have psuedocode for submission logic

Tasks for completion for today:

Onto Stocktake Management Proper - Figuring out Stock Item, and Stock Count state management.

General Flow of State Management for Stock Item and Stock Counts

Models

ComponentItemStock ItemStock Count
Object-class StockItem {
String stockItemId; required
String productId; // This is really a concrete SKU, not a relational ID
String name; required
String description; required
bool isSelected = false;
class StockCount {
int quantity; required // Matches to the “newQuantity” in the Adjustment model
int lastCount; // Matches to the “oldQuantity” in the Adjustment model
bool hasChanged = false;
Methods-- To = JSON
- From = fromFirestore factory method
- To = JSON
- From = JSON

State

ComponentStock Item StateCount State
Objectclass StockItemState {
final List stockItems;
final bool isLoading;
final String? error;
class CountState {
final int quantity;
final int lastCount;
final bool hasChanged;
Methods- copyWith method- copyWith method

Notifiers

ComponentStock Item NotifierCounter Notifier
Objectclass StockItemNotifier extends StateNotifier {
final StockRepository stockRepository;
StockItemNotifier(this.stockRepository) : super(StockItemState());
class CounterNotifier extends StateNotifier {
CounterNotifier(CountState initialState) : super(initialState);
Methods- fetchStockItems()
- addStockItem(StockItem item)
- updateStockItem(StockItem item)
- deleteStockItem(StockItem item)
// TODO - Remove interface and refactor
- incrementCount()
- decrementCount()
- setCount(int newCount)

Repository

Methods
- fetchStockItems()
- addStockItem(StockItem item)
// TODO - Remove interface and refactor
- fetchStockCounts() // TODO - Complete
- updateStockCount(StockCount count) // TODO - Complete

Providers

Not yet completed

final counterProvider =
StateNotifierProvider.family<CounterNotifier, CountState, int>(
(ref, initialCount) => CounterNotifier(CountState(
quantity: initialCount,
hasChanged: false,

Consumers - UI

Not yet completed

class Counter extends ConsumerWidget {
  final int initialCount;
  const Counter({
    super.key,
    required this.initialCount,
  });
  // Much more to do with the widget build

Mutation Matrix - Mapping the flow of change of the data / UI

Key:

MutationCarouselStocktake ListStock ItemStock CountDots Decorator / Indicator
InitialisationdisplayLocationName
displaySublocation(init)
getPageNumber(init)
populateList(init)fetchStockItems(init)
mapStockItems(init)
cacheStockItems
displayStockItems(init)
fetchStockCounts(init)
mapStockCounts(init)
cacheStockCounts
displayStockCounts(init)
buildDot(init)
onPageChangegetPageNumber(new)
updateSublocation(new)
displaySublocation(new)
populateList(new)cache.fetchStockItems(new)
displayStockItems(new)
cache.fetchStockCounts(new)
displayStockCounts(new)
buildDot(new)
onCountChangeNo actionNo actionNo actionupdateStockCount()
updateStockCounts(change)
displayStockCounts(change)
No action
Consider supporting this blog