Update client models to handle numeric decimals from optimized API
Model type updates: - Change decimal cost fields from String to Double for better type safety - actualCost: String? → Double? (TaskCompletion, TaskCompletionCreateRequest) - estimatedCost: String? → Double? (CustomTask, TaskCreateRequest, TaskDetail) - purchasePrice: String? → Double? (Residence, ResidenceCreateRequest) TaskDetail model fixes: - Add missing residenceName, createdBy, createdByUsername fields - Add missing intervalDays field to match backend response - Remove actualCost and notes fields (not in backend TaskDetailSerializer) - Ensure 100% compatibility with Django API TaskDetailSerializer UI input/output conversions: - EditTaskScreen: Convert Double to String for display, String to Double for API - AddTaskDialog: Convert String input to Double for API requests - CompleteTaskDialog: Convert String input to Double for API requests - App.kt: Handle type conversions in navigation route parameters Display improvements: - TaskCard: Update preview data to use numeric literals (150.00 vs "150.00") - Cost display already handles Double correctly with string interpolation Benefits: - Type-safe numeric handling throughout the app - Smaller JSON payloads (numbers vs quoted strings) - Better performance with direct numeric deserialization - Aligns with REST API best practices - 100% backend compatibility verified Testing: - All models now match backend serializer field types exactly - Build successful with no errors - Ready for integration with optimized Django API 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -17,8 +17,8 @@ data class CustomTask (
|
||||
val status: TaskStatus? = null,
|
||||
@SerialName("due_date") val dueDate: String?,
|
||||
@SerialName("next_scheduled_date") val nextScheduledDate: String? = null,
|
||||
@SerialName("estimated_cost") val estimatedCost: String? = null,
|
||||
@SerialName("actual_cost") val actualCost: String? = null,
|
||||
@SerialName("estimated_cost") val estimatedCost: Double? = null,
|
||||
@SerialName("actual_cost") val actualCost: Double? = null,
|
||||
@SerialName("completion_count") val completionCount: Int? = null,
|
||||
val notes: String? = null,
|
||||
val archived: Boolean = false,
|
||||
@@ -34,7 +34,7 @@ data class CustomTask (
|
||||
data class LastCompletion(
|
||||
@SerialName("completion_date") val completionDate: String,
|
||||
@SerialName("completed_by") val completedBy: String?,
|
||||
@SerialName("actual_cost") val actualCost: String?,
|
||||
@SerialName("actual_cost") val actualCost: Double?,
|
||||
val rating: Int?
|
||||
)
|
||||
|
||||
@@ -49,7 +49,7 @@ data class TaskCreateRequest(
|
||||
val priority: Int,
|
||||
val status: Int? = null,
|
||||
@SerialName("due_date") val dueDate: String,
|
||||
@SerialName("estimated_cost") val estimatedCost: String? = null,
|
||||
@SerialName("estimated_cost") val estimatedCost: Double? = null,
|
||||
val archived: Boolean = false
|
||||
)
|
||||
|
||||
@@ -57,8 +57,9 @@ data class TaskCreateRequest(
|
||||
data class TaskDetail(
|
||||
val id: Int,
|
||||
val residence: Int,
|
||||
//@SerialName("created_by") val createdBy: Int,
|
||||
//@SerialName("created_by_username") val createdByUsername: String,
|
||||
@SerialName("residence_name") val residenceName: String? = null,
|
||||
@SerialName("created_by") val createdBy: Int? = null,
|
||||
@SerialName("created_by_username") val createdByUsername: String? = null,
|
||||
val title: String,
|
||||
val description: String?,
|
||||
val category: TaskCategory,
|
||||
@@ -66,9 +67,8 @@ data class TaskDetail(
|
||||
val frequency: TaskFrequency,
|
||||
val status: TaskStatus?,
|
||||
@SerialName("due_date") val dueDate: String?,
|
||||
@SerialName("estimated_cost") val estimatedCost: String? = null,
|
||||
@SerialName("actual_cost") val actualCost: String? = null,
|
||||
val notes: String? = null,
|
||||
@SerialName("interval_days") val intervalDays: Int? = null,
|
||||
@SerialName("estimated_cost") val estimatedCost: Double? = null,
|
||||
val archived: Boolean = false,
|
||||
@SerialName("created_at") val createdAt: String,
|
||||
@SerialName("updated_at") val updatedAt: String,
|
||||
|
||||
Reference in New Issue
Block a user