From 9b8c92605c0976a4ebb60f7b1cc23f0a254f3b2d Mon Sep 17 00:00:00 2001 From: shaulascr Date: Fri, 29 Aug 2025 16:27:02 +0700 Subject: [PATCH] fix hardcode detail sells --- .../mystore/sells/DetailSellsActivity.kt | 6 ++-- .../ui/profile/mystore/sells/SellsAdapter.kt | 28 +++++++++++++++++-- .../sells/payment/DetailPaymentActivity.kt | 3 +- .../sells/shipment/DetailShipmentActivity.kt | 3 +- .../main/res/layout/item_order_history.xml | 11 ++++---- 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/DetailSellsActivity.kt b/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/DetailSellsActivity.kt index 1a6cf1f..98e090f 100644 --- a/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/DetailSellsActivity.kt +++ b/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/DetailSellsActivity.kt @@ -2,7 +2,6 @@ package com.alya.ecommerce_serang.ui.profile.mystore.sells import android.os.Bundle import android.util.Log -import android.widget.Toast import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.LinearLayoutManager @@ -12,7 +11,6 @@ import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig import com.alya.ecommerce_serang.data.repository.AddressRepository import com.alya.ecommerce_serang.data.repository.SellsRepository import com.alya.ecommerce_serang.databinding.ActivityDetailSellsBinding -import com.alya.ecommerce_serang.ui.profile.mystore.sells.shipment.DetailShipmentActivity import com.alya.ecommerce_serang.utils.BaseViewModelFactory import com.alya.ecommerce_serang.utils.SessionManager import com.alya.ecommerce_serang.utils.viewmodel.AddressViewModel @@ -22,7 +20,6 @@ import java.text.SimpleDateFormat import java.util.Calendar import java.util.Locale import java.util.TimeZone -import kotlin.getValue class DetailSellsActivity : AppCompatActivity() { private lateinit var binding: ActivityDetailSellsBinding @@ -100,8 +97,9 @@ class DetailSellsActivity : AppCompatActivity() { tvOrderCustomer.text = sell.username tvOrderDate.text = formatDate(sell.updatedAt.toString()) tvOrderTotalProduct.text = "(${sell.orderItems?.size ?: 0} Barang)" - tvOrderSubtotal.text = formatPrice(sell.totalAmount.toString()) tvOrderShipPrice.text = formatPrice(sell.shipmentPrice.toString()) + val totalPrice = (sell.totalAmount?.toDouble()?.toInt() ?: 0) - (sell.shipmentPrice?.toDouble()?.toInt() ?: 0) + tvOrderSubtotal.text = formatPrice(totalPrice.toString()) tvOrderPrice.text = formatPrice(sell.totalAmount.toString()) tvOrderRecipient.text = sell.recipient ?: "-" tvOrderRecipientNum.text = sell.receiptNum?.toString() ?: "-" diff --git a/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/SellsAdapter.kt b/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/SellsAdapter.kt index 6d4908e..9ca78fb 100644 --- a/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/SellsAdapter.kt +++ b/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/SellsAdapter.kt @@ -186,7 +186,9 @@ class SellsAdapter( .into(ivSellsProduct) tvSellsQty.text = "${order.orderItems?.size} produk" - tvSellsPrice.text = order.totalAmount?.let { formatPrice(it.toDouble().toInt()) } + val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0) + tvSellsPrice.text =formatPrice(totalPrice).toString() + Log.d("SellsAdapter", "Cek price:$totalPrice" ) } "paid" -> { layoutOrders.visibility = View.GONE @@ -208,7 +210,7 @@ class SellsAdapter( tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 2) val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0) tvSellsPrice.text =formatPrice(totalPrice).toString() - + tvSellsQty.text = "${order.orderItems?.size} produk" } "processed" -> { layoutOrders.visibility = View.GONE @@ -237,6 +239,10 @@ class SellsAdapter( tvSellsLocation.text = order.subdistrict tvSellsCustomer.text = order.username tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 2) + tvSellsQty.text = "${order.orderItems?.size} produk" + val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0) + tvSellsPrice.text =formatPrice(totalPrice).toString() + } "shipped" -> { layoutOrders.visibility = View.GONE @@ -248,7 +254,11 @@ class SellsAdapter( tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 0) tvSellsDue.background = itemView.context.getDrawable(R.drawable.bg_product_inactive) + tvSellsQty.text = "${order.orderItems?.size} produk" btnConfirmPayment.visibility = View.GONE + + val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0) + tvSellsPrice.text =formatPrice(totalPrice).toString() } "delivered" -> { layoutOrders.visibility = View.GONE @@ -259,8 +269,13 @@ class SellsAdapter( tvSellsDueDesc.text = "Dikirimkan pada" tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 0) + tvSellsQty.text = "${order.orderItems?.size} produk" + tvSellsDue.background = itemView.context.getDrawable(R.drawable.bg_product_inactive) btnConfirmPayment.visibility = View.GONE + + val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0) + tvSellsPrice.text =formatPrice(totalPrice).toString() } "completed" -> { layoutOrders.visibility = View.GONE @@ -271,8 +286,13 @@ class SellsAdapter( tvSellsDueDesc.text = "Selesai pada" tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 0) + tvSellsQty.text = "${order.orderItems?.size} produk" + tvSellsDue.background = itemView.context.getDrawable(R.drawable.bg_product_inactive) btnConfirmPayment.visibility = View.GONE + + val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0) + tvSellsPrice.text =formatPrice(totalPrice).toString() } "canceled" -> { layoutOrders.visibility = View.GONE @@ -283,6 +303,10 @@ class SellsAdapter( tvSellsDueDesc.text = "Dibatalkan pada" tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 0) + tvSellsQty.text = "${order.orderItems?.size} produk" + val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0) + tvSellsPrice.text =formatPrice(totalPrice).toString() + tvSellsDue.background = itemView.context.getDrawable(R.drawable.bg_product_inactive) btnConfirmPayment.visibility = View.GONE } diff --git a/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/payment/DetailPaymentActivity.kt b/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/payment/DetailPaymentActivity.kt index 94488bd..18576c8 100644 --- a/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/payment/DetailPaymentActivity.kt +++ b/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/payment/DetailPaymentActivity.kt @@ -145,7 +145,8 @@ class DetailPaymentActivity : AppCompatActivity() { tvOrderCustomer.text = sell.username tvOrderDate.text = formatDate(sell.updatedAt.toString()) tvOrderTotalProduct.text = "(${sell.orderItems?.size ?: 0} Barang)" - tvOrderSubtotal.text = formatPrice(sell.totalAmount.toString()) + val totalPrice = (sell.totalAmount?.toDouble()?.toInt() ?: 0) - (sell.shipmentPrice?.toDouble()?.toInt() ?: 0) + tvOrderSubtotal.text = formatPrice(totalPrice.toString()) tvOrderShipPrice.text = formatPrice(sell.shipmentPrice.toString()) tvOrderPrice.text = formatPrice(sell.totalAmount.toString()) tvOrderDue.text = formatDueDate(sell.updatedAt.toString(), 2) diff --git a/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/shipment/DetailShipmentActivity.kt b/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/shipment/DetailShipmentActivity.kt index d80b5b8..8c3dc0d 100644 --- a/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/shipment/DetailShipmentActivity.kt +++ b/app/src/main/java/com/alya/ecommerce_serang/ui/profile/mystore/sells/shipment/DetailShipmentActivity.kt @@ -101,7 +101,8 @@ class DetailShipmentActivity : AppCompatActivity() { tvOrderCustomer.text = sell.username tvOrderDate.text = formatDate(sell.updatedAt.toString()) tvOrderTotalProduct.text = "(${sell.orderItems?.size ?: 0} Barang)" - tvOrderSubtotal.text = formatPrice(sell.totalAmount.toString()) + val totalPrice = (sell.totalAmount?.toDouble()?.toInt() ?: 0) - (sell.shipmentPrice?.toDouble()?.toInt() ?: 0) + tvOrderSubtotal.text = formatPrice(totalPrice.toString()) tvOrderShipPrice.text = formatPrice(sell.shipmentPrice.toString()) tvOrderPrice.text = formatPrice(sell.totalAmount.toString()) tvOrderDue.text = formatDueDate(sell.updatedAt.toString(), 2) diff --git a/app/src/main/res/layout/item_order_history.xml b/app/src/main/res/layout/item_order_history.xml index 793fcb6..4aa7854 100644 --- a/app/src/main/res/layout/item_order_history.xml +++ b/app/src/main/res/layout/item_order_history.xml @@ -133,35 +133,36 @@