결재 API 계약 보완 및 테스트 정리
This commit is contained in:
@@ -27,17 +27,18 @@ class StockTransactionCreateInput {
|
||||
final StockTransactionApprovalInput? approval;
|
||||
|
||||
Map<String, dynamic> toPayload() {
|
||||
final sanitizedNote = note?.trim();
|
||||
return {
|
||||
if (transactionNo != null && transactionNo!.trim().isNotEmpty)
|
||||
'transaction_no': transactionNo,
|
||||
'transaction_type_id': transactionTypeId,
|
||||
'transaction_status_id': transactionStatusId,
|
||||
'warehouse_id': warehouseId,
|
||||
'transaction_date': transactionDate.toIso8601String(),
|
||||
'transaction_date': _formatNaiveDate(transactionDate),
|
||||
'created_by_id': createdById,
|
||||
if (note != null && note!.trim().isNotEmpty) 'note': note,
|
||||
'note': sanitizedNote,
|
||||
if (expectedReturnDate != null)
|
||||
'expected_return_date': expectedReturnDate!.toIso8601String(),
|
||||
'expected_return_date': _formatNaiveDate(expectedReturnDate!),
|
||||
if (lines.isNotEmpty)
|
||||
'lines': lines.map((line) => line.toJson()).toList(growable: false),
|
||||
if (customers.isNotEmpty)
|
||||
@@ -62,11 +63,13 @@ class StockTransactionUpdateInput {
|
||||
final DateTime? expectedReturnDate;
|
||||
|
||||
Map<String, dynamic> toPayload() {
|
||||
final sanitizedNote = note?.trim();
|
||||
return {
|
||||
'transaction_status_id': transactionStatusId,
|
||||
if (note != null && note!.trim().isNotEmpty) 'note': note,
|
||||
if (expectedReturnDate != null)
|
||||
'expected_return_date': expectedReturnDate!.toIso8601String(),
|
||||
'note': sanitizedNote,
|
||||
'expected_return_date': expectedReturnDate == null
|
||||
? null
|
||||
: _formatNaiveDate(expectedReturnDate!),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -88,12 +91,13 @@ class TransactionLineCreateInput {
|
||||
final String? note;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final sanitizedNote = note?.trim();
|
||||
return {
|
||||
'line_no': lineNo,
|
||||
'product_id': productId,
|
||||
'quantity': quantity,
|
||||
'unit_price': unitPrice,
|
||||
if (note != null && note!.trim().isNotEmpty) 'note': note,
|
||||
'note': sanitizedNote,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -115,12 +119,13 @@ class TransactionLineUpdateInput {
|
||||
final String? note;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final sanitizedNote = note?.trim();
|
||||
return {
|
||||
'id': id,
|
||||
if (lineNo != null) 'line_no': lineNo,
|
||||
if (quantity != null) 'quantity': quantity,
|
||||
if (unitPrice != null) 'unit_price': unitPrice,
|
||||
if (note != null && note!.trim().isNotEmpty) 'note': note,
|
||||
if (note != null) 'note': sanitizedNote,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -133,10 +138,8 @@ class TransactionCustomerCreateInput {
|
||||
final String? note;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'customer_id': customerId,
|
||||
if (note != null && note!.trim().isNotEmpty) 'note': note,
|
||||
};
|
||||
final sanitizedNote = note?.trim();
|
||||
return {'customer_id': customerId, 'note': sanitizedNote};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,10 +151,8 @@ class TransactionCustomerUpdateInput {
|
||||
final String? note;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
if (note != null && note!.trim().isNotEmpty) 'note': note,
|
||||
};
|
||||
final sanitizedNote = note?.trim();
|
||||
return {'id': id, 'note': sanitizedNote};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,12 +206,7 @@ class StockTransactionListFilter {
|
||||
|
||||
/// 백엔드가 요구하는 `yyyy-MM-dd`(NaiveDate) 형식으로 변환한다.
|
||||
String _formatDate(DateTime value) {
|
||||
final iso = value.toIso8601String();
|
||||
final separatorIndex = iso.indexOf('T');
|
||||
if (separatorIndex == -1) {
|
||||
return iso;
|
||||
}
|
||||
return iso.substring(0, separatorIndex);
|
||||
return _formatNaiveDate(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +229,14 @@ class StockTransactionApprovalInput {
|
||||
'approval_no': approvalNo,
|
||||
if (approvalStatusId != null) 'approval_status_id': approvalStatusId,
|
||||
'requested_by_id': requestedById,
|
||||
if (note != null && note!.trim().isNotEmpty) 'note': note,
|
||||
'note': note?.trim(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
String _formatNaiveDate(DateTime value) {
|
||||
final year = value.year.toString().padLeft(4, '0');
|
||||
final month = value.month.toString().padLeft(2, '0');
|
||||
final day = value.day.toString().padLeft(2, '0');
|
||||
return '$year-$month-$day';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user