quantityRuleForUnit function

QuantityDefaults quantityRuleForUnit(
  1. String? unit
)

Vorgabe je Einheit — was der Betrieb bei einem neuen Artikel bekommt und ändern darf.

Implementation

QuantityDefaults quantityRuleForUnit(String? unit) {
  final u = (unit ?? '').trim().toLowerCase();
  final stellen = _dezimalEinheiten[u];
  if (stellen == null) return const QuantityDefaults(rule: QuantityRule.piece, ask: false, decimals: 0);
  // g, ml, min: ganze Zahl, aber die Menge wird gefragt.
  if (stellen == 0) return const QuantityDefaults(rule: QuantityRule.piece, ask: true, decimals: 0);
  return QuantityDefaults(rule: QuantityRule.decimal, ask: true, decimals: stellen);
}