Track inventory
This commit is contained in:
parent
15f4f11d3a
commit
cf4e012fcc
|
|
@ -95,7 +95,7 @@ abstract class ProductEntity extends Object
|
||||||
createdAt: 0,
|
createdAt: 0,
|
||||||
assignedUserId: '',
|
assignedUserId: '',
|
||||||
createdUserId: '',
|
createdUserId: '',
|
||||||
inStockQuantity: 0,
|
stockQuantity: 0,
|
||||||
stockNotificationThreshold: 0,
|
stockNotificationThreshold: 0,
|
||||||
stockNotification: true,
|
stockNotification: true,
|
||||||
documents: BuiltList<DocumentEntity>(),
|
documents: BuiltList<DocumentEntity>(),
|
||||||
|
|
@ -161,7 +161,7 @@ abstract class ProductEntity extends Object
|
||||||
String get customValue4;
|
String get customValue4;
|
||||||
|
|
||||||
@BuiltValueField(wireName: 'in_stock_quantity')
|
@BuiltValueField(wireName: 'in_stock_quantity')
|
||||||
int get inStockQuantity;
|
int get stockQuantity;
|
||||||
|
|
||||||
@BuiltValueField(wireName: 'stock_notification_threshold')
|
@BuiltValueField(wireName: 'stock_notification_threshold')
|
||||||
int get stockNotificationThreshold;
|
int get stockNotificationThreshold;
|
||||||
|
|
@ -347,7 +347,7 @@ abstract class ProductEntity extends Object
|
||||||
|
|
||||||
// ignore: unused_element
|
// ignore: unused_element
|
||||||
static void _initializeBuilder(ProductEntityBuilder builder) => builder
|
static void _initializeBuilder(ProductEntityBuilder builder) => builder
|
||||||
..inStockQuantity = 0
|
..stockQuantity = 0
|
||||||
..stockNotification = true
|
..stockNotification = true
|
||||||
..stockNotificationThreshold = 0;
|
..stockNotificationThreshold = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ class _$ProductEntitySerializer implements StructuredSerializer<ProductEntity> {
|
||||||
serializers.serialize(object.customValue4,
|
serializers.serialize(object.customValue4,
|
||||||
specifiedType: const FullType(String)),
|
specifiedType: const FullType(String)),
|
||||||
'in_stock_quantity',
|
'in_stock_quantity',
|
||||||
serializers.serialize(object.inStockQuantity,
|
serializers.serialize(object.stockQuantity,
|
||||||
specifiedType: const FullType(int)),
|
specifiedType: const FullType(int)),
|
||||||
'stock_notification_threshold',
|
'stock_notification_threshold',
|
||||||
serializers.serialize(object.stockNotificationThreshold,
|
serializers.serialize(object.stockNotificationThreshold,
|
||||||
|
|
@ -292,7 +292,7 @@ class _$ProductEntitySerializer implements StructuredSerializer<ProductEntity> {
|
||||||
specifiedType: const FullType(String)) as String;
|
specifiedType: const FullType(String)) as String;
|
||||||
break;
|
break;
|
||||||
case 'in_stock_quantity':
|
case 'in_stock_quantity':
|
||||||
result.inStockQuantity = serializers.deserialize(value,
|
result.stockQuantity = serializers.deserialize(value,
|
||||||
specifiedType: const FullType(int)) as int;
|
specifiedType: const FullType(int)) as int;
|
||||||
break;
|
break;
|
||||||
case 'stock_notification_threshold':
|
case 'stock_notification_threshold':
|
||||||
|
|
@ -565,7 +565,7 @@ class _$ProductEntity extends ProductEntity {
|
||||||
@override
|
@override
|
||||||
final String customValue4;
|
final String customValue4;
|
||||||
@override
|
@override
|
||||||
final int inStockQuantity;
|
final int stockQuantity;
|
||||||
@override
|
@override
|
||||||
final int stockNotificationThreshold;
|
final int stockNotificationThreshold;
|
||||||
@override
|
@override
|
||||||
|
|
@ -608,7 +608,7 @@ class _$ProductEntity extends ProductEntity {
|
||||||
this.customValue2,
|
this.customValue2,
|
||||||
this.customValue3,
|
this.customValue3,
|
||||||
this.customValue4,
|
this.customValue4,
|
||||||
this.inStockQuantity,
|
this.stockQuantity,
|
||||||
this.stockNotificationThreshold,
|
this.stockNotificationThreshold,
|
||||||
this.stockNotification,
|
this.stockNotification,
|
||||||
this.documents,
|
this.documents,
|
||||||
|
|
@ -649,7 +649,7 @@ class _$ProductEntity extends ProductEntity {
|
||||||
BuiltValueNullFieldError.checkNotNull(
|
BuiltValueNullFieldError.checkNotNull(
|
||||||
customValue4, 'ProductEntity', 'customValue4');
|
customValue4, 'ProductEntity', 'customValue4');
|
||||||
BuiltValueNullFieldError.checkNotNull(
|
BuiltValueNullFieldError.checkNotNull(
|
||||||
inStockQuantity, 'ProductEntity', 'inStockQuantity');
|
stockQuantity, 'ProductEntity', 'stockQuantity');
|
||||||
BuiltValueNullFieldError.checkNotNull(stockNotificationThreshold,
|
BuiltValueNullFieldError.checkNotNull(stockNotificationThreshold,
|
||||||
'ProductEntity', 'stockNotificationThreshold');
|
'ProductEntity', 'stockNotificationThreshold');
|
||||||
BuiltValueNullFieldError.checkNotNull(
|
BuiltValueNullFieldError.checkNotNull(
|
||||||
|
|
@ -691,7 +691,7 @@ class _$ProductEntity extends ProductEntity {
|
||||||
customValue2 == other.customValue2 &&
|
customValue2 == other.customValue2 &&
|
||||||
customValue3 == other.customValue3 &&
|
customValue3 == other.customValue3 &&
|
||||||
customValue4 == other.customValue4 &&
|
customValue4 == other.customValue4 &&
|
||||||
inStockQuantity == other.inStockQuantity &&
|
stockQuantity == other.stockQuantity &&
|
||||||
stockNotificationThreshold == other.stockNotificationThreshold &&
|
stockNotificationThreshold == other.stockNotificationThreshold &&
|
||||||
stockNotification == other.stockNotification &&
|
stockNotification == other.stockNotification &&
|
||||||
documents == other.documents &&
|
documents == other.documents &&
|
||||||
|
|
@ -734,7 +734,7 @@ class _$ProductEntity extends ProductEntity {
|
||||||
customValue2.hashCode),
|
customValue2.hashCode),
|
||||||
customValue3.hashCode),
|
customValue3.hashCode),
|
||||||
customValue4.hashCode),
|
customValue4.hashCode),
|
||||||
inStockQuantity.hashCode),
|
stockQuantity.hashCode),
|
||||||
stockNotificationThreshold.hashCode),
|
stockNotificationThreshold.hashCode),
|
||||||
stockNotification.hashCode),
|
stockNotification.hashCode),
|
||||||
documents.hashCode),
|
documents.hashCode),
|
||||||
|
|
@ -766,7 +766,7 @@ class _$ProductEntity extends ProductEntity {
|
||||||
..add('customValue2', customValue2)
|
..add('customValue2', customValue2)
|
||||||
..add('customValue3', customValue3)
|
..add('customValue3', customValue3)
|
||||||
..add('customValue4', customValue4)
|
..add('customValue4', customValue4)
|
||||||
..add('inStockQuantity', inStockQuantity)
|
..add('stockQuantity', stockQuantity)
|
||||||
..add('stockNotificationThreshold', stockNotificationThreshold)
|
..add('stockNotificationThreshold', stockNotificationThreshold)
|
||||||
..add('stockNotification', stockNotification)
|
..add('stockNotification', stockNotification)
|
||||||
..add('documents', documents)
|
..add('documents', documents)
|
||||||
|
|
@ -846,10 +846,9 @@ class ProductEntityBuilder
|
||||||
String get customValue4 => _$this._customValue4;
|
String get customValue4 => _$this._customValue4;
|
||||||
set customValue4(String customValue4) => _$this._customValue4 = customValue4;
|
set customValue4(String customValue4) => _$this._customValue4 = customValue4;
|
||||||
|
|
||||||
int _inStockQuantity;
|
int _stockQuantity;
|
||||||
int get inStockQuantity => _$this._inStockQuantity;
|
int get stockQuantity => _$this._stockQuantity;
|
||||||
set inStockQuantity(int inStockQuantity) =>
|
set stockQuantity(int stockQuantity) => _$this._stockQuantity = stockQuantity;
|
||||||
_$this._inStockQuantity = inStockQuantity;
|
|
||||||
|
|
||||||
int _stockNotificationThreshold;
|
int _stockNotificationThreshold;
|
||||||
int get stockNotificationThreshold => _$this._stockNotificationThreshold;
|
int get stockNotificationThreshold => _$this._stockNotificationThreshold;
|
||||||
|
|
@ -923,7 +922,7 @@ class ProductEntityBuilder
|
||||||
_customValue2 = $v.customValue2;
|
_customValue2 = $v.customValue2;
|
||||||
_customValue3 = $v.customValue3;
|
_customValue3 = $v.customValue3;
|
||||||
_customValue4 = $v.customValue4;
|
_customValue4 = $v.customValue4;
|
||||||
_inStockQuantity = $v.inStockQuantity;
|
_stockQuantity = $v.stockQuantity;
|
||||||
_stockNotificationThreshold = $v.stockNotificationThreshold;
|
_stockNotificationThreshold = $v.stockNotificationThreshold;
|
||||||
_stockNotification = $v.stockNotification;
|
_stockNotification = $v.stockNotification;
|
||||||
_documents = $v.documents.toBuilder();
|
_documents = $v.documents.toBuilder();
|
||||||
|
|
@ -982,7 +981,7 @@ class ProductEntityBuilder
|
||||||
customValue2: BuiltValueNullFieldError.checkNotNull(customValue2, 'ProductEntity', 'customValue2'),
|
customValue2: BuiltValueNullFieldError.checkNotNull(customValue2, 'ProductEntity', 'customValue2'),
|
||||||
customValue3: BuiltValueNullFieldError.checkNotNull(customValue3, 'ProductEntity', 'customValue3'),
|
customValue3: BuiltValueNullFieldError.checkNotNull(customValue3, 'ProductEntity', 'customValue3'),
|
||||||
customValue4: BuiltValueNullFieldError.checkNotNull(customValue4, 'ProductEntity', 'customValue4'),
|
customValue4: BuiltValueNullFieldError.checkNotNull(customValue4, 'ProductEntity', 'customValue4'),
|
||||||
inStockQuantity: BuiltValueNullFieldError.checkNotNull(inStockQuantity, 'ProductEntity', 'inStockQuantity'),
|
stockQuantity: BuiltValueNullFieldError.checkNotNull(stockQuantity, 'ProductEntity', 'stockQuantity'),
|
||||||
stockNotificationThreshold: BuiltValueNullFieldError.checkNotNull(stockNotificationThreshold, 'ProductEntity', 'stockNotificationThreshold'),
|
stockNotificationThreshold: BuiltValueNullFieldError.checkNotNull(stockNotificationThreshold, 'ProductEntity', 'stockNotificationThreshold'),
|
||||||
stockNotification: BuiltValueNullFieldError.checkNotNull(stockNotification, 'ProductEntity', 'stockNotification'),
|
stockNotification: BuiltValueNullFieldError.checkNotNull(stockNotification, 'ProductEntity', 'stockNotification'),
|
||||||
documents: documents.build(),
|
documents: documents.build(),
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
final _custom2Controller = TextEditingController();
|
final _custom2Controller = TextEditingController();
|
||||||
final _custom3Controller = TextEditingController();
|
final _custom3Controller = TextEditingController();
|
||||||
final _custom4Controller = TextEditingController();
|
final _custom4Controller = TextEditingController();
|
||||||
|
final _stockQuantityController = TextEditingController();
|
||||||
|
final _notificationThresholdController = TextEditingController();
|
||||||
|
|
||||||
List<TextEditingController> _controllers = [];
|
List<TextEditingController> _controllers = [];
|
||||||
final _debouncer = Debouncer();
|
final _debouncer = Debouncer();
|
||||||
|
|
@ -59,6 +61,8 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
_custom2Controller,
|
_custom2Controller,
|
||||||
_custom3Controller,
|
_custom3Controller,
|
||||||
_custom4Controller,
|
_custom4Controller,
|
||||||
|
_stockQuantityController,
|
||||||
|
_notificationThresholdController,
|
||||||
];
|
];
|
||||||
|
|
||||||
_controllers
|
_controllers
|
||||||
|
|
@ -77,6 +81,16 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
_custom2Controller.text = product.customValue2;
|
_custom2Controller.text = product.customValue2;
|
||||||
_custom3Controller.text = product.customValue3;
|
_custom3Controller.text = product.customValue3;
|
||||||
_custom4Controller.text = product.customValue4;
|
_custom4Controller.text = product.customValue4;
|
||||||
|
_stockQuantityController.text = formatNumber(
|
||||||
|
product.stockQuantity.toDouble(),
|
||||||
|
context,
|
||||||
|
formatNumberType: FormatNumberType.int,
|
||||||
|
);
|
||||||
|
_notificationThresholdController.text = formatNumber(
|
||||||
|
product.stockNotificationThreshold.toDouble(),
|
||||||
|
context,
|
||||||
|
formatNumberType: FormatNumberType.int,
|
||||||
|
);
|
||||||
|
|
||||||
_controllers
|
_controllers
|
||||||
.forEach((dynamic controller) => controller.addListener(_onChanged));
|
.forEach((dynamic controller) => controller.addListener(_onChanged));
|
||||||
|
|
@ -245,6 +259,27 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
value: product.customValue4,
|
value: product.customValue4,
|
||||||
onSavePressed: viewModel.onSavePressed,
|
onSavePressed: viewModel.onSavePressed,
|
||||||
),
|
),
|
||||||
|
if (company.trackInventory) ...[
|
||||||
|
DecoratedFormField(
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
controller: _stockQuantityController,
|
||||||
|
label: localization.stockQuantity,
|
||||||
|
),
|
||||||
|
SwitchListTile(
|
||||||
|
activeColor: Theme.of(context).colorScheme.secondary,
|
||||||
|
title: Text(localization.stockNotifications),
|
||||||
|
value: product.stockNotification,
|
||||||
|
subtitle: Text(localization.stockNotificationsHelp),
|
||||||
|
onChanged: (value) => viewModel.onChanged(
|
||||||
|
product.rebuild((b) => b..stockNotification = value)),
|
||||||
|
),
|
||||||
|
if (product.stockNotification)
|
||||||
|
DecoratedFormField(
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
controller: _notificationThresholdController,
|
||||||
|
label: localization.stockQuantity,
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
static final Map<String, Map<String, String>> _localizedValues = {
|
static final Map<String, Map<String, String>> _localizedValues = {
|
||||||
'en': {
|
'en': {
|
||||||
// STARTER: lang key - do not remove comment
|
// STARTER: lang key - do not remove comment
|
||||||
|
'stock_quantity': 'Stock Quantity',
|
||||||
'notification_threshold': 'Notification Threshold',
|
'notification_threshold': 'Notification Threshold',
|
||||||
'track_inventory': 'Track Inventory',
|
'track_inventory': 'Track Inventory',
|
||||||
'track_inventory_help':
|
'track_inventory_help':
|
||||||
|
|
@ -70573,6 +70574,11 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
_localizedValues[localeCode]['notification_threshold'] ??
|
_localizedValues[localeCode]['notification_threshold'] ??
|
||||||
_localizedValues['en']['notification_threshold'];
|
_localizedValues['en']['notification_threshold'];
|
||||||
|
|
||||||
|
String get stockQuantity =>
|
||||||
|
_localizedValues[localeCode]['stock_quantity'] ??
|
||||||
|
_localizedValues['en']['stock_quantity'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// STARTER: lang field - do not remove comment
|
// STARTER: lang field - do not remove comment
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue