2026-05-16 09:04:18 +02:00
|
|
|
// Se un domani ci saranno nuovi tipi di documento, basterà aggiungerli qui
|
|
|
|
|
// e alla mappa nella DocumentSequenceSection dei documenti supportati
|
2026-05-19 11:17:28 +02:00
|
|
|
enum DocumentType {
|
|
|
|
|
ticket(name: 'ticket', label: 'Ticket', defaultPrefix: 'TCK'),
|
|
|
|
|
ticketsShipping(
|
|
|
|
|
name: 'tickets_shipping',
|
|
|
|
|
label: 'DDT (Documento di Trasporto)',
|
|
|
|
|
defaultPrefix: 'DDT',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final String name;
|
|
|
|
|
final String label;
|
|
|
|
|
final String defaultPrefix;
|
|
|
|
|
const DocumentType({
|
|
|
|
|
required this.name,
|
|
|
|
|
required this.label,
|
|
|
|
|
required this.defaultPrefix,
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-05-10 14:09:57 +02:00
|
|
|
|
|
|
|
|
class DocumentSequence {
|
|
|
|
|
final String docType;
|
|
|
|
|
final int nextValue;
|
|
|
|
|
final String prefix;
|
|
|
|
|
|
|
|
|
|
DocumentSequence({
|
|
|
|
|
required this.docType,
|
|
|
|
|
required this.nextValue,
|
|
|
|
|
required this.prefix,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
DocumentSequence copyWith({int? nextValue, String? prefix}) {
|
|
|
|
|
return DocumentSequence(
|
|
|
|
|
docType: docType,
|
|
|
|
|
nextValue: nextValue ?? this.nextValue,
|
|
|
|
|
prefix: prefix ?? this.prefix,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
factory DocumentSequence.fromMap(Map<String, dynamic> map) {
|
|
|
|
|
return DocumentSequence(
|
|
|
|
|
docType: map['doc_type'],
|
|
|
|
|
nextValue: map['next_value'],
|
|
|
|
|
prefix: map['prefix'] ?? '',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|