fixed purchase order for android on new backend

This commit is contained in:
Alex
2026-04-07 17:31:43 -06:00
parent ce5adccdfe
commit 31df67ef33
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.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() : ""));
String status = po.getStatus() != null ? po.getStatus() : "";
binding.tvPOStatus.setText(status);
switch (status) {
case "Completed":
switch (status.toUpperCase()) {
case "RECEIVED":
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
break;
case "Pending":
case "PLACED":
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#2196F3"));
break;
case "PENDING":
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#FF9800"));
break;
case "Cancelled":
case "CANCELLED":
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#F44336"));
break;
default:

View File

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

View File

@@ -173,7 +173,7 @@ public class ProductFragment extends Fragment implements ProductAdapter.OnProduc
Bundle args = new Bundle();
if (position != -1) {
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);
}

View File

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

View File

@@ -70,6 +70,22 @@
android:textStyle="bold"
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
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -53,6 +53,17 @@
android:textColor="#888888"
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
android:layout_width="match_parent"
android:layout_height="wrap_content"