price round fix
parent
410f162eed
commit
8d162bf19b
|
|
@ -18,7 +18,7 @@ import 'package:satu/views/work/tabs/component/product_list_item.dart';
|
||||||
import 'package:satu/widgets/bar/products_app_bar.dart';
|
import 'package:satu/widgets/bar/products_app_bar.dart';
|
||||||
import 'package:satu/widgets/bar/products_header_bar.dart';
|
import 'package:satu/widgets/bar/products_header_bar.dart';
|
||||||
import 'package:satu/widgets/bar/products_title_bar.dart';
|
import 'package:satu/widgets/bar/products_title_bar.dart';
|
||||||
import 'package:satu/views/work/tabs/utils/ProductUtils.dart';
|
import 'package:satu/views/work/tabs/utils/product_utils.dart';
|
||||||
|
|
||||||
import 'component/contagent_select_bar.dart';
|
import 'component/contagent_select_bar.dart';
|
||||||
|
|
||||||
|
|
@ -39,44 +39,50 @@ class SellView extends StatelessWidget {
|
||||||
sum: sumProducts(state.items!),
|
sum: sumProducts(state.items!),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: ListView(
|
body: Column(
|
||||||
physics: const BouncingScrollPhysics(),
|
|
||||||
children: [
|
children: [
|
||||||
const ContragentSelectBar(
|
const ContragentSelectBar(
|
||||||
value: 'Частное лицо',
|
value: 'Частное лицо',
|
||||||
),
|
),
|
||||||
Visibility(
|
Expanded(
|
||||||
visible: state.items!.isNotEmpty,
|
child: ListView(
|
||||||
child: const ProductsTitleBarBar(
|
physics: const BouncingScrollPhysics(),
|
||||||
itemsExist: true,
|
children: [
|
||||||
title: 'Товары',
|
Visibility(
|
||||||
|
visible: state.items!.isNotEmpty,
|
||||||
|
child: const ProductsTitleBarBar(
|
||||||
|
itemsExist: true,
|
||||||
|
title: 'Товары',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListView.separated(
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
padding: const EdgeInsets.only(bottom: 120),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: state.items!.length,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
final ProductDao product = state.items!.elementAt(index);
|
||||||
|
return ProductListItem(
|
||||||
|
key: UniqueKey(),
|
||||||
|
ean: product.eanCode,
|
||||||
|
isOdd: index % 2 == 0,
|
||||||
|
name: product.productName,
|
||||||
|
price: product.price,
|
||||||
|
count: product.count,
|
||||||
|
categoryName: product.categoryName,
|
||||||
|
transactionId: product.transactionId,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (context, index) {
|
||||||
|
return const Divider(
|
||||||
|
height: 1,
|
||||||
|
color: disableColor,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ListView.separated(
|
|
||||||
physics: const BouncingScrollPhysics(),
|
|
||||||
padding: const EdgeInsets.only(bottom: 120),
|
|
||||||
shrinkWrap: true,
|
|
||||||
itemCount: state.items!.length,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
final ProductDao product = state.items!.elementAt(index);
|
|
||||||
return ProductListItem(
|
|
||||||
key: UniqueKey(),
|
|
||||||
ean: product.eanCode,
|
|
||||||
isOdd: index % 2 == 0,
|
|
||||||
name: product.productName,
|
|
||||||
price: product.price,
|
|
||||||
count: product.count,
|
|
||||||
categoryName: product.categoryName,
|
|
||||||
transactionId: product.transactionId,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
separatorBuilder: (context, index) {
|
|
||||||
return const Divider(
|
|
||||||
height: 1,
|
|
||||||
color: disableColor,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
floatingActionButtonLocation:
|
floatingActionButtonLocation:
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
import 'package:satu/core/models/flow/product_dao.dart';
|
|
||||||
|
|
||||||
num sumProducts(List<ProductDao> list) {
|
|
||||||
num result = 0.0;
|
|
||||||
if (list.isNotEmpty) {
|
|
||||||
list.forEach((product) {
|
|
||||||
result += (product.price! * product.count!);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
import 'package:satu/core/models/flow/product_dao.dart';
|
||||||
|
|
||||||
|
num sumProducts(List<ProductDao> list) {
|
||||||
|
num result = 0.0;
|
||||||
|
if (list.isNotEmpty) {
|
||||||
|
for( final ProductDao product in list) {
|
||||||
|
final String val = (product.price! * product.count!).toStringAsFixed(5);
|
||||||
|
// result += product.price! * product.count!;
|
||||||
|
result += num.parse(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ import 'package:satu/shared/app_colors.dart';
|
||||||
import 'package:satu/widgets/bar/products_app_bar.dart';
|
import 'package:satu/widgets/bar/products_app_bar.dart';
|
||||||
import 'package:satu/widgets/bar/products_header_bar.dart';
|
import 'package:satu/widgets/bar/products_header_bar.dart';
|
||||||
import 'package:satu/widgets/bar/products_title_bar.dart';
|
import 'package:satu/widgets/bar/products_title_bar.dart';
|
||||||
import 'package:satu/views/work/tabs/utils/ProductUtils.dart';
|
import 'package:satu/views/work/tabs/utils/product_utils.dart';
|
||||||
import 'package:satu/widgets/buttons/busy_button.dart';
|
import 'package:satu/widgets/buttons/busy_button.dart';
|
||||||
|
|
||||||
class PaymentView extends StatefulWidget {
|
class PaymentView extends StatefulWidget {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue