fixed purchase order for android on new backend

This commit is contained in:
Alex
2026-04-07 17:31:43 -06:00
parent 5a3229eb19
commit 538b4440d8
6 changed files with 62 additions and 13 deletions

View File

@@ -46,19 +46,23 @@ public class PurchaseOrderAdapter extends RecyclerView.Adapter<PurchaseOrderAdap
binding.tvPOId.setText("PO #" + (po.getPurchaseOrderId() != null ? po.getPurchaseOrderId() : "")); binding.tvPOId.setText("PO #" + (po.getPurchaseOrderId() != null ? po.getPurchaseOrderId() : ""));
binding.tvPOSupplier.setText("Supplier: " + (po.getSupplierName() != null ? po.getSupplierName() : "")); binding.tvPOSupplier.setText("Supplier: " + (po.getSupplierName() != null ? po.getSupplierName() : ""));
binding.tvPOStore.setText("Store: " + (po.getStoreName() != null ? po.getStoreName() : ""));
binding.tvPODate.setText("Date: " + (po.getOrderDate() != null ? po.getOrderDate() : "")); binding.tvPODate.setText("Date: " + (po.getOrderDate() != null ? po.getOrderDate() : ""));
String status = po.getStatus() != null ? po.getStatus() : ""; String status = po.getStatus() != null ? po.getStatus() : "";
binding.tvPOStatus.setText(status); binding.tvPOStatus.setText(status);
switch (status) { switch (status.toUpperCase()) {
case "Completed": case "RECEIVED":
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#4CAF50")); binding.tvPOStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
break; break;
case "Pending": case "PLACED":
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#2196F3"));
break;
case "PENDING":
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#FF9800")); binding.tvPOStatus.setBackgroundColor(Color.parseColor("#FF9800"));
break; break;
case "Cancelled": case "CANCELLED":
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#F44336")); binding.tvPOStatus.setBackgroundColor(Color.parseColor("#F44336"));
break; break;
default: default:

View File

@@ -4,6 +4,8 @@ public class PurchaseOrderDTO {
private Long purchaseOrderId; private Long purchaseOrderId;
private Long supId; private Long supId;
private String supplierName; private String supplierName;
private Long storeId;
private String storeName;
private String orderDate; private String orderDate;
private String status; private String status;
private String createdAt; private String createdAt;
@@ -21,6 +23,14 @@ public class PurchaseOrderDTO {
return supplierName; return supplierName;
} }
public Long getStoreId() {
return storeId;
}
public String getStoreName() {
return storeName;
}
public String getOrderDate() { public String getOrderDate() {
return orderDate; return orderDate;
} }

View File

@@ -173,7 +173,7 @@ public class ProductFragment extends Fragment implements ProductAdapter.OnProduc
Bundle args = new Bundle(); Bundle args = new Bundle();
if (position != -1) { if (position != -1) {
ProductDTO product = productList.get(position); ProductDTO product = productList.get(position);
args.putLong("productId", product.getProdId()); args.putLong("prodId", product.getProdId());
} }
NavHostFragment.findNavController(this).navigate(R.id.nav_product_detail, args); NavHostFragment.findNavController(this).navigate(R.id.nav_product_detail, args);
} }

View File

@@ -73,19 +73,27 @@ public class PurchaseOrderDetailFragment extends Fragment {
PurchaseOrderDTO po = resource.data; PurchaseOrderDTO po = resource.data;
binding.tvPODetailId.setText("PO #" + po.getPurchaseOrderId()); binding.tvPODetailId.setText("PO #" + po.getPurchaseOrderId());
binding.tvPODetailSupplier.setText(po.getSupplierName()); binding.tvPODetailSupplier.setText(po.getSupplierName());
binding.tvPODetailStore.setText(po.getStoreName() != null ? po.getStoreName() : "N/A");
binding.tvPODetailDate.setText(po.getOrderDate()); binding.tvPODetailDate.setText(po.getOrderDate());
String status = po.getStatus() != null ? po.getStatus() : ""; String status = po.getStatus() != null ? po.getStatus() : "";
binding.tvPODetailStatus.setText(status); binding.tvPODetailStatus.setText(status);
switch (status) { switch (status.toUpperCase()) {
case "Completed": case "RECEIVED":
binding.tvPODetailStatus.setTextColor(Color.parseColor("#4CAF50")); break; binding.tvPODetailStatus.setTextColor(Color.parseColor("#4CAF50"));
case "Pending": break;
binding.tvPODetailStatus.setTextColor(Color.parseColor("#FF9800")); break; case "PLACED":
case "Cancelled": binding.tvPODetailStatus.setTextColor(Color.parseColor("#2196F3"));
binding.tvPODetailStatus.setTextColor(Color.parseColor("#F44336")); break; break;
case "PENDING":
binding.tvPODetailStatus.setTextColor(Color.parseColor("#FF9800"));
break;
case "CANCELLED":
binding.tvPODetailStatus.setTextColor(Color.parseColor("#F44336"));
break;
default: default:
binding.tvPODetailStatus.setTextColor(Color.parseColor("#9E9E9E")); break; binding.tvPODetailStatus.setTextColor(Color.parseColor("#9E9E9E"));
break;
} }
} else if (resource.status == Resource.Status.ERROR) { } else if (resource.status == Resource.Status.ERROR) {
Toast.makeText(getContext(), "Failed to load order: " + resource.message, Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Failed to load order: " + resource.message, Toast.LENGTH_SHORT).show();

View File

@@ -70,6 +70,22 @@
android:textStyle="bold" android:textStyle="bold"
android:layout_marginBottom="16dp"/> android:layout_marginBottom="16dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Store"
android:textColor="@color/text_light"
android:textSize="12sp"/>
<TextView
android:id="@+id/tvPODetailStore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_dark"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginBottom="16dp"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@@ -53,6 +53,17 @@
android:textColor="#888888" android:textColor="#888888"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView
android:id="@+id/tvPOStore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:maxLines="1"
android:text="Store Name"
android:textColor="#888888"
android:textSize="14sp" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"