diff --git a/backend/internal/handler/inventory.go b/backend/internal/handler/inventory.go index 80ac350..daabd6f 100644 --- a/backend/internal/handler/inventory.go +++ b/backend/internal/handler/inventory.go @@ -36,7 +36,8 @@ type inventoryRow struct { Spec string `json:"spec"` Unit string `json:"unit"` WarehouseName string `json:"warehouse_name"` - UnitPrice *float64 `json:"unit_price"` + UnitPrice *float64 `json:"unit_price"` // 成本价(入库进价) + SalePrice *float64 `json:"sale_price"` // 单价(product 售价) ProductionDate *string `json:"production_date"` BatchNo string `json:"batch_no"` SupplierName string `json:"supplier_name"` @@ -131,7 +132,8 @@ func (h *InventoryHandler) List(c *gin.Context) { COALESCE(NULLIF(p.spec,''), NULLIF(sii.spec,''), inv.spec, '') AS spec, COALESCE(NULLIF(p.unit,''), inv.unit, '') AS unit, COALESCE(NULLIF(w.name,''), inv.warehouse_name, '') AS warehouse_name, - COALESCE(sii.unit_price, inv.unit_price) AS unit_price, + COALESCE(sii.unit_price, inv.unit_price, p.purchase_price) AS unit_price, + p.sale_price AS sale_price, COALESCE(DATE(sii.production_date), DATE(inv.production_date)) AS production_date, COALESCE(NULLIF(sii.batch_no,''), inv.batch_no, '') AS batch_no, inv.supplier_name, diff --git a/client/lib/models/inventory.dart b/client/lib/models/inventory.dart index afa6f38..b1ce039 100644 --- a/client/lib/models/inventory.dart +++ b/client/lib/models/inventory.dart @@ -15,7 +15,8 @@ class Inventory { final String spec; final String unit; final String warehouseName; - final double? unitPrice; + final double? unitPrice; // 成本价(入库进价) + final double? salePrice; // 单价(product 售价) final String? productionDate; final String batchNo; final String supplierName; @@ -37,6 +38,7 @@ class Inventory { this.unit = '', this.warehouseName = '', this.unitPrice, + this.salePrice, this.productionDate, this.batchNo = '', this.supplierName = '', @@ -59,6 +61,7 @@ class Inventory { unit: json['unit'] as String? ?? '', warehouseName: json['warehouse_name'] as String? ?? '', unitPrice: (json['unit_price'] as num?)?.toDouble(), + salePrice: (json['sale_price'] as num?)?.toDouble(), productionDate: _parseDate(json['production_date'] as String?), batchNo: json['batch_no'] as String? ?? '', supplierName: json['supplier_name'] as String? ?? '',