23 lines
741 B
Dart
23 lines
741 B
Dart
import 'dart:math';
|
|
|
|
/// Mengelola nomor faktur: 6 digit heksadesimal acak (contoh: 3F9A2C).
|
|
///
|
|
/// Nomor dibuat sekali per struk sebelum item dimasukkan, lalu dipakai ulang
|
|
/// untuk preview dan lampiran invoice sampai struk di-reset.
|
|
class InvoiceNumberService {
|
|
static const int _length = 6;
|
|
static final Random _random = Random.secure();
|
|
|
|
/// Bangun nomor faktur baru tanpa menyentuh state apa pun.
|
|
static String generate() {
|
|
final buffer = StringBuffer();
|
|
for (var i = 0; i < _length; i++) {
|
|
buffer.write(_random.nextInt(16).toRadixString(16).toUpperCase());
|
|
}
|
|
return buffer.toString();
|
|
}
|
|
|
|
/// Bangun nomor faktur baru (6 digit hex acak).
|
|
static String nextNumber({DateTime? date}) => generate();
|
|
}
|