From f2183fd2dec45980479fb6552b0403c98bb897e7 Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Tue, 4 Nov 2025 15:48:48 +0330 Subject: [PATCH] feat: add otp code for sell order fix: form for segmentation --- android/local.properties | 4 +- .../steward_free_sale_bar_request.dart | 8 +- ...steward_free_sale_bar_request.freezed.dart | 60 +- .../steward_free_sale_bar_request.g.dart | 16 +- .../steward_free_sale_bar.dart | 1 + .../steward_free_sale_bar.freezed.dart | 43 +- .../steward_free_sale_bar.g.dart | 2 + .../presentation/pages/steward/home/view.dart | 2 - .../steward/sales_in_province/logic.dart | 9 +- .../pages/steward/sales_in_province/view.dart | 474 +--------------- .../widgets/cu_sale_in_provience.dart | 342 +++++++++++ .../steward/sales_out_of_province/logic.dart | 57 +- .../steward/sales_out_of_province/view.dart | 537 +++++++++--------- .../view.dart | 21 +- .../pages/steward/segmentation/logic.dart | 53 +- .../pages/steward/segmentation/view.dart | 458 +-------------- .../segmentation/widgets/cu_bottom_sheet.dart | 395 +++++++++++++ packages/chicken/pubspec.yaml | 4 +- .../presentation/widget/inputs/r_input.dart | 1 + .../widget/inputs/unit_text_field.dart | 16 +- .../presentation/widget/monthly_calender.dart | 3 + pubspec.yaml | 2 +- 22 files changed, 1220 insertions(+), 1288 deletions(-) create mode 100644 packages/chicken/lib/presentation/pages/steward/sales_in_province/widgets/cu_sale_in_provience.dart create mode 100644 packages/chicken/lib/presentation/pages/steward/segmentation/widgets/cu_bottom_sheet.dart diff --git a/android/local.properties b/android/local.properties index 7e73034..a348d42 100644 --- a/android/local.properties +++ b/android/local.properties @@ -1,5 +1,5 @@ sdk.dir=C:/Users/Housh11/AppData/Local/Android/Sdk flutter.sdk=C:\\src\\flutter flutter.buildMode=release -flutter.versionName=1.3.30 -flutter.versionCode=27 \ No newline at end of file +flutter.versionName=1.3.32 +flutter.versionCode=29 \ No newline at end of file diff --git a/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.dart b/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.dart index 6e0ebaa..1d8da3e 100644 --- a/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.dart +++ b/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.dart @@ -7,12 +7,18 @@ part 'steward_free_sale_bar_request.g.dart'; abstract class StewardFreeSaleBarRequest with _$StewardFreeSaleBarRequest { const factory StewardFreeSaleBarRequest({ String? buyerKey, + String? buyerMobile, + String? buyerName, + String? city, + String? key, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, - String? key, + String? role, + String? registerCode, + String? province, String? quota, String? saleType, String? productionDate, diff --git a/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.freezed.dart b/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.freezed.dart index 0a24d2f..3a73391 100644 --- a/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.freezed.dart +++ b/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$StewardFreeSaleBarRequest { - String? get buyerKey; int? get numberOfCarcasses; int? get weightOfCarcasses; String? get date; String? get clearanceCode; String? get productKey; String? get key; String? get quota; String? get saleType; String? get productionDate; + String? get buyerKey; String? get buyerMobile; String? get buyerName; String? get city; String? get key; int? get numberOfCarcasses; int? get weightOfCarcasses; String? get date; String? get clearanceCode; String? get productKey; String? get role; String? get registerCode; String? get province; String? get quota; String? get saleType; String? get productionDate; /// Create a copy of StewardFreeSaleBarRequest /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -28,16 +28,16 @@ $StewardFreeSaleBarRequestCopyWith get copyWith => _$ @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is StewardFreeSaleBarRequest&&(identical(other.buyerKey, buyerKey) || other.buyerKey == buyerKey)&&(identical(other.numberOfCarcasses, numberOfCarcasses) || other.numberOfCarcasses == numberOfCarcasses)&&(identical(other.weightOfCarcasses, weightOfCarcasses) || other.weightOfCarcasses == weightOfCarcasses)&&(identical(other.date, date) || other.date == date)&&(identical(other.clearanceCode, clearanceCode) || other.clearanceCode == clearanceCode)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.key, key) || other.key == key)&&(identical(other.quota, quota) || other.quota == quota)&&(identical(other.saleType, saleType) || other.saleType == saleType)&&(identical(other.productionDate, productionDate) || other.productionDate == productionDate)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is StewardFreeSaleBarRequest&&(identical(other.buyerKey, buyerKey) || other.buyerKey == buyerKey)&&(identical(other.buyerMobile, buyerMobile) || other.buyerMobile == buyerMobile)&&(identical(other.buyerName, buyerName) || other.buyerName == buyerName)&&(identical(other.city, city) || other.city == city)&&(identical(other.key, key) || other.key == key)&&(identical(other.numberOfCarcasses, numberOfCarcasses) || other.numberOfCarcasses == numberOfCarcasses)&&(identical(other.weightOfCarcasses, weightOfCarcasses) || other.weightOfCarcasses == weightOfCarcasses)&&(identical(other.date, date) || other.date == date)&&(identical(other.clearanceCode, clearanceCode) || other.clearanceCode == clearanceCode)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.role, role) || other.role == role)&&(identical(other.registerCode, registerCode) || other.registerCode == registerCode)&&(identical(other.province, province) || other.province == province)&&(identical(other.quota, quota) || other.quota == quota)&&(identical(other.saleType, saleType) || other.saleType == saleType)&&(identical(other.productionDate, productionDate) || other.productionDate == productionDate)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,buyerKey,numberOfCarcasses,weightOfCarcasses,date,clearanceCode,productKey,key,quota,saleType,productionDate); +int get hashCode => Object.hash(runtimeType,buyerKey,buyerMobile,buyerName,city,key,numberOfCarcasses,weightOfCarcasses,date,clearanceCode,productKey,role,registerCode,province,quota,saleType,productionDate); @override String toString() { - return 'StewardFreeSaleBarRequest(buyerKey: $buyerKey, numberOfCarcasses: $numberOfCarcasses, weightOfCarcasses: $weightOfCarcasses, date: $date, clearanceCode: $clearanceCode, productKey: $productKey, key: $key, quota: $quota, saleType: $saleType, productionDate: $productionDate)'; + return 'StewardFreeSaleBarRequest(buyerKey: $buyerKey, buyerMobile: $buyerMobile, buyerName: $buyerName, city: $city, key: $key, numberOfCarcasses: $numberOfCarcasses, weightOfCarcasses: $weightOfCarcasses, date: $date, clearanceCode: $clearanceCode, productKey: $productKey, role: $role, registerCode: $registerCode, province: $province, quota: $quota, saleType: $saleType, productionDate: $productionDate)'; } @@ -48,7 +48,7 @@ abstract mixin class $StewardFreeSaleBarRequestCopyWith<$Res> { factory $StewardFreeSaleBarRequestCopyWith(StewardFreeSaleBarRequest value, $Res Function(StewardFreeSaleBarRequest) _then) = _$StewardFreeSaleBarRequestCopyWithImpl; @useResult $Res call({ - String? buyerKey, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, String? key, String? quota, String? saleType, String? productionDate + String? buyerKey, String? buyerMobile, String? buyerName, String? city, String? key, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, String? role, String? registerCode, String? province, String? quota, String? saleType, String? productionDate }); @@ -65,15 +65,21 @@ class _$StewardFreeSaleBarRequestCopyWithImpl<$Res> /// Create a copy of StewardFreeSaleBarRequest /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? buyerKey = freezed,Object? numberOfCarcasses = freezed,Object? weightOfCarcasses = freezed,Object? date = freezed,Object? clearanceCode = freezed,Object? productKey = freezed,Object? key = freezed,Object? quota = freezed,Object? saleType = freezed,Object? productionDate = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? buyerKey = freezed,Object? buyerMobile = freezed,Object? buyerName = freezed,Object? city = freezed,Object? key = freezed,Object? numberOfCarcasses = freezed,Object? weightOfCarcasses = freezed,Object? date = freezed,Object? clearanceCode = freezed,Object? productKey = freezed,Object? role = freezed,Object? registerCode = freezed,Object? province = freezed,Object? quota = freezed,Object? saleType = freezed,Object? productionDate = freezed,}) { return _then(_self.copyWith( buyerKey: freezed == buyerKey ? _self.buyerKey : buyerKey // ignore: cast_nullable_to_non_nullable +as String?,buyerMobile: freezed == buyerMobile ? _self.buyerMobile : buyerMobile // ignore: cast_nullable_to_non_nullable +as String?,buyerName: freezed == buyerName ? _self.buyerName : buyerName // ignore: cast_nullable_to_non_nullable +as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable +as String?,key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable as String?,numberOfCarcasses: freezed == numberOfCarcasses ? _self.numberOfCarcasses : numberOfCarcasses // ignore: cast_nullable_to_non_nullable as int?,weightOfCarcasses: freezed == weightOfCarcasses ? _self.weightOfCarcasses : weightOfCarcasses // ignore: cast_nullable_to_non_nullable as int?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable as String?,clearanceCode: freezed == clearanceCode ? _self.clearanceCode : clearanceCode // ignore: cast_nullable_to_non_nullable as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable -as String?,key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable +as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable +as String?,registerCode: freezed == registerCode ? _self.registerCode : registerCode // ignore: cast_nullable_to_non_nullable +as String?,province: freezed == province ? _self.province : province // ignore: cast_nullable_to_non_nullable as String?,quota: freezed == quota ? _self.quota : quota // ignore: cast_nullable_to_non_nullable as String?,saleType: freezed == saleType ? _self.saleType : saleType // ignore: cast_nullable_to_non_nullable as String?,productionDate: freezed == productionDate ? _self.productionDate : productionDate // ignore: cast_nullable_to_non_nullable @@ -162,10 +168,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String? buyerKey, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, String? key, String? quota, String? saleType, String? productionDate)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String? buyerKey, String? buyerMobile, String? buyerName, String? city, String? key, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, String? role, String? registerCode, String? province, String? quota, String? saleType, String? productionDate)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _StewardFreeSaleBarRequest() when $default != null: -return $default(_that.buyerKey,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.clearanceCode,_that.productKey,_that.key,_that.quota,_that.saleType,_that.productionDate);case _: +return $default(_that.buyerKey,_that.buyerMobile,_that.buyerName,_that.city,_that.key,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.clearanceCode,_that.productKey,_that.role,_that.registerCode,_that.province,_that.quota,_that.saleType,_that.productionDate);case _: return orElse(); } @@ -183,10 +189,10 @@ return $default(_that.buyerKey,_that.numberOfCarcasses,_that.weightOfCarcasses,_ /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String? buyerKey, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, String? key, String? quota, String? saleType, String? productionDate) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String? buyerKey, String? buyerMobile, String? buyerName, String? city, String? key, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, String? role, String? registerCode, String? province, String? quota, String? saleType, String? productionDate) $default,) {final _that = this; switch (_that) { case _StewardFreeSaleBarRequest(): -return $default(_that.buyerKey,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.clearanceCode,_that.productKey,_that.key,_that.quota,_that.saleType,_that.productionDate);case _: +return $default(_that.buyerKey,_that.buyerMobile,_that.buyerName,_that.city,_that.key,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.clearanceCode,_that.productKey,_that.role,_that.registerCode,_that.province,_that.quota,_that.saleType,_that.productionDate);case _: throw StateError('Unexpected subclass'); } @@ -203,10 +209,10 @@ return $default(_that.buyerKey,_that.numberOfCarcasses,_that.weightOfCarcasses,_ /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? buyerKey, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, String? key, String? quota, String? saleType, String? productionDate)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? buyerKey, String? buyerMobile, String? buyerName, String? city, String? key, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, String? role, String? registerCode, String? province, String? quota, String? saleType, String? productionDate)? $default,) {final _that = this; switch (_that) { case _StewardFreeSaleBarRequest() when $default != null: -return $default(_that.buyerKey,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.clearanceCode,_that.productKey,_that.key,_that.quota,_that.saleType,_that.productionDate);case _: +return $default(_that.buyerKey,_that.buyerMobile,_that.buyerName,_that.city,_that.key,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.clearanceCode,_that.productKey,_that.role,_that.registerCode,_that.province,_that.quota,_that.saleType,_that.productionDate);case _: return null; } @@ -218,16 +224,22 @@ return $default(_that.buyerKey,_that.numberOfCarcasses,_that.weightOfCarcasses,_ @JsonSerializable() class _StewardFreeSaleBarRequest implements StewardFreeSaleBarRequest { - const _StewardFreeSaleBarRequest({this.buyerKey, this.numberOfCarcasses, this.weightOfCarcasses, this.date, this.clearanceCode, this.productKey, this.key, this.quota, this.saleType, this.productionDate}); + const _StewardFreeSaleBarRequest({this.buyerKey, this.buyerMobile, this.buyerName, this.city, this.key, this.numberOfCarcasses, this.weightOfCarcasses, this.date, this.clearanceCode, this.productKey, this.role, this.registerCode, this.province, this.quota, this.saleType, this.productionDate}); factory _StewardFreeSaleBarRequest.fromJson(Map json) => _$StewardFreeSaleBarRequestFromJson(json); @override final String? buyerKey; +@override final String? buyerMobile; +@override final String? buyerName; +@override final String? city; +@override final String? key; @override final int? numberOfCarcasses; @override final int? weightOfCarcasses; @override final String? date; @override final String? clearanceCode; @override final String? productKey; -@override final String? key; +@override final String? role; +@override final String? registerCode; +@override final String? province; @override final String? quota; @override final String? saleType; @override final String? productionDate; @@ -245,16 +257,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _StewardFreeSaleBarRequest&&(identical(other.buyerKey, buyerKey) || other.buyerKey == buyerKey)&&(identical(other.numberOfCarcasses, numberOfCarcasses) || other.numberOfCarcasses == numberOfCarcasses)&&(identical(other.weightOfCarcasses, weightOfCarcasses) || other.weightOfCarcasses == weightOfCarcasses)&&(identical(other.date, date) || other.date == date)&&(identical(other.clearanceCode, clearanceCode) || other.clearanceCode == clearanceCode)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.key, key) || other.key == key)&&(identical(other.quota, quota) || other.quota == quota)&&(identical(other.saleType, saleType) || other.saleType == saleType)&&(identical(other.productionDate, productionDate) || other.productionDate == productionDate)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _StewardFreeSaleBarRequest&&(identical(other.buyerKey, buyerKey) || other.buyerKey == buyerKey)&&(identical(other.buyerMobile, buyerMobile) || other.buyerMobile == buyerMobile)&&(identical(other.buyerName, buyerName) || other.buyerName == buyerName)&&(identical(other.city, city) || other.city == city)&&(identical(other.key, key) || other.key == key)&&(identical(other.numberOfCarcasses, numberOfCarcasses) || other.numberOfCarcasses == numberOfCarcasses)&&(identical(other.weightOfCarcasses, weightOfCarcasses) || other.weightOfCarcasses == weightOfCarcasses)&&(identical(other.date, date) || other.date == date)&&(identical(other.clearanceCode, clearanceCode) || other.clearanceCode == clearanceCode)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.role, role) || other.role == role)&&(identical(other.registerCode, registerCode) || other.registerCode == registerCode)&&(identical(other.province, province) || other.province == province)&&(identical(other.quota, quota) || other.quota == quota)&&(identical(other.saleType, saleType) || other.saleType == saleType)&&(identical(other.productionDate, productionDate) || other.productionDate == productionDate)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,buyerKey,numberOfCarcasses,weightOfCarcasses,date,clearanceCode,productKey,key,quota,saleType,productionDate); +int get hashCode => Object.hash(runtimeType,buyerKey,buyerMobile,buyerName,city,key,numberOfCarcasses,weightOfCarcasses,date,clearanceCode,productKey,role,registerCode,province,quota,saleType,productionDate); @override String toString() { - return 'StewardFreeSaleBarRequest(buyerKey: $buyerKey, numberOfCarcasses: $numberOfCarcasses, weightOfCarcasses: $weightOfCarcasses, date: $date, clearanceCode: $clearanceCode, productKey: $productKey, key: $key, quota: $quota, saleType: $saleType, productionDate: $productionDate)'; + return 'StewardFreeSaleBarRequest(buyerKey: $buyerKey, buyerMobile: $buyerMobile, buyerName: $buyerName, city: $city, key: $key, numberOfCarcasses: $numberOfCarcasses, weightOfCarcasses: $weightOfCarcasses, date: $date, clearanceCode: $clearanceCode, productKey: $productKey, role: $role, registerCode: $registerCode, province: $province, quota: $quota, saleType: $saleType, productionDate: $productionDate)'; } @@ -265,7 +277,7 @@ abstract mixin class _$StewardFreeSaleBarRequestCopyWith<$Res> implements $Stewa factory _$StewardFreeSaleBarRequestCopyWith(_StewardFreeSaleBarRequest value, $Res Function(_StewardFreeSaleBarRequest) _then) = __$StewardFreeSaleBarRequestCopyWithImpl; @override @useResult $Res call({ - String? buyerKey, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, String? key, String? quota, String? saleType, String? productionDate + String? buyerKey, String? buyerMobile, String? buyerName, String? city, String? key, int? numberOfCarcasses, int? weightOfCarcasses, String? date, String? clearanceCode, String? productKey, String? role, String? registerCode, String? province, String? quota, String? saleType, String? productionDate }); @@ -282,15 +294,21 @@ class __$StewardFreeSaleBarRequestCopyWithImpl<$Res> /// Create a copy of StewardFreeSaleBarRequest /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? buyerKey = freezed,Object? numberOfCarcasses = freezed,Object? weightOfCarcasses = freezed,Object? date = freezed,Object? clearanceCode = freezed,Object? productKey = freezed,Object? key = freezed,Object? quota = freezed,Object? saleType = freezed,Object? productionDate = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? buyerKey = freezed,Object? buyerMobile = freezed,Object? buyerName = freezed,Object? city = freezed,Object? key = freezed,Object? numberOfCarcasses = freezed,Object? weightOfCarcasses = freezed,Object? date = freezed,Object? clearanceCode = freezed,Object? productKey = freezed,Object? role = freezed,Object? registerCode = freezed,Object? province = freezed,Object? quota = freezed,Object? saleType = freezed,Object? productionDate = freezed,}) { return _then(_StewardFreeSaleBarRequest( buyerKey: freezed == buyerKey ? _self.buyerKey : buyerKey // ignore: cast_nullable_to_non_nullable +as String?,buyerMobile: freezed == buyerMobile ? _self.buyerMobile : buyerMobile // ignore: cast_nullable_to_non_nullable +as String?,buyerName: freezed == buyerName ? _self.buyerName : buyerName // ignore: cast_nullable_to_non_nullable +as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable +as String?,key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable as String?,numberOfCarcasses: freezed == numberOfCarcasses ? _self.numberOfCarcasses : numberOfCarcasses // ignore: cast_nullable_to_non_nullable as int?,weightOfCarcasses: freezed == weightOfCarcasses ? _self.weightOfCarcasses : weightOfCarcasses // ignore: cast_nullable_to_non_nullable as int?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable as String?,clearanceCode: freezed == clearanceCode ? _self.clearanceCode : clearanceCode // ignore: cast_nullable_to_non_nullable as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable -as String?,key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable +as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable +as String?,registerCode: freezed == registerCode ? _self.registerCode : registerCode // ignore: cast_nullable_to_non_nullable +as String?,province: freezed == province ? _self.province : province // ignore: cast_nullable_to_non_nullable as String?,quota: freezed == quota ? _self.quota : quota // ignore: cast_nullable_to_non_nullable as String?,saleType: freezed == saleType ? _self.saleType : saleType // ignore: cast_nullable_to_non_nullable as String?,productionDate: freezed == productionDate ? _self.productionDate : productionDate // ignore: cast_nullable_to_non_nullable diff --git a/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.g.dart b/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.g.dart index 1f99507..375effa 100644 --- a/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.g.dart +++ b/packages/chicken/lib/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.g.dart @@ -10,12 +10,18 @@ _StewardFreeSaleBarRequest _$StewardFreeSaleBarRequestFromJson( Map json, ) => _StewardFreeSaleBarRequest( buyerKey: json['buyer_key'] as String?, + buyerMobile: json['buyer_mobile'] as String?, + buyerName: json['buyer_name'] as String?, + city: json['city'] as String?, + key: json['key'] as String?, numberOfCarcasses: (json['number_of_carcasses'] as num?)?.toInt(), weightOfCarcasses: (json['weight_of_carcasses'] as num?)?.toInt(), date: json['date'] as String?, clearanceCode: json['clearance_code'] as String?, productKey: json['product_key'] as String?, - key: json['key'] as String?, + role: json['role'] as String?, + registerCode: json['register_code'] as String?, + province: json['province'] as String?, quota: json['quota'] as String?, saleType: json['sale_type'] as String?, productionDate: json['production_date'] as String?, @@ -25,12 +31,18 @@ Map _$StewardFreeSaleBarRequestToJson( _StewardFreeSaleBarRequest instance, ) => { 'buyer_key': instance.buyerKey, + 'buyer_mobile': instance.buyerMobile, + 'buyer_name': instance.buyerName, + 'city': instance.city, + 'key': instance.key, 'number_of_carcasses': instance.numberOfCarcasses, 'weight_of_carcasses': instance.weightOfCarcasses, 'date': instance.date, 'clearance_code': instance.clearanceCode, 'product_key': instance.productKey, - 'key': instance.key, + 'role': instance.role, + 'register_code': instance.registerCode, + 'province': instance.province, 'quota': instance.quota, 'sale_type': instance.saleType, 'production_date': instance.productionDate, diff --git a/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.dart b/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.dart index fcadc97..2e580b3 100644 --- a/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.dart +++ b/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.dart @@ -26,6 +26,7 @@ abstract class StewardFreeSaleBar with _$StewardFreeSaleBar { String? date, bool? temporaryTrash, bool? temporaryDeleted, + String? registerCode, String? createdBy, String? modifiedBy, String? quota, diff --git a/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.freezed.dart b/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.freezed.dart index dfd27a8..2a71c34 100644 --- a/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.freezed.dart +++ b/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$StewardFreeSaleBar { - int? get id; Buyer? get buyer; String? get key; String? get createDate; String? get modifyDate; bool? get trash; String? get buyerName; String? get buyerMobile; String? get province; String? get city; String? get driverName; String? get driverMobile; String? get typeCar; String? get pelak; String? get clearanceCode; int? get numberOfCarcasses; double? get weightOfCarcasses; String? get date; bool? get temporaryTrash; bool? get temporaryDeleted; String? get createdBy; String? get modifiedBy; String? get quota; String? get saleType; String? get productionDate; dynamic get steward; dynamic get guild; dynamic get product; + int? get id; Buyer? get buyer; String? get key; String? get createDate; String? get modifyDate; bool? get trash; String? get buyerName; String? get buyerMobile; String? get province; String? get city; String? get driverName; String? get driverMobile; String? get typeCar; String? get pelak; String? get clearanceCode; int? get numberOfCarcasses; double? get weightOfCarcasses; String? get date; bool? get temporaryTrash; bool? get temporaryDeleted; String? get registerCode; String? get createdBy; String? get modifiedBy; String? get quota; String? get saleType; String? get productionDate; dynamic get steward; dynamic get guild; dynamic get product; /// Create a copy of StewardFreeSaleBar /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -28,16 +28,16 @@ $StewardFreeSaleBarCopyWith get copyWith => _$StewardFreeSal @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is StewardFreeSaleBar&&(identical(other.id, id) || other.id == id)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.key, key) || other.key == key)&&(identical(other.createDate, createDate) || other.createDate == createDate)&&(identical(other.modifyDate, modifyDate) || other.modifyDate == modifyDate)&&(identical(other.trash, trash) || other.trash == trash)&&(identical(other.buyerName, buyerName) || other.buyerName == buyerName)&&(identical(other.buyerMobile, buyerMobile) || other.buyerMobile == buyerMobile)&&(identical(other.province, province) || other.province == province)&&(identical(other.city, city) || other.city == city)&&(identical(other.driverName, driverName) || other.driverName == driverName)&&(identical(other.driverMobile, driverMobile) || other.driverMobile == driverMobile)&&(identical(other.typeCar, typeCar) || other.typeCar == typeCar)&&(identical(other.pelak, pelak) || other.pelak == pelak)&&(identical(other.clearanceCode, clearanceCode) || other.clearanceCode == clearanceCode)&&(identical(other.numberOfCarcasses, numberOfCarcasses) || other.numberOfCarcasses == numberOfCarcasses)&&(identical(other.weightOfCarcasses, weightOfCarcasses) || other.weightOfCarcasses == weightOfCarcasses)&&(identical(other.date, date) || other.date == date)&&(identical(other.temporaryTrash, temporaryTrash) || other.temporaryTrash == temporaryTrash)&&(identical(other.temporaryDeleted, temporaryDeleted) || other.temporaryDeleted == temporaryDeleted)&&(identical(other.createdBy, createdBy) || other.createdBy == createdBy)&&(identical(other.modifiedBy, modifiedBy) || other.modifiedBy == modifiedBy)&&(identical(other.quota, quota) || other.quota == quota)&&(identical(other.saleType, saleType) || other.saleType == saleType)&&(identical(other.productionDate, productionDate) || other.productionDate == productionDate)&&const DeepCollectionEquality().equals(other.steward, steward)&&const DeepCollectionEquality().equals(other.guild, guild)&&const DeepCollectionEquality().equals(other.product, product)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is StewardFreeSaleBar&&(identical(other.id, id) || other.id == id)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.key, key) || other.key == key)&&(identical(other.createDate, createDate) || other.createDate == createDate)&&(identical(other.modifyDate, modifyDate) || other.modifyDate == modifyDate)&&(identical(other.trash, trash) || other.trash == trash)&&(identical(other.buyerName, buyerName) || other.buyerName == buyerName)&&(identical(other.buyerMobile, buyerMobile) || other.buyerMobile == buyerMobile)&&(identical(other.province, province) || other.province == province)&&(identical(other.city, city) || other.city == city)&&(identical(other.driverName, driverName) || other.driverName == driverName)&&(identical(other.driverMobile, driverMobile) || other.driverMobile == driverMobile)&&(identical(other.typeCar, typeCar) || other.typeCar == typeCar)&&(identical(other.pelak, pelak) || other.pelak == pelak)&&(identical(other.clearanceCode, clearanceCode) || other.clearanceCode == clearanceCode)&&(identical(other.numberOfCarcasses, numberOfCarcasses) || other.numberOfCarcasses == numberOfCarcasses)&&(identical(other.weightOfCarcasses, weightOfCarcasses) || other.weightOfCarcasses == weightOfCarcasses)&&(identical(other.date, date) || other.date == date)&&(identical(other.temporaryTrash, temporaryTrash) || other.temporaryTrash == temporaryTrash)&&(identical(other.temporaryDeleted, temporaryDeleted) || other.temporaryDeleted == temporaryDeleted)&&(identical(other.registerCode, registerCode) || other.registerCode == registerCode)&&(identical(other.createdBy, createdBy) || other.createdBy == createdBy)&&(identical(other.modifiedBy, modifiedBy) || other.modifiedBy == modifiedBy)&&(identical(other.quota, quota) || other.quota == quota)&&(identical(other.saleType, saleType) || other.saleType == saleType)&&(identical(other.productionDate, productionDate) || other.productionDate == productionDate)&&const DeepCollectionEquality().equals(other.steward, steward)&&const DeepCollectionEquality().equals(other.guild, guild)&&const DeepCollectionEquality().equals(other.product, product)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hashAll([runtimeType,id,buyer,key,createDate,modifyDate,trash,buyerName,buyerMobile,province,city,driverName,driverMobile,typeCar,pelak,clearanceCode,numberOfCarcasses,weightOfCarcasses,date,temporaryTrash,temporaryDeleted,createdBy,modifiedBy,quota,saleType,productionDate,const DeepCollectionEquality().hash(steward),const DeepCollectionEquality().hash(guild),const DeepCollectionEquality().hash(product)]); +int get hashCode => Object.hashAll([runtimeType,id,buyer,key,createDate,modifyDate,trash,buyerName,buyerMobile,province,city,driverName,driverMobile,typeCar,pelak,clearanceCode,numberOfCarcasses,weightOfCarcasses,date,temporaryTrash,temporaryDeleted,registerCode,createdBy,modifiedBy,quota,saleType,productionDate,const DeepCollectionEquality().hash(steward),const DeepCollectionEquality().hash(guild),const DeepCollectionEquality().hash(product)]); @override String toString() { - return 'StewardFreeSaleBar(id: $id, buyer: $buyer, key: $key, createDate: $createDate, modifyDate: $modifyDate, trash: $trash, buyerName: $buyerName, buyerMobile: $buyerMobile, province: $province, city: $city, driverName: $driverName, driverMobile: $driverMobile, typeCar: $typeCar, pelak: $pelak, clearanceCode: $clearanceCode, numberOfCarcasses: $numberOfCarcasses, weightOfCarcasses: $weightOfCarcasses, date: $date, temporaryTrash: $temporaryTrash, temporaryDeleted: $temporaryDeleted, createdBy: $createdBy, modifiedBy: $modifiedBy, quota: $quota, saleType: $saleType, productionDate: $productionDate, steward: $steward, guild: $guild, product: $product)'; + return 'StewardFreeSaleBar(id: $id, buyer: $buyer, key: $key, createDate: $createDate, modifyDate: $modifyDate, trash: $trash, buyerName: $buyerName, buyerMobile: $buyerMobile, province: $province, city: $city, driverName: $driverName, driverMobile: $driverMobile, typeCar: $typeCar, pelak: $pelak, clearanceCode: $clearanceCode, numberOfCarcasses: $numberOfCarcasses, weightOfCarcasses: $weightOfCarcasses, date: $date, temporaryTrash: $temporaryTrash, temporaryDeleted: $temporaryDeleted, registerCode: $registerCode, createdBy: $createdBy, modifiedBy: $modifiedBy, quota: $quota, saleType: $saleType, productionDate: $productionDate, steward: $steward, guild: $guild, product: $product)'; } @@ -48,7 +48,7 @@ abstract mixin class $StewardFreeSaleBarCopyWith<$Res> { factory $StewardFreeSaleBarCopyWith(StewardFreeSaleBar value, $Res Function(StewardFreeSaleBar) _then) = _$StewardFreeSaleBarCopyWithImpl; @useResult $Res call({ - int? id, Buyer? buyer, String? key, String? createDate, String? modifyDate, bool? trash, String? buyerName, String? buyerMobile, String? province, String? city, String? driverName, String? driverMobile, String? typeCar, String? pelak, String? clearanceCode, int? numberOfCarcasses, double? weightOfCarcasses, String? date, bool? temporaryTrash, bool? temporaryDeleted, String? createdBy, String? modifiedBy, String? quota, String? saleType, String? productionDate, dynamic steward, dynamic guild, dynamic product + int? id, Buyer? buyer, String? key, String? createDate, String? modifyDate, bool? trash, String? buyerName, String? buyerMobile, String? province, String? city, String? driverName, String? driverMobile, String? typeCar, String? pelak, String? clearanceCode, int? numberOfCarcasses, double? weightOfCarcasses, String? date, bool? temporaryTrash, bool? temporaryDeleted, String? registerCode, String? createdBy, String? modifiedBy, String? quota, String? saleType, String? productionDate, dynamic steward, dynamic guild, dynamic product }); @@ -65,7 +65,7 @@ class _$StewardFreeSaleBarCopyWithImpl<$Res> /// Create a copy of StewardFreeSaleBar /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? buyer = freezed,Object? key = freezed,Object? createDate = freezed,Object? modifyDate = freezed,Object? trash = freezed,Object? buyerName = freezed,Object? buyerMobile = freezed,Object? province = freezed,Object? city = freezed,Object? driverName = freezed,Object? driverMobile = freezed,Object? typeCar = freezed,Object? pelak = freezed,Object? clearanceCode = freezed,Object? numberOfCarcasses = freezed,Object? weightOfCarcasses = freezed,Object? date = freezed,Object? temporaryTrash = freezed,Object? temporaryDeleted = freezed,Object? createdBy = freezed,Object? modifiedBy = freezed,Object? quota = freezed,Object? saleType = freezed,Object? productionDate = freezed,Object? steward = freezed,Object? guild = freezed,Object? product = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? buyer = freezed,Object? key = freezed,Object? createDate = freezed,Object? modifyDate = freezed,Object? trash = freezed,Object? buyerName = freezed,Object? buyerMobile = freezed,Object? province = freezed,Object? city = freezed,Object? driverName = freezed,Object? driverMobile = freezed,Object? typeCar = freezed,Object? pelak = freezed,Object? clearanceCode = freezed,Object? numberOfCarcasses = freezed,Object? weightOfCarcasses = freezed,Object? date = freezed,Object? temporaryTrash = freezed,Object? temporaryDeleted = freezed,Object? registerCode = freezed,Object? createdBy = freezed,Object? modifiedBy = freezed,Object? quota = freezed,Object? saleType = freezed,Object? productionDate = freezed,Object? steward = freezed,Object? guild = freezed,Object? product = freezed,}) { return _then(_self.copyWith( id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable @@ -87,7 +87,8 @@ as int?,weightOfCarcasses: freezed == weightOfCarcasses ? _self.weightOfCarcasse as double?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable as String?,temporaryTrash: freezed == temporaryTrash ? _self.temporaryTrash : temporaryTrash // ignore: cast_nullable_to_non_nullable as bool?,temporaryDeleted: freezed == temporaryDeleted ? _self.temporaryDeleted : temporaryDeleted // ignore: cast_nullable_to_non_nullable -as bool?,createdBy: freezed == createdBy ? _self.createdBy : createdBy // ignore: cast_nullable_to_non_nullable +as bool?,registerCode: freezed == registerCode ? _self.registerCode : registerCode // ignore: cast_nullable_to_non_nullable +as String?,createdBy: freezed == createdBy ? _self.createdBy : createdBy // ignore: cast_nullable_to_non_nullable as String?,modifiedBy: freezed == modifiedBy ? _self.modifiedBy : modifiedBy // ignore: cast_nullable_to_non_nullable as String?,quota: freezed == quota ? _self.quota : quota // ignore: cast_nullable_to_non_nullable as String?,saleType: freezed == saleType ? _self.saleType : saleType // ignore: cast_nullable_to_non_nullable @@ -192,10 +193,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( int? id, Buyer? buyer, String? key, String? createDate, String? modifyDate, bool? trash, String? buyerName, String? buyerMobile, String? province, String? city, String? driverName, String? driverMobile, String? typeCar, String? pelak, String? clearanceCode, int? numberOfCarcasses, double? weightOfCarcasses, String? date, bool? temporaryTrash, bool? temporaryDeleted, String? createdBy, String? modifiedBy, String? quota, String? saleType, String? productionDate, dynamic steward, dynamic guild, dynamic product)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( int? id, Buyer? buyer, String? key, String? createDate, String? modifyDate, bool? trash, String? buyerName, String? buyerMobile, String? province, String? city, String? driverName, String? driverMobile, String? typeCar, String? pelak, String? clearanceCode, int? numberOfCarcasses, double? weightOfCarcasses, String? date, bool? temporaryTrash, bool? temporaryDeleted, String? registerCode, String? createdBy, String? modifiedBy, String? quota, String? saleType, String? productionDate, dynamic steward, dynamic guild, dynamic product)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _StewardFreeSaleBar() when $default != null: -return $default(_that.id,_that.buyer,_that.key,_that.createDate,_that.modifyDate,_that.trash,_that.buyerName,_that.buyerMobile,_that.province,_that.city,_that.driverName,_that.driverMobile,_that.typeCar,_that.pelak,_that.clearanceCode,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.temporaryTrash,_that.temporaryDeleted,_that.createdBy,_that.modifiedBy,_that.quota,_that.saleType,_that.productionDate,_that.steward,_that.guild,_that.product);case _: +return $default(_that.id,_that.buyer,_that.key,_that.createDate,_that.modifyDate,_that.trash,_that.buyerName,_that.buyerMobile,_that.province,_that.city,_that.driverName,_that.driverMobile,_that.typeCar,_that.pelak,_that.clearanceCode,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.temporaryTrash,_that.temporaryDeleted,_that.registerCode,_that.createdBy,_that.modifiedBy,_that.quota,_that.saleType,_that.productionDate,_that.steward,_that.guild,_that.product);case _: return orElse(); } @@ -213,10 +214,10 @@ return $default(_that.id,_that.buyer,_that.key,_that.createDate,_that.modifyDate /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( int? id, Buyer? buyer, String? key, String? createDate, String? modifyDate, bool? trash, String? buyerName, String? buyerMobile, String? province, String? city, String? driverName, String? driverMobile, String? typeCar, String? pelak, String? clearanceCode, int? numberOfCarcasses, double? weightOfCarcasses, String? date, bool? temporaryTrash, bool? temporaryDeleted, String? createdBy, String? modifiedBy, String? quota, String? saleType, String? productionDate, dynamic steward, dynamic guild, dynamic product) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( int? id, Buyer? buyer, String? key, String? createDate, String? modifyDate, bool? trash, String? buyerName, String? buyerMobile, String? province, String? city, String? driverName, String? driverMobile, String? typeCar, String? pelak, String? clearanceCode, int? numberOfCarcasses, double? weightOfCarcasses, String? date, bool? temporaryTrash, bool? temporaryDeleted, String? registerCode, String? createdBy, String? modifiedBy, String? quota, String? saleType, String? productionDate, dynamic steward, dynamic guild, dynamic product) $default,) {final _that = this; switch (_that) { case _StewardFreeSaleBar(): -return $default(_that.id,_that.buyer,_that.key,_that.createDate,_that.modifyDate,_that.trash,_that.buyerName,_that.buyerMobile,_that.province,_that.city,_that.driverName,_that.driverMobile,_that.typeCar,_that.pelak,_that.clearanceCode,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.temporaryTrash,_that.temporaryDeleted,_that.createdBy,_that.modifiedBy,_that.quota,_that.saleType,_that.productionDate,_that.steward,_that.guild,_that.product);case _: +return $default(_that.id,_that.buyer,_that.key,_that.createDate,_that.modifyDate,_that.trash,_that.buyerName,_that.buyerMobile,_that.province,_that.city,_that.driverName,_that.driverMobile,_that.typeCar,_that.pelak,_that.clearanceCode,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.temporaryTrash,_that.temporaryDeleted,_that.registerCode,_that.createdBy,_that.modifiedBy,_that.quota,_that.saleType,_that.productionDate,_that.steward,_that.guild,_that.product);case _: throw StateError('Unexpected subclass'); } @@ -233,10 +234,10 @@ return $default(_that.id,_that.buyer,_that.key,_that.createDate,_that.modifyDate /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( int? id, Buyer? buyer, String? key, String? createDate, String? modifyDate, bool? trash, String? buyerName, String? buyerMobile, String? province, String? city, String? driverName, String? driverMobile, String? typeCar, String? pelak, String? clearanceCode, int? numberOfCarcasses, double? weightOfCarcasses, String? date, bool? temporaryTrash, bool? temporaryDeleted, String? createdBy, String? modifiedBy, String? quota, String? saleType, String? productionDate, dynamic steward, dynamic guild, dynamic product)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( int? id, Buyer? buyer, String? key, String? createDate, String? modifyDate, bool? trash, String? buyerName, String? buyerMobile, String? province, String? city, String? driverName, String? driverMobile, String? typeCar, String? pelak, String? clearanceCode, int? numberOfCarcasses, double? weightOfCarcasses, String? date, bool? temporaryTrash, bool? temporaryDeleted, String? registerCode, String? createdBy, String? modifiedBy, String? quota, String? saleType, String? productionDate, dynamic steward, dynamic guild, dynamic product)? $default,) {final _that = this; switch (_that) { case _StewardFreeSaleBar() when $default != null: -return $default(_that.id,_that.buyer,_that.key,_that.createDate,_that.modifyDate,_that.trash,_that.buyerName,_that.buyerMobile,_that.province,_that.city,_that.driverName,_that.driverMobile,_that.typeCar,_that.pelak,_that.clearanceCode,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.temporaryTrash,_that.temporaryDeleted,_that.createdBy,_that.modifiedBy,_that.quota,_that.saleType,_that.productionDate,_that.steward,_that.guild,_that.product);case _: +return $default(_that.id,_that.buyer,_that.key,_that.createDate,_that.modifyDate,_that.trash,_that.buyerName,_that.buyerMobile,_that.province,_that.city,_that.driverName,_that.driverMobile,_that.typeCar,_that.pelak,_that.clearanceCode,_that.numberOfCarcasses,_that.weightOfCarcasses,_that.date,_that.temporaryTrash,_that.temporaryDeleted,_that.registerCode,_that.createdBy,_that.modifiedBy,_that.quota,_that.saleType,_that.productionDate,_that.steward,_that.guild,_that.product);case _: return null; } @@ -248,7 +249,7 @@ return $default(_that.id,_that.buyer,_that.key,_that.createDate,_that.modifyDate @JsonSerializable() class _StewardFreeSaleBar implements StewardFreeSaleBar { - const _StewardFreeSaleBar({this.id, this.buyer, this.key, this.createDate, this.modifyDate, this.trash, this.buyerName, this.buyerMobile, this.province, this.city, this.driverName, this.driverMobile, this.typeCar, this.pelak, this.clearanceCode, this.numberOfCarcasses, this.weightOfCarcasses, this.date, this.temporaryTrash, this.temporaryDeleted, this.createdBy, this.modifiedBy, this.quota, this.saleType, this.productionDate, this.steward, this.guild, this.product}); + const _StewardFreeSaleBar({this.id, this.buyer, this.key, this.createDate, this.modifyDate, this.trash, this.buyerName, this.buyerMobile, this.province, this.city, this.driverName, this.driverMobile, this.typeCar, this.pelak, this.clearanceCode, this.numberOfCarcasses, this.weightOfCarcasses, this.date, this.temporaryTrash, this.temporaryDeleted, this.registerCode, this.createdBy, this.modifiedBy, this.quota, this.saleType, this.productionDate, this.steward, this.guild, this.product}); factory _StewardFreeSaleBar.fromJson(Map json) => _$StewardFreeSaleBarFromJson(json); @override final int? id; @@ -271,6 +272,7 @@ class _StewardFreeSaleBar implements StewardFreeSaleBar { @override final String? date; @override final bool? temporaryTrash; @override final bool? temporaryDeleted; +@override final String? registerCode; @override final String? createdBy; @override final String? modifiedBy; @override final String? quota; @@ -293,16 +295,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _StewardFreeSaleBar&&(identical(other.id, id) || other.id == id)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.key, key) || other.key == key)&&(identical(other.createDate, createDate) || other.createDate == createDate)&&(identical(other.modifyDate, modifyDate) || other.modifyDate == modifyDate)&&(identical(other.trash, trash) || other.trash == trash)&&(identical(other.buyerName, buyerName) || other.buyerName == buyerName)&&(identical(other.buyerMobile, buyerMobile) || other.buyerMobile == buyerMobile)&&(identical(other.province, province) || other.province == province)&&(identical(other.city, city) || other.city == city)&&(identical(other.driverName, driverName) || other.driverName == driverName)&&(identical(other.driverMobile, driverMobile) || other.driverMobile == driverMobile)&&(identical(other.typeCar, typeCar) || other.typeCar == typeCar)&&(identical(other.pelak, pelak) || other.pelak == pelak)&&(identical(other.clearanceCode, clearanceCode) || other.clearanceCode == clearanceCode)&&(identical(other.numberOfCarcasses, numberOfCarcasses) || other.numberOfCarcasses == numberOfCarcasses)&&(identical(other.weightOfCarcasses, weightOfCarcasses) || other.weightOfCarcasses == weightOfCarcasses)&&(identical(other.date, date) || other.date == date)&&(identical(other.temporaryTrash, temporaryTrash) || other.temporaryTrash == temporaryTrash)&&(identical(other.temporaryDeleted, temporaryDeleted) || other.temporaryDeleted == temporaryDeleted)&&(identical(other.createdBy, createdBy) || other.createdBy == createdBy)&&(identical(other.modifiedBy, modifiedBy) || other.modifiedBy == modifiedBy)&&(identical(other.quota, quota) || other.quota == quota)&&(identical(other.saleType, saleType) || other.saleType == saleType)&&(identical(other.productionDate, productionDate) || other.productionDate == productionDate)&&const DeepCollectionEquality().equals(other.steward, steward)&&const DeepCollectionEquality().equals(other.guild, guild)&&const DeepCollectionEquality().equals(other.product, product)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _StewardFreeSaleBar&&(identical(other.id, id) || other.id == id)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.key, key) || other.key == key)&&(identical(other.createDate, createDate) || other.createDate == createDate)&&(identical(other.modifyDate, modifyDate) || other.modifyDate == modifyDate)&&(identical(other.trash, trash) || other.trash == trash)&&(identical(other.buyerName, buyerName) || other.buyerName == buyerName)&&(identical(other.buyerMobile, buyerMobile) || other.buyerMobile == buyerMobile)&&(identical(other.province, province) || other.province == province)&&(identical(other.city, city) || other.city == city)&&(identical(other.driverName, driverName) || other.driverName == driverName)&&(identical(other.driverMobile, driverMobile) || other.driverMobile == driverMobile)&&(identical(other.typeCar, typeCar) || other.typeCar == typeCar)&&(identical(other.pelak, pelak) || other.pelak == pelak)&&(identical(other.clearanceCode, clearanceCode) || other.clearanceCode == clearanceCode)&&(identical(other.numberOfCarcasses, numberOfCarcasses) || other.numberOfCarcasses == numberOfCarcasses)&&(identical(other.weightOfCarcasses, weightOfCarcasses) || other.weightOfCarcasses == weightOfCarcasses)&&(identical(other.date, date) || other.date == date)&&(identical(other.temporaryTrash, temporaryTrash) || other.temporaryTrash == temporaryTrash)&&(identical(other.temporaryDeleted, temporaryDeleted) || other.temporaryDeleted == temporaryDeleted)&&(identical(other.registerCode, registerCode) || other.registerCode == registerCode)&&(identical(other.createdBy, createdBy) || other.createdBy == createdBy)&&(identical(other.modifiedBy, modifiedBy) || other.modifiedBy == modifiedBy)&&(identical(other.quota, quota) || other.quota == quota)&&(identical(other.saleType, saleType) || other.saleType == saleType)&&(identical(other.productionDate, productionDate) || other.productionDate == productionDate)&&const DeepCollectionEquality().equals(other.steward, steward)&&const DeepCollectionEquality().equals(other.guild, guild)&&const DeepCollectionEquality().equals(other.product, product)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hashAll([runtimeType,id,buyer,key,createDate,modifyDate,trash,buyerName,buyerMobile,province,city,driverName,driverMobile,typeCar,pelak,clearanceCode,numberOfCarcasses,weightOfCarcasses,date,temporaryTrash,temporaryDeleted,createdBy,modifiedBy,quota,saleType,productionDate,const DeepCollectionEquality().hash(steward),const DeepCollectionEquality().hash(guild),const DeepCollectionEquality().hash(product)]); +int get hashCode => Object.hashAll([runtimeType,id,buyer,key,createDate,modifyDate,trash,buyerName,buyerMobile,province,city,driverName,driverMobile,typeCar,pelak,clearanceCode,numberOfCarcasses,weightOfCarcasses,date,temporaryTrash,temporaryDeleted,registerCode,createdBy,modifiedBy,quota,saleType,productionDate,const DeepCollectionEquality().hash(steward),const DeepCollectionEquality().hash(guild),const DeepCollectionEquality().hash(product)]); @override String toString() { - return 'StewardFreeSaleBar(id: $id, buyer: $buyer, key: $key, createDate: $createDate, modifyDate: $modifyDate, trash: $trash, buyerName: $buyerName, buyerMobile: $buyerMobile, province: $province, city: $city, driverName: $driverName, driverMobile: $driverMobile, typeCar: $typeCar, pelak: $pelak, clearanceCode: $clearanceCode, numberOfCarcasses: $numberOfCarcasses, weightOfCarcasses: $weightOfCarcasses, date: $date, temporaryTrash: $temporaryTrash, temporaryDeleted: $temporaryDeleted, createdBy: $createdBy, modifiedBy: $modifiedBy, quota: $quota, saleType: $saleType, productionDate: $productionDate, steward: $steward, guild: $guild, product: $product)'; + return 'StewardFreeSaleBar(id: $id, buyer: $buyer, key: $key, createDate: $createDate, modifyDate: $modifyDate, trash: $trash, buyerName: $buyerName, buyerMobile: $buyerMobile, province: $province, city: $city, driverName: $driverName, driverMobile: $driverMobile, typeCar: $typeCar, pelak: $pelak, clearanceCode: $clearanceCode, numberOfCarcasses: $numberOfCarcasses, weightOfCarcasses: $weightOfCarcasses, date: $date, temporaryTrash: $temporaryTrash, temporaryDeleted: $temporaryDeleted, registerCode: $registerCode, createdBy: $createdBy, modifiedBy: $modifiedBy, quota: $quota, saleType: $saleType, productionDate: $productionDate, steward: $steward, guild: $guild, product: $product)'; } @@ -313,7 +315,7 @@ abstract mixin class _$StewardFreeSaleBarCopyWith<$Res> implements $StewardFreeS factory _$StewardFreeSaleBarCopyWith(_StewardFreeSaleBar value, $Res Function(_StewardFreeSaleBar) _then) = __$StewardFreeSaleBarCopyWithImpl; @override @useResult $Res call({ - int? id, Buyer? buyer, String? key, String? createDate, String? modifyDate, bool? trash, String? buyerName, String? buyerMobile, String? province, String? city, String? driverName, String? driverMobile, String? typeCar, String? pelak, String? clearanceCode, int? numberOfCarcasses, double? weightOfCarcasses, String? date, bool? temporaryTrash, bool? temporaryDeleted, String? createdBy, String? modifiedBy, String? quota, String? saleType, String? productionDate, dynamic steward, dynamic guild, dynamic product + int? id, Buyer? buyer, String? key, String? createDate, String? modifyDate, bool? trash, String? buyerName, String? buyerMobile, String? province, String? city, String? driverName, String? driverMobile, String? typeCar, String? pelak, String? clearanceCode, int? numberOfCarcasses, double? weightOfCarcasses, String? date, bool? temporaryTrash, bool? temporaryDeleted, String? registerCode, String? createdBy, String? modifiedBy, String? quota, String? saleType, String? productionDate, dynamic steward, dynamic guild, dynamic product }); @@ -330,7 +332,7 @@ class __$StewardFreeSaleBarCopyWithImpl<$Res> /// Create a copy of StewardFreeSaleBar /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? buyer = freezed,Object? key = freezed,Object? createDate = freezed,Object? modifyDate = freezed,Object? trash = freezed,Object? buyerName = freezed,Object? buyerMobile = freezed,Object? province = freezed,Object? city = freezed,Object? driverName = freezed,Object? driverMobile = freezed,Object? typeCar = freezed,Object? pelak = freezed,Object? clearanceCode = freezed,Object? numberOfCarcasses = freezed,Object? weightOfCarcasses = freezed,Object? date = freezed,Object? temporaryTrash = freezed,Object? temporaryDeleted = freezed,Object? createdBy = freezed,Object? modifiedBy = freezed,Object? quota = freezed,Object? saleType = freezed,Object? productionDate = freezed,Object? steward = freezed,Object? guild = freezed,Object? product = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? buyer = freezed,Object? key = freezed,Object? createDate = freezed,Object? modifyDate = freezed,Object? trash = freezed,Object? buyerName = freezed,Object? buyerMobile = freezed,Object? province = freezed,Object? city = freezed,Object? driverName = freezed,Object? driverMobile = freezed,Object? typeCar = freezed,Object? pelak = freezed,Object? clearanceCode = freezed,Object? numberOfCarcasses = freezed,Object? weightOfCarcasses = freezed,Object? date = freezed,Object? temporaryTrash = freezed,Object? temporaryDeleted = freezed,Object? registerCode = freezed,Object? createdBy = freezed,Object? modifiedBy = freezed,Object? quota = freezed,Object? saleType = freezed,Object? productionDate = freezed,Object? steward = freezed,Object? guild = freezed,Object? product = freezed,}) { return _then(_StewardFreeSaleBar( id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable @@ -352,7 +354,8 @@ as int?,weightOfCarcasses: freezed == weightOfCarcasses ? _self.weightOfCarcasse as double?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable as String?,temporaryTrash: freezed == temporaryTrash ? _self.temporaryTrash : temporaryTrash // ignore: cast_nullable_to_non_nullable as bool?,temporaryDeleted: freezed == temporaryDeleted ? _self.temporaryDeleted : temporaryDeleted // ignore: cast_nullable_to_non_nullable -as bool?,createdBy: freezed == createdBy ? _self.createdBy : createdBy // ignore: cast_nullable_to_non_nullable +as bool?,registerCode: freezed == registerCode ? _self.registerCode : registerCode // ignore: cast_nullable_to_non_nullable +as String?,createdBy: freezed == createdBy ? _self.createdBy : createdBy // ignore: cast_nullable_to_non_nullable as String?,modifiedBy: freezed == modifiedBy ? _self.modifiedBy : modifiedBy // ignore: cast_nullable_to_non_nullable as String?,quota: freezed == quota ? _self.quota : quota // ignore: cast_nullable_to_non_nullable as String?,saleType: freezed == saleType ? _self.saleType : saleType // ignore: cast_nullable_to_non_nullable diff --git a/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.g.dart b/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.g.dart index 65e4c20..f360836 100644 --- a/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.g.dart +++ b/packages/chicken/lib/data/models/response/steward_free_sale_bar/steward_free_sale_bar.g.dart @@ -30,6 +30,7 @@ _StewardFreeSaleBar _$StewardFreeSaleBarFromJson(Map json) => date: json['date'] as String?, temporaryTrash: json['temporary_trash'] as bool?, temporaryDeleted: json['temporary_deleted'] as bool?, + registerCode: json['register_code'] as String?, createdBy: json['created_by'] as String?, modifiedBy: json['modified_by'] as String?, quota: json['quota'] as String?, @@ -62,6 +63,7 @@ Map _$StewardFreeSaleBarToJson(_StewardFreeSaleBar instance) => 'date': instance.date, 'temporary_trash': instance.temporaryTrash, 'temporary_deleted': instance.temporaryDeleted, + 'register_code': instance.registerCode, 'created_by': instance.createdBy, 'modified_by': instance.modifiedBy, 'quota': instance.quota, diff --git a/packages/chicken/lib/presentation/pages/steward/home/view.dart b/packages/chicken/lib/presentation/pages/steward/home/view.dart index 4d69733..a451c90 100644 --- a/packages/chicken/lib/presentation/pages/steward/home/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/home/view.dart @@ -5,7 +5,6 @@ import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_in import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; import 'package:rasadyar_chicken/presentation/widget/steward/widely_used/view.dart'; import 'package:rasadyar_core/core.dart'; -import 'package:rasadyar_core/presentation/widget/error_widget.dart'; import 'logic.dart'; @@ -441,7 +440,6 @@ class HomePage extends GetView { isLoading: data.value == null, description: data.value?.totalGovernmentalRemainWeight?.separatedByCommaFa ?? '0', iconPath: Assets.vec.cubeCardGovermentSvg.path, - iconColor: AppColor.textColor, bgDescriptionColor: const Color(0xFFF5ECEE), bgLabelColor: const Color(0xFFDEC1C7), diff --git a/packages/chicken/lib/presentation/pages/steward/sales_in_province/logic.dart b/packages/chicken/lib/presentation/pages/steward/sales_in_province/logic.dart index b2fd3dd..3958640 100644 --- a/packages/chicken/lib/presentation/pages/steward/sales_in_province/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/sales_in_province/logic.dart @@ -60,6 +60,7 @@ class SalesInProvinceLogic extends GetxController { SubmitStewardAllocation? tmpStewardAllocation; Rxn productionDate = Rxn(null); + Rxn remainingStock = Rxn(null); Map freeProductionDateData = {}; Map governmentalProductionDateData = {}; @@ -76,6 +77,11 @@ class SalesInProvinceLogic extends GetxController { getGuilds(); }); + ever(quotaType, (_) { + remainingStock.value = null; + productionDate.value = null; + }); + debounce(weight, time: Duration(milliseconds: 110), (callback) { totalCost.value = callback * pricePerKilo.value; }); @@ -275,7 +281,8 @@ class SalesInProvinceLogic extends GetxController { call: () async => await rootLogic.chickenRepository.getGuilds( token: rootLogic.tokenService.accessToken.value!, queryParameters: buildQueryParams( - queryParams: {'free': saleType.value == 2 ? true : false}, + //queryParams: {'free': saleType.value == 2 ? true : false}, + queryParams: {'all': true}, role: 'Steward', ), ), diff --git a/packages/chicken/lib/presentation/pages/steward/sales_in_province/view.dart b/packages/chicken/lib/presentation/pages/steward/sales_in_province/view.dart index db97283..3f46401 100644 --- a/packages/chicken/lib/presentation/pages/steward/sales_in_province/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/sales_in_province/view.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart'; -import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; -import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; +import 'package:rasadyar_chicken/presentation/pages/steward/sales_in_province/widgets/cu_sale_in_provience.dart'; import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart'; import 'package:rasadyar_chicken/presentation/utils/string_utils.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; @@ -78,7 +76,7 @@ class SalesInProvincePage extends GetView { RFab.add( onPressed: () { Get.bottomSheet( - addOrEditBottomSheet(), + addOrEditBottomSheet(controller), isScrollControlled: true, backgroundColor: Colors.transparent, ).whenComplete(() { @@ -367,7 +365,7 @@ class SalesInProvincePage extends GetView { onPressed: () { controller.setEditData(item); Get.bottomSheet( - addOrEditBottomSheet(true), + addOrEditBottomSheet(controller, isEditMode: true), isScrollControlled: true, backgroundColor: Colors.transparent, ).whenComplete(() { @@ -402,472 +400,6 @@ class SalesInProvincePage extends GetView { ); } - Widget addOrEditBottomSheet([bool isEditMode = false]) { - return BaseBottomSheet( - height: Get.height * (isEditMode ? 0.60 : 0.75), - child: Form( - key: controller.formKey, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - '${isEditMode ? 'ویرایش' : 'ثبت'} توزیع/ فروش', - style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal), - ), - const SizedBox(height: 12), - productDropDown(), - const SizedBox(height: 12), - Visibility( - visible: isEditMode == false, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.darkGreyLight, width: 1), - ), - - child: Column( - children: [ - const SizedBox(height: 8), - SizedBox( - height: 40, - child: ObxValue((data) { - return RadioGroup( - groupValue: controller.saleType.value, - onChanged: (value) { - controller.saleType.value = value!; - controller.selectedGuildModel.value = null; - controller.selectedGuildModel.refresh(); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Row( - children: [ - Radio(value: 1), - Text('فروش اختصاصی', style: AppFonts.yekan14), - ], - ), - ), - - Expanded( - child: Row( - children: [ - Radio(value: 2), - Text('فروش آزاد', style: AppFonts.yekan14), - ], - ), - ), - ], - ), - ); - }, controller.saleType), - ), - const SizedBox(height: 12), - - guildsDropDown(), - ], - ), - ), - ), - const SizedBox(height: 12), - - Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.darkGreyLight, width: 1), - ), - child: Column( - spacing: 12, - children: [ - const SizedBox(height: 8), - ObxValue((data) { - return RTextField( - controller: TextEditingController(), - filledColor: AppColor.bgLight, - filled: true, - label: 'تاریخ', - onTap: () { - Get.bottomSheet( - modalDatePicker((value) { - controller.fromDateFilter.value = value; - controller.fromDateFilter.refresh(); - }), - ); - }, - borderColor: AppColor.darkGreyLight, - initText: (data.value ?? Jalali.now()).formatCompactDate(), - ); - }, controller.fromDateFilter), - - RTextField( - controller: controller.weightController, - keyboardType: TextInputType.number, - borderColor: AppColor.darkGreyLight, - filledColor: AppColor.bgLight, - filled: true, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - SeparatorInputFormatter(), - ], - validator: (value) { - if (int.parse(value!.clearComma) > - (controller.rootLogic.inventoryModel.value?.totalRemainWeight?.toInt() ?? - 100)) { - return 'وزن تخصیصی بیشتر از موجودی انبار است'; - } - return null; - }, - onChanged: (p0) { - controller.weight.value = int.tryParse(p0.clearComma) ?? 0; - }, - label: 'وزن لاشه (کیلوگرم)', - ), - - Visibility( - visible: isEditMode == false, - child: Column( - children: [ - SizedBox(height: 12), - Container( - height: 50.h, - clipBehavior: Clip.none, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.darkGreyLight, width: 1), - ), - child: Stack( - fit: StackFit.expand, - alignment: Alignment.center, - clipBehavior: Clip.none, - children: [ - Positioned( - child: Container(color: Colors.white, child: Text("نوع انبار")), - top: -10, - right: 8, - ), - Obx(() { - return RadioGroup( - groupValue: controller.quotaType.value, - onChanged: (value) { - controller.quotaType.value = value ?? 0; - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalGovernmentalRemainWeight ?? - -1) > - 0 - ? () { - controller.quotaType.value = 1; - } - : null, - child: Row( - children: [ - Radio( - value: 1, - enabled: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalGovernmentalRemainWeight ?? - -1) > - 0, - ), - Text( - 'انبار دولتی', - style: AppFonts.yekan14.copyWith( - color: - ((controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalGovernmentalRemainWeight ?? - -1) > - 0) - ? AppColor.textColor - : AppColor.labelTextColor, - ), - ), - ], - ), - ), - ), - - Expanded( - child: GestureDetector( - onTap: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalFreeRemainWeight ?? - -1) > - 0 - ? () { - controller.quotaType.value = 2; - } - : null, - child: Row( - children: [ - Radio( - value: 2, - enabled: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalFreeRemainWeight ?? - -1) > - 0, - ), - Text( - 'انبار آزاد', - style: AppFonts.yekan14.copyWith( - color: - ((controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalFreeRemainWeight ?? - -1) > - 0) - ? AppColor.textColor - : AppColor.labelTextColor, - ), - ), - ], - ), - ), - ), - ], - ), - ); - }), - ], - ), - ), - SizedBox(height: 12), - Container( - height: 58.h, - clipBehavior: Clip.none, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.darkGreyLight, width: 1), - ), - child: Stack( - fit: StackFit.expand, - alignment: Alignment.center, - clipBehavior: Clip.none, - children: [ - Positioned( - child: Container(color: Colors.white, child: Text("نوع فروش")), - top: -10, - right: 8, - ), - Obx(() { - return RadioGroup( - groupValue: controller.priceType.value, - onChanged: (value) { - controller.priceType.value = value!; - }, - child: Row( - children: [ - Expanded( - child: GestureDetector( - onTap: (controller.broadcastPrice.value?.active ?? false) - ? () { - controller.priceType.value = 1; - } - : null, - child: Row( - children: [ - Radio( - value: 1, - enabled: - controller.broadcastPrice.value?.active ?? - false, - ), - Text( - 'قیمت دولتی', - style: AppFonts.yekan14.copyWith( - color: - (controller.broadcastPrice.value?.active ?? - false) - ? AppColor.textColor - : AppColor.labelTextColor, - ), - ), - ], - ), - ), - ), - - Expanded( - child: GestureDetector( - onTap: () { - controller.priceType.value = 2; - }, - child: Row( - children: [ - Radio(value: 2), - Text('قیمت آزاد', style: AppFonts.yekan14), - ], - ), - ), - ), - ], - ), - ); - }), - ], - ), - ), - ], - ), - ), - Obx(() { - return MonthlyDataCalendar( - label: 'تاریخ تولید گوشت', - selectedDate: controller.productionDate.value?.formatCompactDate(), - onDateSelect: (value) { - controller.productionDate.value = value.date; - }, - dayData: controller.quotaType.value == 1 - ? controller.governmentalProductionDateData - : controller.freeProductionDateData, - ); - }), - RTextField( - variant: RTextFieldVariant.noBorder, - controller: controller.pricePerKiloController, - borderColor: AppColor.darkGreyLight, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - SeparatorInputFormatter(), - ], - filledColor: AppColor.bgLight, - filled: true, - enabled: - (controller.priceType.value == 2 || - (controller.selectedProductModel.value?.approvedPriceStatus == false)), - onChanged: (p0) { - controller.pricePerKilo.value = int.tryParse(p0.clearComma) ?? 0; - }, - keyboardType: TextInputType.number, - label: 'قیمت هر کیلو (ريال)', - ), - - RTextField( - variant: RTextFieldVariant.noBorder, - enabled: false, - keyboardType: TextInputType.number, - filledColor: AppColor.bgLight, - filled: true, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - SeparatorInputFormatter(), - ], - controller: controller.totalCostController, - label: 'هزینه کل (ريال)', - ), - ], - ), - ), - - SizedBox(height: 12.h), - ObxValue((data) { - return RElevated( - text: isEditMode ? 'ویرایش' : 'ثبت', - isFullWidth: true, - textStyle: AppFonts.yekan16.copyWith(color: Colors.white), - backgroundColor: AppColor.greenNormal, - height: 40, - enabled: data.value, - onPressed: isEditMode - ? () async { - await controller.updateAllocation(); - } - : () async { - await controller.submitAllocation(); - }, - ); - }, controller.isValid), - const SizedBox(height: 20), - ], - ), - ), - ); - } - - Widget guildsDropDown() { - return Obx(() { - final item = controller.selectedGuildModel.value; - return OverlayDropdownWidget( - key: ValueKey(item?.user?.fullname ?? ''), - items: controller.guildsModel, - onChanged: (value) { - controller.selectedGuildModel.value = value; - }, - selectedItem: item, - itemBuilder: (item) => Text( - item.user != null - ? '${item.steward == true ? 'مباشر' : 'صنف'} ${item.user!.fullname} (${item.user!.mobile})' - : 'بدون نام', - ), - labelBuilder: (item) => Text( - item?.user != null - ? '${item?.steward == true ? 'مباشر' : 'صنف'} ${item?.user!.fullname} (${item?.user!.mobile})' - : 'انتخاب مباشر/صنف', - ), - ); - }); - } - - Widget productDropDown() { - return Obx(() { - return OverlayDropdownWidget( - items: controller.rolesProductsModel, - height: 56, - hasDropIcon: false, - background: Colors.white, - onChanged: (value) { - controller.selectedProductModel.value = value; - }, - selectedItem: controller.selectedProductModel.value, - itemBuilder: (item) => Text(item.name ?? 'بدون نام'), - labelBuilder: (item) => Row( - spacing: 8, - children: [ - (item?.name?.contains('مرغ گرم') ?? false) - ? Assets.images.chicken.image(width: 40, height: 40) - : Assets.vec.placeHolderSvg.svg(width: 40, height: 40), - - Text(item?.name ?? 'انتخاب محصول'), - Spacer(), - Text( - 'موجودی:${controller.rootLogic.inventoryModel.value?.totalRemainWeight.separatedByCommaFa ?? 0}', - ), - ], - ), - ); - }); - } - Widget filterBottomSheet() { return BaseBottomSheet( height: 200, diff --git a/packages/chicken/lib/presentation/pages/steward/sales_in_province/widgets/cu_sale_in_provience.dart b/packages/chicken/lib/presentation/pages/steward/sales_in_province/widgets/cu_sale_in_provience.dart new file mode 100644 index 0000000..09bc2a5 --- /dev/null +++ b/packages/chicken/lib/presentation/pages/steward/sales_in_province/widgets/cu_sale_in_provience.dart @@ -0,0 +1,342 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; +import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; +import 'package:rasadyar_chicken/presentation/pages/steward/sales_in_province/logic.dart'; +import 'package:rasadyar_core/core.dart'; + +Widget addOrEditBottomSheet(SalesInProvinceLogic controller, {bool isEditMode = false}) { + return BaseBottomSheet( + height: Get.height * (isEditMode ? 0.60 : 0.75), + child: Form( + key: controller.formKey, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + '${isEditMode ? 'ویرایش' : 'ثبت'} توزیع/ فروش', + style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal), + ), + const SizedBox(height: 12), + productDropDown(controller), + const SizedBox(height: 12), + + Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.darkGreyLight, width: 1), + ), + child: Column( + spacing: 12, + children: [ + const SizedBox(height: 8), + RTextField( + controller: TextEditingController(), + filledColor: AppColor.bgLight, + label: 'تاریخ', + readonly: true, + borderColor: AppColor.darkGreyLight, + initText: Jalali.now().formatCompactDate(), + ), + + Visibility( + visible: isEditMode == false, + child: Container( + height: 50.h, + clipBehavior: Clip.none, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.darkGreyLight, width: 1), + ), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Positioned( + child: Container(color: Colors.white, child: Text("انبار")), + top: -10, + right: 8, + ), + Obx(() { + return RadioGroup( + groupValue: controller.quotaType.value, + onChanged: (value) { + controller.quotaType.value = value ?? 0; + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: GestureDetector( + onTap: () { + controller.quotaType.value = 1; + }, + child: Row( + children: [ + Radio(value: 1), + Text('دولتی', style: AppFonts.yekan14), + ], + ), + ), + ), + + Expanded( + child: GestureDetector( + onTap: () { + controller.quotaType.value = 2; + }, + child: Row( + children: [ + Radio(value: 2), + Text('آزاد', style: AppFonts.yekan14), + ], + ), + ), + ), + ], + ), + ); + }), + ], + ), + ), + ), + + Obx(() { + return MonthlyDataCalendar( + label: 'تاریخ تولید گوشت', + selectedDate: controller.productionDate.value?.formatCompactDate(), + onDateSelect: (value) { + controller.productionDate.value = value.date; + controller.remainingStock.value = value.remainingStock; + }, + dayData: controller.quotaType.value == 1 + ? controller.governmentalProductionDateData + : controller.freeProductionDateData, + ); + }), + + Visibility(visible: isEditMode == false, child: guildsDropDown(controller)), + + RTextField( + controller: controller.weightController, + keyboardType: TextInputType.number, + autoValidateMode: AutovalidateMode.onUserInteraction, + borderColor: AppColor.darkGreyLight, + filledColor: AppColor.bgLight, + filled: true, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + SeparatorInputFormatter(), + ], + validator: (value) { + if ((int.tryParse(value?.clearComma ?? '0') ?? 0) > + (controller.remainingStock.value ?? 0)) { + return 'وزن تخصیصی بیشتر از موجودی انبار است'; + } + return null; + }, + onChanged: (p0) { + controller.weight.value = int.tryParse(p0.clearComma) ?? 0; + }, + label: 'وزن لاشه (کیلوگرم)', + ), + + Visibility( + visible: isEditMode == false, + child: Container( + height: 58.h, + clipBehavior: Clip.none, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.darkGreyLight, width: 1), + ), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Positioned( + child: Container(color: Colors.white, child: Text("فروش")), + top: -10, + right: 8, + ), + Obx(() { + return RadioGroup( + groupValue: controller.priceType.value, + onChanged: (value) { + controller.priceType.value = value!; + }, + child: Row( + children: [ + Expanded( + child: GestureDetector( + onTap: (controller.broadcastPrice.value?.active ?? false) + ? () { + controller.priceType.value = 1; + } + : null, + child: Row( + children: [ + Radio( + value: 1, + enabled: controller.broadcastPrice.value?.active ?? false, + ), + Text( + 'قیمت مصوب', + style: AppFonts.yekan14.copyWith( + color: + (controller.broadcastPrice.value?.active ?? false) + ? AppColor.textColor + : AppColor.labelTextColor, + ), + ), + ], + ), + ), + ), + + Expanded( + child: GestureDetector( + onTap: () { + controller.priceType.value = 2; + }, + child: Row( + children: [ + Radio(value: 2), + Text('قیمت آزاد', style: AppFonts.yekan14), + ], + ), + ), + ), + ], + ), + ); + }), + ], + ), + ), + ), + + ObxValue((data) { + return RTextField( + variant: RTextFieldVariant.noBorder, + controller: controller.pricePerKiloController, + borderColor: AppColor.darkGreyLight, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + SeparatorInputFormatter(), + ], + filledColor: AppColor.bgLight, + filled: true, + readonly: data.value == 1, + onChanged: (p0) { + controller.pricePerKilo.value = int.tryParse(p0.clearComma) ?? 0; + }, + keyboardType: TextInputType.number, + label: 'قیمت هر کیلو (ريال)', + ); + }, controller.priceType), + + RTextField( + variant: RTextFieldVariant.noBorder, + enabled: false, + keyboardType: TextInputType.number, + filledColor: AppColor.bgLight, + filled: true, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + SeparatorInputFormatter(), + ], + controller: controller.totalCostController, + label: 'هزینه کل (ريال)', + ), + ], + ), + ), + + SizedBox(height: 12.h), + ObxValue((data) { + return RElevated( + text: isEditMode ? 'ویرایش' : 'ثبت', + isFullWidth: true, + textStyle: AppFonts.yekan16.copyWith(color: Colors.white), + backgroundColor: AppColor.greenNormal, + height: 40, + enabled: data.value, + onPressed: isEditMode + ? () async { + await controller.updateAllocation(); + } + : () async { + await controller.submitAllocation(); + }, + ); + }, controller.isValid), + const SizedBox(height: 20), + ], + ), + ), + ); +} + +Widget guildsDropDown(SalesInProvinceLogic controller) { + return Obx(() { + final item = controller.selectedGuildModel.value; + return OverlayDropdownWidget( + key: ValueKey(item?.user?.fullname ?? ''), + items: controller.guildsModel, + onChanged: (value) { + controller.selectedGuildModel.value = value; + }, + selectedItem: item, + itemBuilder: (item) => Text( + item.user != null + ? '${item.steward == true ? 'مباشر' : 'صنف'} ${item.user!.fullname} (${item.user!.mobile})' + : 'بدون نام', + ), + labelBuilder: (item) => Text( + item?.user != null + ? '${item?.steward == true ? 'مباشر' : 'صنف'} ${item?.user!.fullname} (${item?.user!.mobile})' + : 'انتخاب مباشر/صنف', + ), + ); + }); +} + +Widget productDropDown(SalesInProvinceLogic controller) { + return Obx(() { + return OverlayDropdownWidget( + items: controller.rolesProductsModel, + height: 56, + hasDropIcon: false, + background: Colors.white, + onChanged: (value) { + controller.selectedProductModel.value = value; + }, + selectedItem: controller.selectedProductModel.value, + itemBuilder: (item) => Text(item.name ?? 'بدون نام'), + labelBuilder: (item) => Row( + spacing: 8, + children: [ + (item?.name?.contains('مرغ گرم') ?? false) + ? Assets.images.chicken.image(width: 40, height: 40) + : Assets.vec.placeHolderSvg.svg(width: 40, height: 40), + + Text(item?.name ?? 'انتخاب محصول'), + + Spacer(), + + ObxValue((data) { + return Visibility(visible: data.value != null, child: Text('موجودی: $data')); + }, controller.remainingStock), + ], + ), + ); + }); +} diff --git a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/logic.dart b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/logic.dart index 6951b3c..7a272ab 100644 --- a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/logic.dart @@ -37,8 +37,15 @@ class SalesOutOfProvinceLogic extends GetxController { TextEditingController quarantineCodeController = TextEditingController(); TextEditingController saleWeightController = TextEditingController(); TextEditingController saleCountController = TextEditingController(); + TextEditingController pricePerKiloController = TextEditingController(); + TextEditingController totalCostController = TextEditingController(); + TextEditingController otpCodeSell = TextEditingController(); Rx saleDate = Jalali.now().obs; String? key; + RxInt pricePerKilo = 0.obs; + RxInt totalCost = 0.obs; + RxInt weight = 0.obs; + RxString otpCode = ''.obs; Rx>> salesList = Resource>.loading().obs; @@ -49,6 +56,7 @@ class SalesOutOfProvinceLogic extends GetxController { RxInt saleType = 2.obs; RxInt quotaType = 1.obs; Rxn productionDate = Rxn(); + Rxn remainingStock = Rxn(null); Map freeProductionDateData = {}; Map governmentalProductionDateData = {}; @@ -77,6 +85,17 @@ class SalesOutOfProvinceLogic extends GetxController { _updateGovernmentalProductionDateData(); _updateFreeProductionDateData(); }); + ever(quotaType, (_) { + remainingStock.value = null; + productionDate.value = null; + }); + debounce(pricePerKilo, time: Duration(milliseconds: 100), (callback) { + totalCost.value = callback * (weight.value); + }); + + ever(totalCost, (callback) { + totalCostController.text = callback.separatedByComma; + }); } void _updateGovernmentalProductionDateData() { @@ -153,7 +172,7 @@ class SalesOutOfProvinceLogic extends GetxController { quarantineCodeController.addListener(checkSalesFormValid); saleWeightController.addListener(() { checkSalesFormValid(); - var weight = int.parse(saleWeightController.text.clearComma); + weight.value = int.parse(saleWeightController.text.clearComma); var res = (weight / selectedProduct.value!.weightAverage!.toInt()).round(); saleCountController.text = res.separatedByComma; }); @@ -185,6 +204,8 @@ class SalesOutOfProvinceLogic extends GetxController { quotaType.value = item.quota == 'governmental' ? 1 : 2; isSaleSubmitButtonEnabled.value = true; productionDate.value = item.productionDate.toJalali; + pricePerKiloController.text = pricePerKilo.value.toString().separatedByComma; + totalCostController.text = totalCost.value.toString().separatedByComma; } Future deleteStewardPurchaseOutOfProvince(String key) async { @@ -268,6 +289,40 @@ class SalesOutOfProvinceLogic extends GetxController { return res; } + Future sendSaleOtpCode(StewardFreeSaleBar item) async { + StewardFreeSaleBarRequest requestBody = StewardFreeSaleBarRequest( + buyerKey: item.buyer?.key, + buyerName: item.buyer?.fullname, + buyerMobile: item.buyer?.mobile, + numberOfCarcasses: item.numberOfCarcasses, + weightOfCarcasses: item.weightOfCarcasses?.toInt(), + date: item.date, + clearanceCode: item.clearanceCode, + registerCode: otpCode.value, + saleType: item.saleType, + quota: item.quota, + role: "Steward", + key: item.key, + city: item.city, + province: item.province, + ); + await safeCall( + showError: true, + call: () => rootLogic.chickenRepository.updateOutProvinceStewardFreeBar( + token: rootLogic.tokenService.accessToken.value!, + body: requestBody, + ), + onSuccess: (_) { + onRefresh(); + Future.delayed( + Duration(seconds: 1), + () => defaultShowSuccessMessage("عملیات با موفقیت انجام شد"), + ); + Get.back(); + }, + ); + } + void resetSubmitForm() { selectedCity.value = null; diff --git a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/view.dart b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/view.dart index e7bae09..1d448f2 100644 --- a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/view.dart @@ -94,27 +94,6 @@ class SalesOutOfProvincePage extends GetView { ); } - /* Padding segmentWidget() { - return Padding( - padding: const EdgeInsets.fromLTRB(8, 0, 8, 8), - child: Row( - children: [ - Expanded( - child: RSegment( - children: ['فروش', 'خریداران'], - selectedIndex: controller.selectedSegmentIndex.value, - borderColor: const Color(0xFFB4B4B4), - selectedBorderColor: AppColor.blueNormal, - selectedBackgroundColor: AppColor.blueLight, - onSegmentSelected: (index) => controller.selectedSegmentIndex.value = index, - backgroundColor: AppColor.whiteGreyNormal, - ), - ), - ], - ), - ); - }*/ - Widget filterBottomSheet() => filterBottomSheetWidget( fromDate: controller.fromDateFilter, onChangedFromDate: (jalali) => controller.fromDateFilter.value = jalali, @@ -277,6 +256,32 @@ class SalesOutOfProvincePage extends GetView { valueLabel: 'قطعه', ), + item.registerCode == null + ? Row( + children: [ + Text( + 'کد احراز', + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), + ), + Spacer(), + RElevated( + width: 95.w, + height: 20.h, + textStyle: AppFonts.yekan12, + backgroundColor: AppColor.blueDarkHover, + text: 'ارسال کد', + onPressed: () { + Get.bottomSheet(bottomSendOtpSheetSellCode(item)).then((value) { + controller.otpCode.value = ''; + controller.otpCodeSell.clear(); + }); + }, + ), + ], + ) + : buildRow(title: 'کد احراز ', value: '${item.registerCode}'), + buildRow(title: 'کد قرنطینه ', value: item.clearanceCode ?? 'بدون کد'), + Row( mainAxisAlignment: MainAxisAlignment.center, spacing: 16.w, @@ -347,272 +352,102 @@ class SalesOutOfProvincePage extends GetView { child: Column( spacing: 12, children: [ - ObxValue((data) { - return RTextField( - controller: TextEditingController(), - filledColor: AppColor.bgLight, - filled: true, - label: 'تاریخ', - onTap: () { - Get.bottomSheet( - modalDatePicker((value) { - controller.saleDate.value = value; - controller.saleDate.refresh(); - }), - ); - }, - borderColor: AppColor.darkGreyLight, - initText: data.value.formatCompactDate(), - ); - }, controller.saleDate), - Visibility(visible: isOnEdit == false, child: _buyerWidget()), - RTextField( - controller: controller.quarantineCodeController, - label: 'کد قرنطینه', - borderColor: AppColor.darkGreyLight, + controller: TextEditingController(), filledColor: AppColor.bgLight, - filled: true, - validator: (value) { - if (value == null) { - return 'لطفاً کد قرنطینه را وارد کنید'; - } - return null; - }, + label: 'تاریخ', + readonly: true, + borderColor: AppColor.darkGreyLight, + initText: Jalali.now().formatCompactDate(), ), Visibility( visible: isOnEdit == false, - child: Column( - spacing: 12, - children: [ - Container( - height: 50.h, - clipBehavior: Clip.none, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.darkGreyLight, width: 1), + child: Container( + height: 50.h, + clipBehavior: Clip.none, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.darkGreyLight, width: 1), + ), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Positioned( + child: Container(color: Colors.white, child: Text("انبار")), + top: -10, + right: 8, ), - child: Stack( - fit: StackFit.expand, - alignment: Alignment.center, - clipBehavior: Clip.none, - children: [ - Positioned( - child: Container(color: Colors.white, child: Text("نوع انبار")), - top: -10, - right: 8, - ), - Obx(() { - return RadioGroup( - groupValue: controller.quotaType.value, - onChanged: (value) { - controller.quotaType.value = value ?? 0; - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalGovernmentalRemainWeight ?? - -1) > - 0 - ? () { - controller.quotaType.value = 1; - } - : null, - child: Row( - children: [ - Radio( - value: 1, - enabled: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalGovernmentalRemainWeight ?? - -1) > - 0, - ), - Text( - 'انبار دولتی', - style: AppFonts.yekan14.copyWith( - color: - ((controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalGovernmentalRemainWeight ?? - -1) > - 0) - ? AppColor.textColor - : AppColor.labelTextColor, - ), - ), - ], - ), - ), + Obx(() { + return RadioGroup( + groupValue: controller.quotaType.value, + onChanged: (value) { + controller.quotaType.value = value ?? 0; + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: GestureDetector( + onTap: () { + controller.quotaType.value = 1; + }, + child: Row( + children: [ + Radio(value: 1), + Text('دولتی', style: AppFonts.yekan14), + ], ), - - Expanded( - child: GestureDetector( - onTap: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalFreeRemainWeight ?? - -1) > - 0 - ? () { - controller.quotaType.value = 2; - } - : null, - child: Row( - children: [ - Radio( - value: 2, - enabled: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalFreeRemainWeight ?? - -1) > - 0, - ), - Text( - 'انبار آزاد', - style: AppFonts.yekan14.copyWith( - color: - ((controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalFreeRemainWeight ?? - -1) > - 0) - ? AppColor.textColor - : AppColor.labelTextColor, - ), - ), - ], - ), - ), - ), - ], + ), ), - ); - }), - ], - ), - ), - Container( - height: 50.h, - clipBehavior: Clip.none, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.darkGreyLight, width: 1), - ), - child: Stack( - fit: StackFit.expand, - alignment: Alignment.center, - clipBehavior: Clip.none, - children: [ - Positioned( - child: Container(color: Colors.white, child: Text("نوع فروش")), - top: -10, - right: 8, - ), - Obx(() { - return RadioGroup( - groupValue: controller.saleType.value, - onChanged: (value) { - controller.saleType.value = value ?? 0; - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: - (controller.broadcastPrice.value?.active ?? false) - ? () { - controller.saleType.value = 1; - } - : null, - child: Row( - children: [ - Radio( - value: 1, - enabled: - (controller.broadcastPrice.value?.active ?? - false), - ), - Text( - 'قیمت دولتی', - style: AppFonts.yekan14.copyWith( - color: - (controller.broadcastPrice.value?.active ?? - false) - ? AppColor.textColor - : AppColor.labelTextColor, - ), - ), - ], - ), - ), + Expanded( + child: GestureDetector( + onTap: () { + controller.quotaType.value = 2; + }, + child: Row( + children: [ + Radio(value: 2), + Text('آزاد', style: AppFonts.yekan14), + ], ), - - Expanded( - child: GestureDetector( - onTap: () { - controller.saleType.value = 2; - }, - child: Row( - children: [ - Radio(value: 2), - Text('قیمت آزاد', style: AppFonts.yekan14), - ], - ), - ), - ), - ], + ), ), - ); - }), - ], - ), - ), - - Obx(() { - return MonthlyDataCalendar( - label: 'تاریخ تولید گوشت', - selectedDate: controller.productionDate.value?.formatCompactDate(), - onDateSelect: (value) { - controller.productionDate.value = value.date; - }, - dayData: controller.quotaType.value == 1 - ? controller.governmentalProductionDateData - : controller.freeProductionDateData, - ); - }), - ], + ], + ), + ); + }), + ], + ), ), ), + + Obx(() { + return MonthlyDataCalendar( + label: 'تاریخ تولید گوشت', + selectedDate: controller.productionDate.value?.formatCompactDate(), + onDateSelect: (value) { + controller.productionDate.value = value.date; + controller.remainingStock.value = value.remainingStock; + }, + dayData: controller.quotaType.value == 1 + ? controller.governmentalProductionDateData + : controller.freeProductionDateData, + ); + }), + + Visibility(visible: isOnEdit == false, child: _buyerWidget()), + RTextField( controller: controller.saleWeightController, label: 'وزن لاشه (کیلوگرم)', keyboardType: TextInputType.number, borderColor: AppColor.darkGreyLight, filledColor: AppColor.bgLight, + autoValidateMode: AutovalidateMode.onUserInteraction, filled: true, inputFormatters: [ FilteringTextInputFormatter.digitsOnly, @@ -620,8 +455,9 @@ class SalesOutOfProvincePage extends GetView { ], validator: (value) { - if (value == null) { - return 'لطفاً وزن لاشه را وارد کنید'; + if ((int.tryParse(value?.clearComma ?? '0') ?? 0) > + (controller.remainingStock.value ?? 0)) { + return 'وزن تخصیصی بیشتر از موجودی انبار است'; } return null; }, @@ -641,9 +477,137 @@ class SalesOutOfProvincePage extends GetView { SeparatorInputFormatter(), ], + validator: (value) { + if ((int.tryParse(value?.clearComma ?? '0') ?? 0) > + (controller.remainingStock.value ?? 0)) { + return 'وزن تخصیصی بیشتر از موجودی انبار است'; + } + return null; + }, + ), + + Visibility( + visible: isOnEdit == false, + child: Container( + height: 58.h, + clipBehavior: Clip.none, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.darkGreyLight, width: 1), + ), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Positioned( + child: Container(color: Colors.white, child: Text("فروش")), + top: -10, + right: 8, + ), + Obx(() { + return RadioGroup( + groupValue: controller.saleType.value, + onChanged: (value) { + controller.saleType.value = 2; + }, + child: Row( + children: [ + Expanded( + child: GestureDetector( + onTap: (controller.broadcastPrice.value?.active ?? false) + ? () { + controller.saleType.value = 2; + } + : null, + child: Row( + children: [ + Radio( + value: 1, + enabled: + controller.broadcastPrice.value?.active ?? false, + ), + Text( + 'قیمت مصوب', + style: AppFonts.yekan14.copyWith( + color: + (controller.broadcastPrice.value?.active ?? + false) + ? AppColor.textColor + : AppColor.labelTextColor, + ), + ), + ], + ), + ), + ), + + Expanded( + child: GestureDetector( + onTap: () { + controller.saleType.value = 2; + }, + child: Row( + children: [ + Radio(value: 2), + Text('قیمت آزاد', style: AppFonts.yekan14), + ], + ), + ), + ), + ], + ), + ); + }), + ], + ), + ), + ), + + ObxValue((data) { + return RTextField( + variant: RTextFieldVariant.noBorder, + controller: controller.pricePerKiloController, + borderColor: AppColor.darkGreyLight, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + SeparatorInputFormatter(), + ], + filledColor: AppColor.bgLight, + filled: true, + readonly: data.value == 1, + onChanged: (p0) { + controller.pricePerKilo.value = int.tryParse(p0.clearComma) ?? 0; + }, + keyboardType: TextInputType.number, + label: 'قیمت هر کیلو (ريال)', + ); + }, controller.saleType), + + RTextField( + variant: RTextFieldVariant.noBorder, + enabled: false, + keyboardType: TextInputType.number, + filledColor: AppColor.bgLight, + filled: true, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + SeparatorInputFormatter(), + ], + controller: controller.totalCostController, + label: 'هزینه کل (ريال)', + ), + + RTextField( + controller: controller.quarantineCodeController, + label: 'کد قرنطینه', + borderColor: AppColor.darkGreyLight, + filledColor: AppColor.bgLight, + filled: true, validator: (value) { if (value == null) { - return 'لطفاً قطعه لاشه را وارد کنید'; + return 'لطفاً کد قرنطینه را وارد کنید'; } return null; }, @@ -713,9 +677,9 @@ class SalesOutOfProvincePage extends GetView { Text(item?.name ?? 'انتخاب محصول'), Spacer(), - Text( - 'موجودی:${controller.rootLogic.inventoryModel.value?.totalRemainWeight.separatedByCommaFa ?? 0}', - ), + ObxValue((data) { + return Visibility(visible: data.value != null, child: Text('موجودی: $data')); + }, controller.remainingStock), ], ), ); @@ -913,4 +877,29 @@ class SalesOutOfProvincePage extends GetView { ), ); } + + Widget bottomSendOtpSheetSellCode(StewardFreeSaleBar item) { + return BaseBottomSheet( + height: 190.h, + child: Column( + children: [ + SizedBox(height: 12), + RTextField( + controller: controller.otpCodeSell, + onChanged: (data) => controller.otpCode.value = data, + label: 'کد احراز', + ), + SizedBox(height: 12), + RElevated( + onPressed: () { + controller.sendSaleOtpCode(item); + }, + isFullWidth: true, + text: "ارسال کد", + ), + SizedBox(height: 12), + ], + ), + ); + } } diff --git a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province_sales_list/view.dart b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province_sales_list/view.dart index da2705b..feba52f 100644 --- a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province_sales_list/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province_sales_list/view.dart @@ -78,7 +78,7 @@ class SalesOutOfProvinceSalesListPage extends GetView toDateFilter = Jalali.now().obs; RxnString searchedValue = RxnString(); RxInt segmentType = 1.obs; - RxInt saleType = 2.obs; + RxInt priceType = 2.obs; RxInt quotaType = 2.obs; GlobalKey formKey = GlobalKey(); TextEditingController weightController = TextEditingController(text: '0'); @@ -31,14 +32,15 @@ class SegmentationLogic extends GetxController { Rxn selectedGuildModel = Rxn(); Rxn selectedProduct = Rxn(); Rxn selectedSegment = Rxn(); - + Rxn broadcastPrice = Rxn(); Rx>> segmentationList = Resource>.loading().obs; RxList guildsModel = [].obs; Rx saleDate = Jalali.now().obs; - - Rxn productionDate = Rxn(null); + RxInt weight = 0.obs; + Rxn productionDate = Rxn(null); + Rxn remainingStock = Rxn(null); Map freeProductionDateData = {}; Map governmentalProductionDateData = {}; @@ -50,6 +52,10 @@ class SegmentationLogic extends GetxController { getAllSegmentation(); getGuilds(); + ever(quotaType, (_) { + remainingStock.value = null; + productionDate.value = null; + }); _updateGovernmentalProductionDateData(); _updateFreeProductionDateData(); ever(rootLogic.stewardRemainWeight, (callback) { @@ -100,7 +106,7 @@ class SegmentationLogic extends GetxController { time: Duration(milliseconds: timeDebounce), ); - everAll([selectedSegment, quotaType, saleType], (_) { + everAll([selectedSegment, quotaType, priceType], (_) { validateForm(); }); @@ -116,27 +122,22 @@ class SegmentationLogic extends GetxController { weightController.text = '0'; selectedSegment.value = null; selectedGuildModel.value = null; - productionDate.value = Jalali.now(); + productionDate.value = null; segmentType.value = 1; - saleType.value = 2; + priceType.value = 2; quotaType.value = 1; + remainingStock.value = null; } void validateForm() { - var weight = int.tryParse(weightController.text.trim().clearComma); - var hasWeight = quotaType.value == 2 - ? ((weight ?? 0) <= (rootLogic.stewardSalesInfoDashboard.value?.totalFreeRemainWeight ?? 0)) - : ((weight ?? 0) <= - (rootLogic.stewardSalesInfoDashboard.value?.totalGovernmentalRemainWeight ?? 0)); - if (!hasWeight) { - defaultShowErrorMessage("میزان وزن تخیصصی شده بیشتر از وزن باقیمانده است!"); - } - + var weight = int.tryParse(weightController.text.trim().clearComma) ?? 0; + var hasWeight = (remainingStock.value ?? 0) > weight; isSubmitButtonEnabled.value = selectedProduct.value != null && weightController.text.isNotEmpty && hasWeight && - weight! > 0 && + productionDate.value != null && + weight > 0 && (segmentType.value == 1 || (segmentType.value == 2 && selectedGuildModel.value != null)); } @@ -229,7 +230,7 @@ class SegmentationLogic extends GetxController { SegmentationModel segmentationModel = SegmentationModel( productKey: selectedProduct.value?.key, weight: int.tryParse(weightController.text.clearComma) ?? 0, - saleType: saleType.value == 1 ? 'governmental' : 'free', + saleType: priceType.value == 1 ? 'governmental' : 'free', quota: quotaType.value == 1 ? 'governmental' : 'free', ); if (segmentType.value == 2) { @@ -282,10 +283,26 @@ class SegmentationLogic extends GetxController { currentPage.value = 1; await rootLogic.onRefresh(); await getAllSegmentation(); + await getBroadcastPrice(); _updateFreeProductionDateData(); _updateGovernmentalProductionDateData(); } + Future getBroadcastPrice() async { + safeCall( + call: () async => await rootLogic.chickenRepository.getBroadcastPrice( + token: rootLogic.tokenService.accessToken.value!, + ), + onSuccess: (result) { + broadcastPrice.value = result; + if (broadcastPrice.value?.active == true) { + priceType.value = 2; + } + }, + onError: (error, stacktrace) {}, + ); + } + void toggleExpansion({int? index}) { if (expandedListIndex.value == index || index == null) { expandedListIndex.value = -1; diff --git a/packages/chicken/lib/presentation/pages/steward/segmentation/view.dart b/packages/chicken/lib/presentation/pages/steward/segmentation/view.dart index 54d33ba..d9bb6a3 100644 --- a/packages/chicken/lib/presentation/pages/steward/segmentation/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/segmentation/view.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; -import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; import 'package:rasadyar_chicken/data/models/response/segmentation_model/segmentation_model.dart'; +import 'package:rasadyar_chicken/presentation/pages/steward/segmentation/widgets/cu_bottom_sheet.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; import 'package:rasadyar_chicken/presentation/widget/filter_bottom_sheet.dart'; import 'package:rasadyar_core/core.dart'; @@ -60,7 +58,7 @@ class SegmentationPage extends GetView { child: RFab.add( onPressed: () { Get.bottomSheet( - addOrEditBottomSheet(), + addOrEditBottomSheet(controller), isScrollControlled: true, ignoreSafeArea: false, ).whenComplete(() { @@ -252,7 +250,7 @@ class SegmentationPage extends GetView { onPressed: () { controller.setEditData(item); Get.bottomSheet( - addOrEditBottomSheet(true), + addOrEditBottomSheet(controller, isOnEdit: true), isScrollControlled: true, ignoreSafeArea: false, ).whenComplete(() { @@ -284,454 +282,4 @@ class SegmentationPage extends GetView { ), ); } - - Widget addOrEditBottomSheet([bool isOnEdit = false]) { - return BaseBottomSheet( - height: isOnEdit ? 350.h : 650.h, - child: SingleChildScrollView( - child: Form( - key: controller.formKey, - child: Column( - spacing: 16, - children: [ - Text( - isOnEdit ? 'ویرایش قطعه‌بندی' : 'افزودن قطعه‌بندی', - style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal), - ), - _productDropDown(), - Visibility( - visible: isOnEdit == false, - child: Column( - spacing: 12, - children: [ - Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.darkGreyLight, width: 1), - ), - - child: Column( - children: [ - const SizedBox(height: 8), - SizedBox( - height: 40, - child: ObxValue((data) { - return RadioGroup( - onChanged: (value) { - controller.segmentType.value = value!; - controller.selectedGuildModel.value = null; - controller.selectedGuildModel.refresh(); - }, - groupValue: controller.segmentType.value, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Radio(value: 1), - Text('قطعه‌بندی(کاربر)', style: AppFonts.yekan14), - SizedBox(width: 12), - Radio(value: 2), - Text('تخصیص به قطعه‌بند', style: AppFonts.yekan14), - ], - ), - ); - }, controller.saleType), - ), - const SizedBox(height: 12), - - ObxValue((data) { - return Visibility(visible: data.value == 2, child: guildsDropDown()); - }, controller.segmentType), - ], - ), - ), - - Container( - height: 50.h, - clipBehavior: Clip.none, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.darkGreyLight, width: 1), - ), - child: Stack( - fit: StackFit.expand, - alignment: Alignment.center, - clipBehavior: Clip.none, - children: [ - Positioned( - child: Container(color: Colors.white, child: Text("نوع فروش")), - top: -10, - right: 8, - ), - Obx(() { - return RadioGroup( - groupValue: controller.saleType.value, - onChanged: (value) { - controller.saleType.value = 2 ?? 0; - controller.selectedGuildModel.value = null; - controller.selectedGuildModel.refresh(); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: () { - //controller.saleType.value = 1; - }, - child: Row( - children: [ - Radio(value: 1, enabled: false), - Text( - 'قیمت دولتی', - style: AppFonts.yekan14.copyWith( - color: AppColor.mediumGreyDark, - ), - ), - ], - ), - ), - ), - - Expanded( - child: GestureDetector( - onTap: () { - controller.saleType.value = 2; - }, - child: Row( - children: [ - Radio(value: 2), - Text('قیمت آزاد', style: AppFonts.yekan14), - ], - ), - ), - ), - ], - ), - ); - }), - ], - ), - ), - Container( - height: 50.h, - clipBehavior: Clip.none, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.darkGreyLight, width: 1), - ), - child: Stack( - fit: StackFit.expand, - alignment: Alignment.center, - clipBehavior: Clip.none, - children: [ - Positioned( - child: Container(color: Colors.white, child: Text("نوع انبار")), - top: -10, - right: 8, - ), - Obx(() { - return RadioGroup( - groupValue: controller.quotaType.value, - onChanged: (value) { - controller.quotaType.value = value ?? 0; - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalGovernmentalRemainWeight ?? - -1) > - 0 - ? () { - controller.quotaType.value = 1; - } - : null, - child: Row( - children: [ - Radio( - value: 1, - enabled: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalGovernmentalRemainWeight ?? - -1) > - 0, - ), - Text( - 'انبار دولتی', - style: AppFonts.yekan14.copyWith( - color: - ((controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalGovernmentalRemainWeight ?? - -1) > - 0) - ? AppColor.textColor - : AppColor.labelTextColor, - ), - ), - ], - ), - ), - ), - - Expanded( - child: GestureDetector( - onTap: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalFreeRemainWeight ?? - -1) > - 0 - ? () { - controller.quotaType.value = 2; - } - : null, - child: Row( - children: [ - Radio( - value: 2, - enabled: - (controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalFreeRemainWeight ?? - -1) > - 0, - ), - Text( - 'انبار آزاد', - style: AppFonts.yekan14.copyWith( - color: - ((controller - .rootLogic - .stewardSalesInfoDashboard - .value - ?.totalFreeRemainWeight ?? - -1) > - 0) - ? AppColor.textColor - : AppColor.labelTextColor, - ), - ), - ], - ), - ), - ), - ], - ), - ); - }), - ], - ), - ), - - Obx(() { - return MonthlyDataCalendar( - label: 'تاریخ تولید گوشت', - selectedDate: controller.productionDate.value?.formatCompactDate(), - onDateSelect: (value) => controller.productionDate..value = value.date, - dayData: controller.quotaType.value == 1 - ? controller.governmentalProductionDateData - : controller.freeProductionDateData, - ); - }), - ], - ), - ), - - Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.darkGreyLight, width: 1), - ), - child: Column( - spacing: 12, - children: [ - UnitTextField( - hint: 'وزن', - unit: 'کیلوگرم', - controller: controller.weightController, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - SeparatorInputFormatter(), - ], - validator: (value) { - if (value == null) { - return 'لطفاً وزن لاشه را وارد کنید'; - } - return null; - }, - ), - submitButtonWidget(isOnEdit), - ], - ), - ), - SizedBox(), - ], - ), - ), - ), - ); - } - - Widget submitButtonWidget(bool isOnEdit) { - return ObxValue((data) { - return RElevated( - isFullWidth: true, - backgroundColor: AppColor.greenNormal, - text: isOnEdit ? 'ویرایش' : 'ثبت', - onPressed: data.value - ? () async { - var res = isOnEdit - ? await controller.editSegment() - : await controller.createSegment(); - if (res) { - Get.back(); - } - } - : null, - height: 40, - ); - }, controller.isSubmitButtonEnabled); - } - - Widget _productDropDown() { - return Obx(() { - return OverlayDropdownWidget( - items: controller.rootLogic.rolesProductsModel, - height: 56, - hasDropIcon: false, - background: Colors.white, - onChanged: (value) { - controller.selectedProduct.value = value; - }, - selectedItem: controller.selectedProduct.value, - initialValue: controller.selectedProduct.value, - itemBuilder: (item) => Text(item.name ?? 'بدون نام'), - labelBuilder: (item) => Row( - spacing: 8, - children: [ - (item?.name?.contains('مرغ گرم') ?? false) - ? Assets.images.chicken.image(width: 40, height: 40) - : Assets.vec.placeHolderSvg.svg(width: 40, height: 40), - - Text(item?.name ?? 'انتخاب محصول'), - Spacer(), - Text( - 'موجودی: ${controller.rootLogic.inventoryModel.value?.totalRemainWeight.separatedByCommaFa ?? 0} کیلوگرم', - ), - ], - ), - ); - }); - } - - Widget guildsDropDown() { - return Obx(() { - final item = controller.selectedGuildModel.value; - return OverlayDropdownWidget( - key: ValueKey(item?.user?.fullname ?? ''), - items: controller.guildsModel, - onChanged: (value) { - controller.selectedGuildModel.value = value; - }, - selectedItem: item, - - itemBuilder: (item) => Text( - item.user != null - ? '${item.steward == true ? 'مباشر' : 'صنف'} ${item.user!.fullname} (${item.user!.mobile})' - : 'بدون نام', - ), - labelBuilder: (item) => Text( - item?.user != null - ? '${item?.steward == true ? 'مباشر' : 'صنف'} ${item?.user!.fullname} (${item?.user!.mobile})' - : 'انتخاب مباشر/صنف', - ), - ); - }); - } - - Container modalDatePicker(ValueChanged onDateSelected) { - Jalali currentDate = Jalali.now(); - Jalali? tempPickedDate; - return Container( - height: 250, - color: Colors.white, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - child: Row( - children: [ - SizedBox(width: 20), - RElevated( - height: 35, - width: 70, - textStyle: AppFonts.yekan14.copyWith(color: Colors.white), - onPressed: () { - onDateSelected(tempPickedDate ?? Jalali.now()); - Get.back(); - }, - text: 'تایید', - ), - Spacer(), - RElevated( - height: 35, - width: 70, - backgroundColor: AppColor.error, - textStyle: AppFonts.yekan14.copyWith(color: Colors.white), - onPressed: () { - onDateSelected(tempPickedDate ?? Jalali.now()); - Get.back(); - }, - text: 'لغو', - ), - SizedBox(width: 20), - ], - ), - ), - Divider(height: 0, thickness: 1), - Expanded( - child: Container( - child: PersianCupertinoDatePicker( - initialDateTime: controller.saleDate.value, - mode: PersianCupertinoDatePickerMode.date, - maximumDate: currentDate.addDays(3), - minimumDate: currentDate - .toDateTime() - .subtract(Duration(days: 1)) - .toString() - .toJalali, - maximumYear: currentDate.year, - minimumYear: currentDate.year, - onDateTimeChanged: (dateTime) { - tempPickedDate = dateTime; - }, - ), - ), - ), - ], - ), - ); - } } diff --git a/packages/chicken/lib/presentation/pages/steward/segmentation/widgets/cu_bottom_sheet.dart b/packages/chicken/lib/presentation/pages/steward/segmentation/widgets/cu_bottom_sheet.dart new file mode 100644 index 0000000..f00cf6c --- /dev/null +++ b/packages/chicken/lib/presentation/pages/steward/segmentation/widgets/cu_bottom_sheet.dart @@ -0,0 +1,395 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; +import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; +import 'package:rasadyar_chicken/presentation/pages/steward/segmentation/logic.dart'; +import 'package:rasadyar_core/core.dart'; + +Widget addOrEditBottomSheet(SegmentationLogic controller, {bool isOnEdit = false}) { + return BaseBottomSheet( + height: isOnEdit ? 350.h : 600.h, + child: SingleChildScrollView( + child: Form( + key: controller.formKey, + child: Column( + spacing: 16, + children: [ + Text( + isOnEdit ? 'ویرایش قطعه‌بندی' : 'افزودن قطعه‌بندی', + style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal), + ), + _productDropDown(controller), + Visibility( + visible: isOnEdit == false, + child: Container( + height: 50.h, + clipBehavior: Clip.none, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.darkGreyLight, width: 1), + ), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Positioned( + child: Container(color: Colors.white, child: Text("انبار")), + top: -10, + right: 8, + ), + Obx(() { + return RadioGroup( + groupValue: controller.quotaType.value, + onChanged: (value) { + controller.quotaType.value = value ?? 0; + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: GestureDetector( + onTap: () { + controller.quotaType.value = 1; + }, + child: Row( + children: [ + Radio(value: 1), + Text('دولتی', style: AppFonts.yekan14), + ], + ), + ), + ), + + Expanded( + child: GestureDetector( + onTap: () { + controller.quotaType.value = 2; + }, + child: Row( + children: [ + Radio(value: 2), + Text('آزاد', style: AppFonts.yekan14), + ], + ), + ), + ), + ], + ), + ); + }), + ], + ), + ), + ), + + Obx(() { + return MonthlyDataCalendar( + label: 'تاریخ تولید گوشت', + selectedDate: controller.productionDate.value?.formatCompactDate(), + onDateSelect: (value) { + controller.productionDate.value = value.date; + controller.remainingStock.value = value.remainingStock; + }, + dayData: controller.quotaType.value == 1 + ? controller.governmentalProductionDateData + : controller.freeProductionDateData, + ); + }), + + RTextField( + controller: controller.weightController, + keyboardType: TextInputType.number, + autoValidateMode: AutovalidateMode.onUserInteraction, + borderColor: AppColor.darkGreyLight, + filledColor: AppColor.bgLight, + filled: true, + inputFormatters: [FilteringTextInputFormatter.digitsOnly, SeparatorInputFormatter()], + validator: (value) { + if ((int.tryParse(value?.clearComma ?? '0') ?? 0) > + (controller.remainingStock.value ?? 0)) { + return 'وزن تخصیصی بیشتر از موجودی انبار است'; + } + return null; + }, + onChanged: (p0) { + controller.weight.value = int.tryParse(p0.clearComma) ?? 0; + }, + label: 'وزن لاشه (کیلوگرم)', + ), + Visibility( + visible: isOnEdit == false, + child: Container( + height: 58.h, + clipBehavior: Clip.none, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.darkGreyLight, width: 1), + ), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Positioned( + child: Container(color: Colors.white, child: Text("فروش")), + top: -10, + right: 8, + ), + Obx(() { + return RadioGroup( + groupValue: controller.priceType.value, + onChanged: (value) { + controller.priceType.value = value!; + }, + child: Row( + children: [ + Expanded( + child: GestureDetector( + onTap: (controller.broadcastPrice.value?.active ?? false) + ? () { + controller.priceType.value = 1; + } + : null, + child: Row( + children: [ + Radio( + value: 1, + enabled: controller.broadcastPrice.value?.active ?? false, + ), + Text( + 'قیمت مصوب', + style: AppFonts.yekan14.copyWith( + color: (controller.broadcastPrice.value?.active ?? false) + ? AppColor.textColor + : AppColor.labelTextColor, + ), + ), + ], + ), + ), + ), + + Expanded( + child: GestureDetector( + onTap: () { + controller.priceType.value = 2; + }, + child: Row( + children: [ + Radio(value: 2), + Text('قیمت آزاد', style: AppFonts.yekan14), + ], + ), + ), + ), + ], + ), + ); + }), + ], + ), + ), + ), + Visibility( + visible: isOnEdit == false, + child: Column( + spacing: 12, + children: [ + Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.darkGreyLight, width: 1), + ), + + child: Column( + children: [ + const SizedBox(height: 8), + SizedBox( + height: 40, + child: ObxValue((data) { + return RadioGroup( + onChanged: (value) { + controller.segmentType.value = value!; + controller.selectedGuildModel.value = null; + controller.selectedGuildModel.refresh(); + }, + groupValue: controller.segmentType.value, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Radio(value: 1), + Text('قطعه‌بندی(کاربر)', style: AppFonts.yekan14), + SizedBox(width: 12), + Radio(value: 2), + Text('تخصیص به قطعه‌بند', style: AppFonts.yekan14), + ], + ), + ); + }, controller.priceType), + ), + const SizedBox(height: 12), + + ObxValue((data) { + return Visibility( + visible: data.value == 2, + child: guildsDropDown(controller), + ); + }, controller.segmentType), + ], + ), + ), + ], + ), + ), + + submitButtonWidget(controller, isOnEdit: isOnEdit), + + SizedBox(), + ], + ), + ), + ), + ); +} + +Widget submitButtonWidget(SegmentationLogic controller, {bool isOnEdit = false}) { + return ObxValue((data) { + return RElevated( + isFullWidth: true, + backgroundColor: AppColor.greenNormal, + text: isOnEdit ? 'ویرایش' : 'ثبت', + onPressed: data.value + ? () async { + var res = isOnEdit + ? await controller.editSegment() + : await controller.createSegment(); + if (res) { + Get.back(); + } + } + : null, + height: 40, + ); + }, controller.isSubmitButtonEnabled); +} + +Widget _productDropDown(SegmentationLogic controller) { + return Obx(() { + return OverlayDropdownWidget( + items: controller.rootLogic.rolesProductsModel, + height: 56, + hasDropIcon: false, + background: Colors.white, + onChanged: (value) { + controller.selectedProduct.value = value; + }, + selectedItem: controller.selectedProduct.value, + initialValue: controller.selectedProduct.value, + itemBuilder: (item) => Text(item.name ?? 'بدون نام'), + labelBuilder: (item) => Row( + spacing: 8, + children: [ + (item?.name?.contains('مرغ گرم') ?? false) + ? Assets.images.chicken.image(width: 40, height: 40) + : Assets.vec.placeHolderSvg.svg(width: 40, height: 40), + + Text(item?.name ?? 'انتخاب محصول'), + Spacer(), + ObxValue((data) { + return Visibility(visible: data.value != null, child: Text('موجودی: $data')); + }, controller.remainingStock), + ], + ), + ); + }); +} + +Widget guildsDropDown(SegmentationLogic controller) { + return Obx(() { + final item = controller.selectedGuildModel.value; + return OverlayDropdownWidget( + key: ValueKey(item?.user?.fullname ?? ''), + items: controller.guildsModel, + onChanged: (value) { + controller.selectedGuildModel.value = value; + }, + selectedItem: item, + + itemBuilder: (item) => Text( + item.user != null + ? '${item.steward == true ? 'مباشر' : 'صنف'} ${item.user!.fullname} (${item.user!.mobile})' + : 'بدون نام', + ), + labelBuilder: (item) => Text( + item?.user != null + ? '${item?.steward == true ? 'مباشر' : 'صنف'} ${item?.user!.fullname} (${item?.user!.mobile})' + : 'انتخاب مباشر/صنف', + ), + ); + }); +} + +Container modalDatePicker(SegmentationLogic controller, ValueChanged onDateSelected) { + Jalali currentDate = Jalali.now(); + Jalali? tempPickedDate; + return Container( + height: 250, + color: Colors.white, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + child: Row( + children: [ + SizedBox(width: 20), + RElevated( + height: 35, + width: 70, + textStyle: AppFonts.yekan14.copyWith(color: Colors.white), + onPressed: () { + onDateSelected(tempPickedDate ?? Jalali.now()); + Get.back(); + }, + text: 'تایید', + ), + Spacer(), + RElevated( + height: 35, + width: 70, + backgroundColor: AppColor.error, + textStyle: AppFonts.yekan14.copyWith(color: Colors.white), + onPressed: () { + onDateSelected(tempPickedDate ?? Jalali.now()); + Get.back(); + }, + text: 'لغو', + ), + SizedBox(width: 20), + ], + ), + ), + Divider(height: 0, thickness: 1), + Expanded( + child: Container( + child: PersianCupertinoDatePicker( + initialDateTime: controller.saleDate.value, + mode: PersianCupertinoDatePickerMode.date, + maximumDate: currentDate.addDays(3), + minimumDate: currentDate.toDateTime().subtract(Duration(days: 1)).toString().toJalali, + maximumYear: currentDate.year, + minimumYear: currentDate.year, + onDateTimeChanged: (dateTime) { + tempPickedDate = dateTime; + }, + ), + ), + ), + ], + ), + ); +} diff --git a/packages/chicken/pubspec.yaml b/packages/chicken/pubspec.yaml index 3f702d2..fd61c05 100644 --- a/packages/chicken/pubspec.yaml +++ b/packages/chicken/pubspec.yaml @@ -22,8 +22,8 @@ dev_dependencies: lints: ^6.0.0 test: ^1.25.15 ##code generation - build_runner: ^2.7.1 - hive_ce_generator: ^1.9.3 + build_runner: ^2.10.1 + hive_ce_generator: ^1.10.0 freezed: ^3.2.3 json_serializable: ^6.11.1 diff --git a/packages/core/lib/presentation/widget/inputs/r_input.dart b/packages/core/lib/presentation/widget/inputs/r_input.dart index 81c2ff6..a013f89 100644 --- a/packages/core/lib/presentation/widget/inputs/r_input.dart +++ b/packages/core/lib/presentation/widget/inputs/r_input.dart @@ -200,6 +200,7 @@ class _RTextFieldState extends State { padding: widget.padding ?? EdgeInsets.zero, child: TextFormField( controller: widget.controller, + focusNode: widget.focusNode, textAlign: widget.textAlign ?? TextAlign.start, readOnly: widget.readonly, diff --git a/packages/core/lib/presentation/widget/inputs/unit_text_field.dart b/packages/core/lib/presentation/widget/inputs/unit_text_field.dart index e1bc585..e96021f 100644 --- a/packages/core/lib/presentation/widget/inputs/unit_text_field.dart +++ b/packages/core/lib/presentation/widget/inputs/unit_text_field.dart @@ -20,7 +20,8 @@ class UnitTextField extends StatefulWidget { this.textStyle, this.textColor, this.inputFormatters, - this.validator + this.validator, + this.autoValidateMode, }); final String hint; @@ -34,6 +35,7 @@ class UnitTextField extends StatefulWidget { final TextInputAction? textInputAction; final List? inputFormatters; final FormFieldValidator? validator; + final AutovalidateMode? autoValidateMode; final bool? enabled; final bool? readOnly; final int? maxLines; @@ -62,7 +64,7 @@ class _UnitTextFieldState extends State { @override Widget build(BuildContext context) { return Container( - height: 40, + constraints: const BoxConstraints(minHeight: 40), width: MediaQuery.of(context).size.width, padding: const EdgeInsets.symmetric(horizontal: 12), decoration: BoxDecoration( @@ -76,7 +78,7 @@ class _UnitTextFieldState extends State { Text( widget.hint, style: - widget.textStyle?.copyWith(color: widget.textColor) ?? + widget.textStyle?.copyWith(color: widget.textColor) ?? AppFonts.yekan14.copyWith(color: widget.textColor ?? AppColor.textColorLight), ), @@ -85,7 +87,7 @@ class _UnitTextFieldState extends State { Expanded( child: TextFormField( controller: tmpController, - keyboardType: TextInputType.number, + keyboardType: widget.keyboardType ?? TextInputType.number, textInputAction: widget.textInputAction, onChanged: widget.onChanged, enabled: widget.enabled, @@ -95,11 +97,13 @@ class _UnitTextFieldState extends State { textDirection: TextDirection.ltr, inputFormatters: widget.inputFormatters, validator: widget.validator, + autovalidateMode: widget.autoValidateMode, style: AppFonts.yekan18.copyWith(color: AppColor.darkGreyNormalActive), - decoration: const InputDecoration( + decoration: InputDecoration( isDense: true, border: InputBorder.none, - contentPadding: EdgeInsets.symmetric(vertical: 8), + contentPadding: const EdgeInsets.symmetric(vertical: 8), + errorMaxLines: 2, ), ), ), diff --git a/packages/core/lib/presentation/widget/monthly_calender.dart b/packages/core/lib/presentation/widget/monthly_calender.dart index 7016f63..b00bb90 100644 --- a/packages/core/lib/presentation/widget/monthly_calender.dart +++ b/packages/core/lib/presentation/widget/monthly_calender.dart @@ -114,6 +114,7 @@ class _MonthlyDataCalendarState extends State { isToday: date.year == today.year && date.month == today.month && date.day == today.day, isEnabled: isEnabled, hasZeroValue: hasZeroValue, + remainingStock: data?.value ?? 0, ), ); } @@ -396,6 +397,7 @@ class DayInfo { final bool isToday; final bool isEnabled; final bool hasZeroValue; + final int remainingStock; DayInfo({ required this.date, @@ -404,6 +406,7 @@ class DayInfo { required this.isToday, required this.isEnabled, required this.hasZeroValue, + required this.remainingStock, }); } diff --git a/pubspec.yaml b/pubspec.yaml index 89f3b9e..1f506bd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: rasadyar_app description: "A new Flutter project." publish_to: 'none' -version: 1.3.30+27 +version: 1.3.32+29 environment: sdk: ^3.9.2