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:
@@ -323,7 +323,7 @@ fun App(
|
||||
statusId = task.status?.id,
|
||||
statusName = task.status?.name,
|
||||
dueDate = task.dueDate,
|
||||
estimatedCost = task.estimatedCost,
|
||||
estimatedCost = task.estimatedCost?.toString(),
|
||||
createdAt = task.createdAt,
|
||||
updatedAt = task.updatedAt
|
||||
)
|
||||
@@ -481,7 +481,7 @@ fun App(
|
||||
statusId = task.status?.id,
|
||||
statusName = task.status?.name,
|
||||
dueDate = task.dueDate,
|
||||
estimatedCost = task.estimatedCost,
|
||||
estimatedCost = task.estimatedCost?.toString(),
|
||||
createdAt = task.createdAt,
|
||||
updatedAt = task.updatedAt
|
||||
)
|
||||
@@ -509,9 +509,7 @@ fun App(
|
||||
TaskStatus(it, route.statusName ?: "", displayName = route.statusName ?: "")
|
||||
},
|
||||
dueDate = route.dueDate,
|
||||
estimatedCost = route.estimatedCost,
|
||||
actualCost = null,
|
||||
notes = null,
|
||||
estimatedCost = route.estimatedCost?.toDoubleOrNull(),
|
||||
createdAt = route.createdAt,
|
||||
updatedAt = route.updatedAt,
|
||||
nextScheduledDate = null,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -25,7 +25,7 @@ data class Residence(
|
||||
@SerialName("year_built") val yearBuilt: Int?,
|
||||
val description: String?,
|
||||
@SerialName("purchase_date") val purchaseDate: String?,
|
||||
@SerialName("purchase_price") val purchasePrice: String?,
|
||||
@SerialName("purchase_price") val purchasePrice: Double?,
|
||||
@SerialName("is_primary") val isPrimary: Boolean = false,
|
||||
@SerialName("created_at") val createdAt: String,
|
||||
@SerialName("updated_at") val updatedAt: String
|
||||
@@ -133,7 +133,7 @@ data class ResidenceWithTasks(
|
||||
@SerialName("year_built") val yearBuilt: Int?,
|
||||
val description: String?,
|
||||
@SerialName("purchase_date") val purchaseDate: String?,
|
||||
@SerialName("purchase_price") val purchasePrice: String?,
|
||||
@SerialName("purchase_price") val purchasePrice: Double?,
|
||||
@SerialName("is_primary") val isPrimary: Boolean,
|
||||
@SerialName("task_summary") val taskSummary: TaskSummary,
|
||||
val tasks: List<TaskDetail>,
|
||||
|
||||
@@ -15,7 +15,7 @@ data class TaskCompletion(
|
||||
@SerialName("completed_by_email") val completedByEmail: String?,
|
||||
@SerialName("company_name") val companyName: String?,
|
||||
@SerialName("completion_date") val completionDate: String,
|
||||
@SerialName("actual_cost") val actualCost: String?,
|
||||
@SerialName("actual_cost") val actualCost: Double?,
|
||||
val notes: String?,
|
||||
val rating: Int?,
|
||||
@SerialName("completed_by_display") val completedByDisplay: String?,
|
||||
@@ -43,7 +43,7 @@ data class TaskCompletionCreateRequest(
|
||||
@SerialName("completed_by_email") val completedByEmail: String? = null,
|
||||
@SerialName("company_name") val companyName: String? = null,
|
||||
@SerialName("completion_date") val completionDate: String,
|
||||
@SerialName("actual_cost") val actualCost: String? = null,
|
||||
@SerialName("actual_cost") val actualCost: Double? = null,
|
||||
val notes: String? = null,
|
||||
val rating: Int? = null
|
||||
)
|
||||
|
||||
@@ -342,7 +342,7 @@ fun AddTaskDialog(
|
||||
priority = priority.id,
|
||||
status = null,
|
||||
dueDate = dueDate,
|
||||
estimatedCost = estimatedCost.ifBlank { null }
|
||||
estimatedCost = estimatedCost.ifBlank { null }?.toDoubleOrNull()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ fun CompleteTaskDialog(
|
||||
contractor = selectedContractorId,
|
||||
completedByName = completedByName.ifBlank { null },
|
||||
completionDate = currentDate,
|
||||
actualCost = actualCost.ifBlank { null },
|
||||
actualCost = actualCost.ifBlank { null }?.toDoubleOrNull(),
|
||||
notes = notes.ifBlank { null },
|
||||
rating = rating
|
||||
),
|
||||
|
||||
@@ -601,9 +601,7 @@ fun TaskCardPreview() {
|
||||
),
|
||||
status = TaskStatus(id = 1, name = "pending", displayName = "Pending", description = ""),
|
||||
dueDate = "2024-12-15",
|
||||
estimatedCost = "150.00",
|
||||
actualCost = null,
|
||||
notes = null,
|
||||
estimatedCost = 150.00,
|
||||
createdAt = "2024-01-01T00:00:00Z",
|
||||
updatedAt = "2024-01-01T00:00:00Z",
|
||||
nextScheduledDate = "2024-12-15",
|
||||
|
||||
@@ -33,7 +33,7 @@ fun EditTaskScreen(
|
||||
var selectedPriority by remember { mutableStateOf<TaskPriority?>(task.priority) }
|
||||
var selectedStatus by remember { mutableStateOf<TaskStatus?>(task.status) }
|
||||
var dueDate by remember { mutableStateOf(task.dueDate ?: "") }
|
||||
var estimatedCost by remember { mutableStateOf(task.estimatedCost ?: "") }
|
||||
var estimatedCost by remember { mutableStateOf(task.estimatedCost?.toString() ?: "") }
|
||||
|
||||
var categoryExpanded by remember { mutableStateOf(false) }
|
||||
var frequencyExpanded by remember { mutableStateOf(false) }
|
||||
@@ -309,7 +309,7 @@ fun EditTaskScreen(
|
||||
priority = selectedPriority!!.id,
|
||||
status = selectedStatus!!.id,
|
||||
dueDate = dueDate,
|
||||
estimatedCost = estimatedCost.ifBlank { null },
|
||||
estimatedCost = estimatedCost.ifBlank { null }?.toDoubleOrNull(),
|
||||
archived = task.archived
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user