shiftReceiptLayout function
ReceiptLayout
shiftReceiptLayout(
- ShiftSummaryReceipt receipt, {
- PosPaperSize paperSize = PosPaperSize.mm58,
Z-Bon bzw. X-Bon der Schicht. Titel nach kind: „Schichtabschluss“ oder
„Zwischenbericht“. Wirft (KasseneckValidationError, kind: request),
wenn die Bon-Daten keine Z- oder X-Bon-Daten sind. paperSize ist die
Breite des Bauplans (Vorgabe mm58); die Druckbreite waehlt der Druckweg.
Implementation
ReceiptLayout shiftReceiptLayout(ShiftSummaryReceipt receipt, {PosPaperSize paperSize = PosPaperSize.mm58}) {
zBonPruefen('shiftReceiptLayout', receipt);
final bon = receipt;
final zeilen = <LayoutLine>[];
_kopfblock(zeilen, bon, bon.kind == 'shift_close' ? 'shift_receipt.title_close' : 'shift_receipt.title_interim');
zeilen.add(_kopf(labelText('shift_receipt.shift'), labelText('shift_receipt.number', {'number': bon.number})));
final von = labelText('shift_receipt.by');
_wennText(zeilen, labelText('shift_receipt.opened'), _zeit(bon.openedAt));
_wennText(zeilen, von, bon.openedByName);
_wennText(zeilen, labelText('shift_receipt.closed'), _zeit(bon.closedAt));
_wennText(zeilen, von, bon.closedByName);
// Bargeld: Startgeld, Barumsatz, Bewegungen, Soll, Ist, Differenz.
zeilen.add(_regel());
final start = labelText(bon.openingFloatTakenOver ? 'shift_receipt.opening_float_taken_over' : 'shift_receipt.opening_float');
if (bon.openingFloatCents != null) {
zeilen.add(_betrag(start, bon.openingFloatCents!));
} else if (bon.openingFloatTakenOver) {
zeilen.add(_text(start));
}
zeilen.addAll(_stueckelungZeilen(bon.openingDenominations));
if (bon.cashSalesCents != null) zeilen.add(_betrag(labelText('shift_receipt.cash_sales'), bon.cashSalesCents!));
if (bon.cashCancellationsCents != null) {
zeilen.add(_betrag(labelText('shift_receipt.cash_cancellations'), bon.cashCancellationsCents!));
}
if (bon.movements.isNotEmpty) {
zeilen.add(_text(labelText('shift_receipt.movements'), bold: true));
for (final m in bon.movements) {
zeilen.add(_betrag('${labelText('shift_receipt.number', {'number': m.number})} ${_artText(m.type)}', m.amountCents));
final note = m.note;
if (note != null && note.isNotEmpty) zeilen.add(_text(' $note'));
}
}
if (bon.expectedCents != null) zeilen.add(_betrag(labelText('shift_receipt.expected'), bon.expectedCents!));
if (bon.countedCents != null) {
zeilen.add(_betrag(labelText('shift_receipt.counted'), bon.countedCents!));
zeilen.addAll(_stueckelungZeilen(bon.countedDenominations));
}
if (bon.differenceCents != null) zeilen.add(_betrag(labelText('shift_receipt.difference'), bon.differenceCents!));
final kommentar = bon.comment;
if (kommentar != null && kommentar.isNotEmpty) zeilen.add(_text('${labelText('shift_receipt.comment')}: $kommentar'));
zeilen.addAll(_nachZaehlungZeilen(bon));
// Zur Information: unbar, Zaehler.
zeilen.add(_regel());
if (bon.nonCashByMethod.isNotEmpty) {
zeilen.add(_text(labelText('shift_receipt.non_cash'), bold: true));
for (final u in bon.nonCashByMethod) {
zeilen.add(_betrag(_zahlartText(u.method), u.cents));
}
}
zeilen.add(_anzahl(labelText('shift_receipt.receipts'), bon.receiptCount));
zeilen.add(_anzahl(labelText('shift_receipt.cancellations'), bon.cancellationCount));
zeilen.add(_anzahl(labelText('shift_receipt.openings_without_sale'), bon.openingsWithoutSale));
// Trinkgeld je Mitarbeiter (shiftTipLines): verdient immer, ueber Lohn, schon genommen und offen
// nur ungleich 0; wer ueberall 0 hat, entfaellt, ohne Mitarbeiter auch die Ueberschrift.
final trinkgeld = [
for (final t in bon.tips)
if (shiftTipLines(t) case final z when z.isNotEmpty) (t, z),
];
if (trinkgeld.isNotEmpty) {
zeilen.add(_regel());
zeilen.add(_text(labelText('shift_receipt.tips'), bold: true));
for (final (t, z) in trinkgeld) {
zeilen.add(_text(t.name ?? t.registerUserId));
for (final zeile in z) {
zeilen.add(_betrag(' ${zeile.text}', zeile.cents));
}
}
}
return ReceiptLayout(lines: zeilen, paperSize: paperSize.value, ruleset: _regelwerk);
}