feat : sale out province

This commit is contained in:
MrM
2025-06-06 17:33:34 +03:30
parent 857ae6b550
commit 9e3629ed1e
15 changed files with 1171 additions and 160 deletions

View File

@@ -1,10 +1,8 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_auth/data/utils/safe_call.dart';
import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart';
import 'package:rasadyar_chicken/data/models/request/submit_steward_allocation/submit_steward_allocation.dart';
import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart';
import 'package:rasadyar_chicken/data/models/response/dashboard_kill_house_free_bar/dashboard_kill_house_free_bar.dart';
import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart';
import 'package:rasadyar_chicken/data/models/response/guild_profile/guild_profile.dart';
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart';
import 'package:rasadyar_chicken/presentation/pages/root/logic.dart';
@@ -17,39 +15,13 @@ class SalesWithOutProvinceLogic extends GetxController {
RxList<GuildModel> guildsModel = <GuildModel>[].obs;
Rxn<StewardFreeBarDashboard> stewardFreeDashboard = Rxn<StewardFreeBarDashboard>();
Rxn<StewardFreeBarDashboard> stewardFreeDashboard =
Rxn<StewardFreeBarDashboard>();
@override
void onInit() {
super.onInit();
rootLogic.getInventory();
getAllocatedMade();
getRolesProducts();
getGuilds();
getGuildProfile();
ever(saleType, (callback) {
getGuilds();
});
weight.listen((num) {
totalCost.value = num * pricePerKilo.value;
});
pricePerKilo.listen((num) {
totalCost.value = num * weight.value;
});
totalCost.listen((data) {
totalCostController.text = data.toString();
isValid.value =
weight.value > 0 &&
pricePerKilo.value > 0 &&
totalCost.value > 0 &&
selectedProductModel.value != null &&
selectedGuildModel.value != null;
});
getStewardDashBord();
}
Future<void> getAllocatedMade() async {
@@ -67,14 +39,7 @@ class SalesWithOutProvinceLogic extends GetxController {
);
}
void checkVerfication() {
isValid.value =
weight.value > 0 &&
pricePerKilo.value > 0 &&
totalCost.value > 0 &&
selectedProductModel.value != null &&
selectedGuildModel.value != null;
}
void checkVerfication() {}
void confirmAllocation(ConformAllocation allocation) {
safeCall(
@@ -131,75 +96,46 @@ class SalesWithOutProvinceLogic extends GetxController {
);
}
Future<void> getGuilds() async {
Future<void> getGuilds() async {}
Future<void> addSale() async {}
void setSelectedGuild(GuildModel value) {}
void setSelectedProduct(ProductModel value) {}
Future<void> getStewardDashBord() async {
safeCall(
call: () async => await rootLogic.chickenRepository.getGuilds(
call: () async => await rootLogic.chickenRepository.getStewardDashboard(
token: rootLogic.tokenService.accessToken.value!,
isFree: saleType.value == 2 ? true : false,
stratDate: DateTime.now().formattedDashedGregorian,
endDate: DateTime.now().formattedDashedGregorian,
),
onSuccess: (result) {
if (result != null) {
guildsModel.clear();
guildsModel.addAll(result);
stewardFreeDashboard.value = result;
}
},
onError: (error, stacktrace) {},
);
}
Future<void> addSale() async {}
void setSelectedGuild(GuildModel value) {
selectedGuildModel.value = value;
update();
}
void setSelectedProduct(ProductModel value) {
selectedProductModel.value = value;
update();
}
Future<void> getGuildProfile() async {
await safeCall(
call: () async => await rootLogic.chickenRepository.getProfile(
token: rootLogic.tokenService.accessToken.value!,
),
onError: (error, stackTrace) {},
onSuccess: (result) {
guildProfile.value = result;
},
);
}
Future<void> submitAllocation() async {
SubmitStewardAllocation stewardAllocation = SubmitStewardAllocation(
approvedPriceStatus: false,
allocationType:
'${guildProfile.value?.steward == true ? "steward" : "guild"}-${selectedGuildModel.value?.steward == true ? "steward" : "guild"}',
sellerType: guildProfile.value?.steward == true ? "Steward" : "Guild",
buyerType: selectedGuildModel.value?.steward == true
? "Steward"
: "Guild",
amount: pricePerKilo.value,
totalAmount: totalCost.value,
weightOfCarcasses: weight.value,
guildKey: selectedGuildModel.value?.key,
productKey: selectedProductModel.value?.key,
date: DateTime.now().formattedGregorianDate,
type: "manual",
);
/* Future<void> getKillHouseDashBord() async {
safeCall(
call: () async =>
await rootLogic.chickenRepository.postSubmitStewardAllocation(
await rootLogic.chickenRepository.getDashboardKillHouseFreeBar(
token: rootLogic.tokenService.accessToken.value!,
request: stewardAllocation,
stratDate: DateTime.now().formattedDashedGregorian,
endDate: DateTime.now().formattedDashedGregorian,
),
onSuccess: (result) {
getAllocatedMade();
if (result != null) {
killHouseDashboard.value = result;
}
},
onError: (error, stackTrace) {},
onError: (error, stacktrace) {},
);
}
}*/
Future<void> submitAllocation() async {}
}

View File

@@ -1,10 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart';
import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart';
import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart';
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart';
import 'package:rasadyar_chicken/presentation/pages/entering_the_warehouse/string_utils.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
@@ -15,11 +11,18 @@ class SalesWithOutProvincePage extends GetView<SalesWithOutProvinceLogic> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: RAppBar(title: 'فروش خارج استان'),
appBar: RAppBar(
title: 'فروش خارج استان',
),
body: SingleChildScrollView(
child: Column(
spacing: 10,
children: [
SizedBox(height: 12),
ObxValue(
(model) => summaryOfInformation(model.value),
controller.stewardFreeDashboard,
@@ -33,10 +36,18 @@ class SalesWithOutProvincePage extends GetView<SalesWithOutProvinceLogic> {
Widget summaryOfInformation(StewardFreeBarDashboard? model) {
return Column(
children: [
Text(
'خلاصه اطلاعات',
textAlign: TextAlign.right,
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: [
Text(
'خلاصه اطلاعات',
style: AppFonts.yekan16Bold.copyWith(
color: AppColor.blueNormal,
),
),
],
),
),
Container(
height: 140,
@@ -54,9 +65,15 @@ class SalesWithOutProvincePage extends GetView<SalesWithOutProvinceLogic> {
spacing: 10,
children: [
const SizedBox(height: 12),
buildRow('تعداد کل بارها', model.totalQuantity.toString()),
buildRow('تعداد کل', model.totalBars.toString()),
buildRow('وزن کل (کیلوگرم)', model.totalWeight.toString()),
buildRow(
'تعداد کل بارها',
model.totalQuantity?.toString() ?? '0',
),
buildRow('تعداد کل', model.totalBars?.toString() ?? '0'),
buildRow(
'وزن کل (کیلوگرم)',
model.totalWeight?.toString() ?? '0',
),
],
),
),
@@ -64,7 +81,40 @@ class SalesWithOutProvincePage extends GetView<SalesWithOutProvinceLogic> {
);
}
Widget inventoryWidget() {
Widget buildRow(String title, String value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 2,
child: Text(
title,
textAlign: TextAlign.right,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
),
Flexible(
flex: 2,
child: Text(
value,
textAlign: TextAlign.left,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
),
],
),
);
}
/* Widget inventoryWidget() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Column(
@@ -73,7 +123,7 @@ class SalesWithOutProvincePage extends GetView<SalesWithOutProvinceLogic> {
Align(
alignment: Alignment.centerRight,
child: Text(
'موجودی انبار',
'خرید های خارج استان',
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal),
),
),
@@ -141,9 +191,9 @@ class SalesWithOutProvincePage extends GetView<SalesWithOutProvinceLogic> {
],
),
);
}
}*/
Widget inventoryItem({
/* Widget inventoryItem({
required bool isExpanded,
required int index,
required InventoryModel model,
@@ -186,36 +236,7 @@ class SalesWithOutProvincePage extends GetView<SalesWithOutProvinceLogic> {
);
}
Widget buildRow(String title, String value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 2,
child: Text(
title,
textAlign: TextAlign.right,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
),
Flexible(
flex: 2,
child: Text(
value,
textAlign: TextAlign.left,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
),
],
),
);
}
Widget allocationsMade() {
return Padding(
@@ -547,7 +568,7 @@ class SalesWithOutProvincePage extends GetView<SalesWithOutProvinceLogic> {
},
);
}, controller.guildsModel);
/* return GetBuilder<SalesWithinProvinceLogic>(
*/ /* return GetBuilder<SalesWithinProvinceLogic>(
builder: (controller) {
return DropdownButtonFormField<GuildModel>(
value: controller.selectedGuildModel.value,
@@ -572,7 +593,7 @@ class SalesWithOutProvincePage extends GetView<SalesWithOutProvinceLogic> {
},
);
},
);*/
);*/ /*
}
Widget productDropDown() {
@@ -600,5 +621,5 @@ class SalesWithOutProvincePage extends GetView<SalesWithOutProvinceLogic> {
);
},
);
}
}*/
}