shiftTipLines function
Was vom Trinkgeld eines Mitarbeiters dasteht, auf dem Bon, im Kassenstand
und beim Abschluss gleich (Rulings R50/R51): „verdient“ (sofort + ueber
Lohn) immer, „über Lohn“, „schon genommen“, „selbst zurückgegeben“ (R62)
und „offen“ nur, wenn nicht 0. Davor „aus früheren Schichten“ (R64, nur
wenn nicht 0).
Ist alles 0, gibt es keine Zeile, und der Mitarbeiter entfaellt ganz. Ohne
openCents (Laufstand, ShiftTipTotals) zaehlt offen als 0. Gemeinsame
Faelle mit dem JS-Zwilling: shift-cases.json.
Implementation
List<ShiftTipLine> shiftTipLines(ShiftTipTotals tip) {
final verdient = tip.receivedImmediatelyCents + tip.retainedCents;
final rest = <(String, int)>[
('shift_receipt.tip_retained', tip.retainedCents),
('shift_receipt.tip_paid_out', tip.paidOutCents),
('shift_receipt.tip_refunded_by_employee', tip.refundedByEmployeeCents),
('shift_receipt.tip_open', tip is ShiftTip ? tip.openCents : 0),
].where((z) => z.$2 != 0).toList();
final vortrag = tip is ShiftTip ? tip.carriedOverCents : 0;
if (verdient == 0 && rest.isEmpty && vortrag == 0) return const [];
return [
for (final (key, cents) in [
if (vortrag != 0) ('shift_receipt.tip_carried_over', vortrag),
('shift_receipt.tip_earned', verdient),
...rest,
])
ShiftTipLine(key: key, text: labelText(key), cents: cents),
];
}