mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-29 14:06:47 +00:00
Display line items in purchase order view
This commit is contained in:
parent
cca56299f8
commit
54d8c1759c
@ -103,6 +103,10 @@ class InvenTreeSupplierPart extends InvenTreeModel {
|
||||
|
||||
int get partId => jsondata['part'] ?? -1;
|
||||
|
||||
String get partImage => jsondata["part_detail"]["thumbnail"] ?? InvenTreeAPI.staticThumb;
|
||||
|
||||
String get partName => jsondata["part_detail"]["full_name"] ?? "";
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
var part = InvenTreeSupplierPart.fromJson(json);
|
||||
|
@ -52,7 +52,7 @@ class InvenTreePurchaseOrder extends InvenTreeModel {
|
||||
|
||||
String get targetDate => jsondata['target_date'] ?? "";
|
||||
|
||||
int get lineItems => jsondata['line_items'] ?? 0;
|
||||
int get lineItemCount => jsondata['line_items'] ?? 0;
|
||||
|
||||
bool get overdue => jsondata['overdue'] ?? false;
|
||||
|
||||
@ -144,10 +144,14 @@ class InvenTreePOLineItem extends InvenTreeModel {
|
||||
};
|
||||
}
|
||||
|
||||
bool get isComplete => received >= quantity;
|
||||
|
||||
double get quantity => jsondata['quantity'] ?? 0;
|
||||
|
||||
double get received => jsondata['received'] ?? 0;
|
||||
|
||||
double get outstanding => quantity - received;
|
||||
|
||||
String get reference => jsondata['reference'] ?? "";
|
||||
|
||||
int get orderId => jsondata['order'] ?? -1;
|
||||
@ -164,6 +168,17 @@ class InvenTreePOLineItem extends InvenTreeModel {
|
||||
}
|
||||
}
|
||||
|
||||
InvenTreeSupplierPart? get supplierPart {
|
||||
|
||||
dynamic detail = jsondata["supplier_part_detail"] ?? null;
|
||||
|
||||
if (detail == null) {
|
||||
return null;
|
||||
} else {
|
||||
return InvenTreeSupplierPart.fromJson(detail);
|
||||
}
|
||||
}
|
||||
|
||||
double get purchasePrice => double.parse(jsondata['purchase_price']);
|
||||
|
||||
String get purchasePriceCurrency => jsondata['purchase_price_currency'] ?? "";
|
||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
||||
Subproject commit ecd831b26c3739c235db65867d39ff9af517b09a
|
||||
Subproject commit dba9551b897dca766088e5470704e20edb770499
|
@ -32,6 +32,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
|
||||
List<InvenTreePOLineItem> lines = [];
|
||||
|
||||
int completedLines = 0;
|
||||
|
||||
@override
|
||||
String getAppBarTitle(BuildContext context) => L10().purchaseOrder;
|
||||
|
||||
@ -60,6 +62,14 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
|
||||
lines = await order.getLineItems();
|
||||
|
||||
completedLines = 0;
|
||||
|
||||
for (var line in lines) {
|
||||
if (line.isComplete) {
|
||||
completedLines += 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void editOrder(BuildContext context) async {
|
||||
@ -73,27 +83,40 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
);
|
||||
}
|
||||
|
||||
Widget headerTile(BuildContext context) {
|
||||
|
||||
InvenTreeCompany? supplier = order.supplier;
|
||||
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(order.reference),
|
||||
subtitle: Text(order.description),
|
||||
leading: supplier == null ? null : InvenTreeAPI().getImage(supplier.thumbnail, width: 40, height: 40),
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
List<Widget> orderTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
InvenTreeCompany? supplier = order.supplier;
|
||||
|
||||
tiles.add(Card(
|
||||
child: ListTile(
|
||||
title: Text(order.reference),
|
||||
subtitle: Text(order.description),
|
||||
leading: supplier == null ? null : InvenTreeAPI().getImage(supplier.thumbnail, width: 40, height: 40),
|
||||
)
|
||||
));
|
||||
tiles.add(headerTile(context));
|
||||
|
||||
if (supplier != null) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().supplier),
|
||||
subtitle: Text(supplier.name),
|
||||
leading: FaIcon(FontAwesomeIcons.building),
|
||||
leading: FaIcon(FontAwesomeIcons.building, color: COLOR_CLICK),
|
||||
onTap: () {
|
||||
// TODO - Navigate to "supplier" page
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CompanyDetailWidget(supplier)
|
||||
)
|
||||
);
|
||||
},
|
||||
));
|
||||
}
|
||||
@ -106,6 +129,30 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
));
|
||||
}
|
||||
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().lineItems),
|
||||
leading: FaIcon(FontAwesomeIcons.clipboardList, color: COLOR_CLICK),
|
||||
trailing: Text("${order.lineItemCount}"),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
// Switch to the "line items" tab
|
||||
tabIndex = 1;
|
||||
});
|
||||
},
|
||||
));
|
||||
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().received),
|
||||
leading: FaIcon(FontAwesomeIcons.clipboardCheck, color: COLOR_CLICK),
|
||||
trailing: Text("${completedLines}"),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
// Switch to the "received items" tab
|
||||
tabIndex = 2;
|
||||
});
|
||||
},
|
||||
));
|
||||
|
||||
if (order.issueDate.isNotEmpty) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(L10().issueDate),
|
||||
@ -126,6 +173,33 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
|
||||
}
|
||||
|
||||
List<Widget> lineTiles(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
tiles.add(headerTile(context));
|
||||
|
||||
for (var line in lines) {
|
||||
|
||||
InvenTreeSupplierPart? supplierPart = line.supplierPart;
|
||||
|
||||
if (supplierPart == null) {
|
||||
continue;
|
||||
} else {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(supplierPart.SKU),
|
||||
subtitle: Text(supplierPart.partName),
|
||||
leading: InvenTreeAPI().getImage(supplierPart.partImage, width: 40, height: 40),
|
||||
trailing: Text("${line.quantity}"),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
|
||||
@ -140,6 +214,10 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
||||
return ListView(
|
||||
children: orderTiles(context)
|
||||
);
|
||||
case 1:
|
||||
return ListView(
|
||||
children: lineTiles(context)
|
||||
);
|
||||
case 2:
|
||||
// Stock items received against this order
|
||||
Map<String, String> filters = {
|
||||
|
@ -166,7 +166,7 @@ class _PaginatedPurchaseOrderListState extends State<_PaginatedPurchaseOrderList
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
trailing: Text("${order.lineItems}"),
|
||||
trailing: Text("${order.lineItemCount}"),
|
||||
onTap: () async {
|
||||
Navigator.push(
|
||||
context,
|
||||
|
Loading…
x
Reference in New Issue
Block a user