결재 및 마스터 모듈을 v4 API 계약에 맞게 조정
This commit is contained in:
@@ -26,7 +26,7 @@ class ReportingRepositoryRemote implements ReportingRepository {
|
||||
) async {
|
||||
final response = await _api.get<Uint8List>(
|
||||
_transactionsPath,
|
||||
query: _buildQuery(request),
|
||||
query: _buildTransactionQuery(request),
|
||||
options: Options(responseType: ResponseType.bytes),
|
||||
);
|
||||
return _mapResponse(response, format: request.format);
|
||||
@@ -38,16 +38,16 @@ class ReportingRepositoryRemote implements ReportingRepository {
|
||||
) async {
|
||||
final response = await _api.get<Uint8List>(
|
||||
_approvalsPath,
|
||||
query: _buildQuery(request),
|
||||
query: _buildApprovalQuery(request),
|
||||
options: Options(responseType: ResponseType.bytes),
|
||||
);
|
||||
return _mapResponse(response, format: request.format);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _buildQuery(ReportExportRequest request) {
|
||||
Map<String, dynamic> _buildTransactionQuery(ReportExportRequest request) {
|
||||
return {
|
||||
'from': request.from.toIso8601String(),
|
||||
'to': request.to.toIso8601String(),
|
||||
'date_from': _formatDateOnly(request.from),
|
||||
'date_to': _formatDateOnly(request.to),
|
||||
'format': request.format.apiValue,
|
||||
if (request.transactionStatusId != null)
|
||||
'transaction_status_id': request.transactionStatusId,
|
||||
@@ -58,6 +58,28 @@ class ReportingRepositoryRemote implements ReportingRepository {
|
||||
};
|
||||
}
|
||||
|
||||
Map<String, dynamic> _buildApprovalQuery(ReportExportRequest request) {
|
||||
return {
|
||||
'from': request.from.toIso8601String(),
|
||||
'to': request.to.toIso8601String(),
|
||||
'format': request.format.apiValue,
|
||||
if (request.approvalStatusId != null)
|
||||
'approval_status_id': request.approvalStatusId,
|
||||
if (request.requestedById != null)
|
||||
'requested_by_id': request.requestedById,
|
||||
};
|
||||
}
|
||||
|
||||
/// 백엔드 트랜잭션 보고서가 요구하는 `yyyy-MM-dd` 형식으로 변환한다.
|
||||
String _formatDateOnly(DateTime value) {
|
||||
final iso = value.toIso8601String();
|
||||
final separatorIndex = iso.indexOf('T');
|
||||
if (separatorIndex == -1) {
|
||||
return iso;
|
||||
}
|
||||
return iso.substring(0, separatorIndex);
|
||||
}
|
||||
|
||||
ReportDownloadResult _mapResponse(
|
||||
Response<Uint8List> response, {
|
||||
required ReportExportFormat format,
|
||||
|
||||
Reference in New Issue
Block a user