feat: inventory

This commit is contained in:
efrilm
2025-08-17 23:54:28 +07:00
parent 577adb7964
commit d22ffdd6d0
20 changed files with 5118 additions and 506 deletions
@@ -98,4 +98,32 @@ class AnalyticRemoteDataProvider {
return DC.error(AnalyticFailure.serverError(e));
}
}
Future<DC<AnalyticFailure, InventoryAnalyticDto>> fetchInventory({
required String outletId,
required DateTime dateFrom,
required DateTime dateTo,
}) async {
try {
final response = await _apiClient.get(
'${ApiPath.inventoryReportDetail}/$outletId',
params: {
'date_from': dateFrom.toServerDate,
'date_to': dateTo.toServerDate,
},
headers: getAuthorizationHeader(),
);
if (response.data['data'] == null) {
return DC.error(AnalyticFailure.empty());
}
final dto = InventoryAnalyticDto.fromJson(response.data['data']);
return DC.data(dto);
} on ApiFailure catch (e, s) {
log('fetchInventoryError', name: _logName, error: e, stackTrace: s);
return DC.error(AnalyticFailure.serverError(e));
}
}
}