Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display of sales order completion status #460

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/inventree/orders.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class InvenTreeOrder extends InvenTreeModel {

int get lineItemCount => getInt("line_items", backup: 0);

int get completedLineItemCount => getInt("completed_lines", backup: 0);

bool get complete => completedLineItemCount >= lineItemCount;

bool get overdue => getBool("overdue");

String get reference => getString("reference");
Expand Down
15 changes: 3 additions & 12 deletions lib/widget/order/sales_order_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
List<InvenTreeSOLineItem> lines = [];

bool supportsProjectCodes = false;
int completedLines = 0;
int attachmentCount = 0;

@override
Expand Down Expand Up @@ -114,14 +113,6 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {

supportsProjectCodes = api.supportsProjectCodes && await api.getGlobalBooleanSetting("PROJECT_CODES_ENABLED");

completedLines = 0;

for (var line in lines) {
if (line.isComplete) {
completedLines += 1;
}
}

InvenTreeSalesOrderAttachment().count(filters: {
"order": widget.order.pk.toString()
}).then((int value) {
Expand Down Expand Up @@ -219,16 +210,16 @@ class _SalesOrderDetailState extends RefreshableState<SalesOrderDetailWidget> {
));
}

Color lineColor = completedLines < widget.order.lineItemCount ? COLOR_WARNING : COLOR_SUCCESS;
Color lineColor = widget.order.complete ? COLOR_WARNING : COLOR_SUCCESS;

tiles.add(ListTile(
title: Text(L10().lineItems),
subtitle: ProgressBar(
completedLines.toDouble(),
widget.order.completedLineItemCount.toDouble(),
maximum: widget.order.lineItemCount.toDouble()
),
leading: FaIcon(FontAwesomeIcons.clipboardCheck),
trailing: Text("${completedLines} / ${widget.order.lineItemCount}", style: TextStyle(color: lineColor)),
trailing: Text("${widget.order.completedLineItemCount} / ${widget.order.lineItemCount}", style: TextStyle(color: lineColor)),
));

// TODO: total price
Expand Down