Reliability/PoC hardening: dedupe uploads by file_hash, surface editor sync failures instead of a false success SnackBar with a retry-without-re-OCR path, bound the OCR pipeline fetches with timeouts, share a single ApiClient/Dio instance app-wide, tune capture JPEG quality, and add an opt-in docker-compose.demo.yml for a production-mode run ahead of client demos. Translate all Flutter-side user-facing text (screens, validators, SnackBars, the printed delivery receipt, and shared API error messages) to Bahasa Indonesia. Also includes in-progress OCR parser/accuracy-tuning work from the same session: table column/unit normalization fixes, store/customer master data, accuracy history log, and test-image renaming/cleanup. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017eRAsLqN9Sg1b9YPz22Lxz
110 lines
3.5 KiB
Dart
110 lines
3.5 KiB
Dart
class DocumentModel {
|
|
final String id;
|
|
final String tanggal;
|
|
final String noPo;
|
|
final String noSo;
|
|
final String noDo;
|
|
final String kepadaYth;
|
|
final String orderUntuk;
|
|
final String alamat;
|
|
final String platTruk;
|
|
final String namaDriver;
|
|
final String namaPenerima;
|
|
final double? latitude;
|
|
final double? longitude;
|
|
final List<DocumentItem> items;
|
|
final DateTime createdAt;
|
|
|
|
DocumentModel({
|
|
required this.id,
|
|
required this.tanggal,
|
|
required this.noPo,
|
|
required this.noSo,
|
|
required this.noDo,
|
|
required this.kepadaYth,
|
|
required this.orderUntuk,
|
|
required this.alamat,
|
|
required this.platTruk,
|
|
required this.namaDriver,
|
|
required this.namaPenerima,
|
|
this.latitude,
|
|
this.longitude,
|
|
required this.items,
|
|
required this.createdAt,
|
|
});
|
|
|
|
factory DocumentModel.fromJson(Map<String, dynamic> json) {
|
|
var header = json['header'] ?? {};
|
|
var shipment = json['shipment'] ?? {};
|
|
var itemsList = json['items'] as List? ?? [];
|
|
|
|
return DocumentModel(
|
|
id: json['id'] ?? DateTime.now().millisecondsSinceEpoch.toString(),
|
|
tanggal: header['tanggal']?.toString() ?? '',
|
|
noPo: header['no_po']?.toString() ?? '',
|
|
noSo: header['no_so']?.toString() ?? '',
|
|
noDo: header['no_do']?.toString() ?? '',
|
|
kepadaYth: shipment['kepada_yth']?.toString() ?? '',
|
|
orderUntuk: shipment['order_untuk']?.toString() ?? '',
|
|
alamat: shipment['alamat']?.toString() ?? '',
|
|
platTruk: shipment['plat_truk']?.toString() ?? '',
|
|
namaDriver: json['nama_driver']?.toString() ?? shipment['nama_driver']?.toString() ?? '',
|
|
namaPenerima: json['nama_penerima']?.toString() ?? shipment['nama_penerima']?.toString() ?? '',
|
|
latitude: json['latitude'] != null ? double.tryParse(json['latitude'].toString()) : null,
|
|
longitude: json['longitude'] != null ? double.tryParse(json['longitude'].toString()) : null,
|
|
items: itemsList.map((e) => DocumentItem.fromJson(Map<String, dynamic>.from(e))).toList(),
|
|
createdAt: json['created_at'] != null
|
|
? DateTime.parse(json['created_at'].toString())
|
|
: (json['createdAt'] != null ? DateTime.parse(json['createdAt'].toString()) : DateTime.now()),
|
|
);
|
|
}
|
|
|
|
/// Body for `PUT /api/v1/documents/:id`. Shared by the editor's initial save and
|
|
/// the pending-queue's sync retry so both send an identical payload shape.
|
|
Map<String, dynamic> toPutPayload() {
|
|
return {
|
|
'tanggal': tanggal,
|
|
'noPo': noPo,
|
|
'noSo': noSo,
|
|
'noDo': noDo,
|
|
'kepadaYth': kepadaYth,
|
|
'orderUntuk': orderUntuk,
|
|
'alamat': alamat,
|
|
'platTruk': platTruk,
|
|
'namaDriver': namaDriver,
|
|
'namaPenerima': namaPenerima,
|
|
'latitude': latitude,
|
|
'longitude': longitude,
|
|
'items': items.map((e) => {
|
|
'nomor_sku': e.nomorSku,
|
|
'nama_barang': e.namaBarang,
|
|
'banyak': e.banyak,
|
|
'jumlah': e.jumlah,
|
|
}).toList(),
|
|
};
|
|
}
|
|
}
|
|
|
|
class DocumentItem {
|
|
final String nomorSku;
|
|
final String namaBarang;
|
|
final String banyak;
|
|
final String jumlah;
|
|
|
|
DocumentItem({
|
|
required this.nomorSku,
|
|
required this.namaBarang,
|
|
required this.banyak,
|
|
required this.jumlah,
|
|
});
|
|
|
|
factory DocumentItem.fromJson(Map<String, dynamic> json) {
|
|
return DocumentItem(
|
|
nomorSku: json['nomor_sku']?.toString() ?? '',
|
|
namaBarang: json['nama_barang']?.toString() ?? '',
|
|
banyak: json['banyak']?.toString() ?? '',
|
|
jumlah: json['jumlah']?.toString() ?? '',
|
|
);
|
|
}
|
|
}
|