mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 03:26:24 +00:00
Stock expiry (#590)
* Add stock expiry getters * refactor date getters * Display expiry information * Update release notes * Remove unused import
This commit is contained in:
parent
d84f76d482
commit
aac13ed5d6
6 changed files with 75 additions and 56 deletions
|
|
@ -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 {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue