Stock expiry (#590)

* Add stock expiry getters

* refactor date getters

* Display expiry information

* Update release notes

* Remove unused import
This commit is contained in:
Oliver 2024-12-23 22:25:55 +11:00 committed by GitHub
parent d84f76d482
commit aac13ed5d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 75 additions and 56 deletions

View file

@ -3,6 +3,7 @@ import "dart:io";
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
import "package:flutter/material.dart";
import "package:intl/intl.dart";
import "package:inventree/widget/snacks.dart";
import "package:url_launcher/url_launcher.dart";
import "package:path/path.dart" as path;
@ -156,6 +157,30 @@ class InvenTreeModel {
return value.toString().toLowerCase() == "true";
}
// Helper function to get date value from json data
DateTime? getDate(String key, {DateTime? backup, String subKey = ""}) {
dynamic value = getValue(key, backup: backup, subKey: subKey);
if (value == null) {
return backup;
}
return DateTime.tryParse(value as String);
}
// Helper function to get date as a string
String getDateString(String key, {DateTime? backup, String subKey = ""}) {
DateTime? dt = getDate(key, backup: backup, subKey: subKey);
if (dt == null) {
return "";
}
final DateFormat fmt = DateFormat("yyyy-MM-dd");
return fmt.format(dt);
}
// Return the InvenTree web server URL for this object
String get webUrl {