feat: sync order
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/order_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_remote_datasource.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'transaction_report_event.dart';
|
||||
@@ -19,7 +18,8 @@ class TransactionReportBloc
|
||||
event.endDate,
|
||||
);
|
||||
|
||||
result.fold((l) => emit(_Error(l)), (r) => emit(_Loaded(r.data!)));
|
||||
result.fold(
|
||||
(l) => emit(_Error(l)), (r) => emit(_Loaded(r.data!.orders!)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+22
-22
@@ -342,7 +342,7 @@ mixin _$TransactionReportState {
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String message) error,
|
||||
required TResult Function(List<ItemOrder> transactionReport) loaded,
|
||||
required TResult Function(List<Order> transactionReport) loaded,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
@@ -350,7 +350,7 @@ mixin _$TransactionReportState {
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String message)? error,
|
||||
TResult? Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult? Function(List<Order> transactionReport)? loaded,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
@@ -358,7 +358,7 @@ mixin _$TransactionReportState {
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String message)? error,
|
||||
TResult Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult Function(List<Order> transactionReport)? loaded,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@@ -455,7 +455,7 @@ class _$InitialImpl implements _Initial {
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String message) error,
|
||||
required TResult Function(List<ItemOrder> transactionReport) loaded,
|
||||
required TResult Function(List<Order> transactionReport) loaded,
|
||||
}) {
|
||||
return initial();
|
||||
}
|
||||
@@ -466,7 +466,7 @@ class _$InitialImpl implements _Initial {
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String message)? error,
|
||||
TResult? Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult? Function(List<Order> transactionReport)? loaded,
|
||||
}) {
|
||||
return initial?.call();
|
||||
}
|
||||
@@ -477,7 +477,7 @@ class _$InitialImpl implements _Initial {
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String message)? error,
|
||||
TResult Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult Function(List<Order> transactionReport)? loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
@@ -572,7 +572,7 @@ class _$LoadingImpl implements _Loading {
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String message) error,
|
||||
required TResult Function(List<ItemOrder> transactionReport) loaded,
|
||||
required TResult Function(List<Order> transactionReport) loaded,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
@@ -583,7 +583,7 @@ class _$LoadingImpl implements _Loading {
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String message)? error,
|
||||
TResult? Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult? Function(List<Order> transactionReport)? loaded,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
@@ -594,7 +594,7 @@ class _$LoadingImpl implements _Loading {
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String message)? error,
|
||||
TResult Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult Function(List<Order> transactionReport)? loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
@@ -716,7 +716,7 @@ class _$ErrorImpl implements _Error {
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String message) error,
|
||||
required TResult Function(List<ItemOrder> transactionReport) loaded,
|
||||
required TResult Function(List<Order> transactionReport) loaded,
|
||||
}) {
|
||||
return error(message);
|
||||
}
|
||||
@@ -727,7 +727,7 @@ class _$ErrorImpl implements _Error {
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String message)? error,
|
||||
TResult? Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult? Function(List<Order> transactionReport)? loaded,
|
||||
}) {
|
||||
return error?.call(message);
|
||||
}
|
||||
@@ -738,7 +738,7 @@ class _$ErrorImpl implements _Error {
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String message)? error,
|
||||
TResult Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult Function(List<Order> transactionReport)? loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
@@ -803,7 +803,7 @@ abstract class _$$LoadedImplCopyWith<$Res> {
|
||||
_$LoadedImpl value, $Res Function(_$LoadedImpl) then) =
|
||||
__$$LoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({List<ItemOrder> transactionReport});
|
||||
$Res call({List<Order> transactionReport});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -825,7 +825,7 @@ class __$$LoadedImplCopyWithImpl<$Res>
|
||||
null == transactionReport
|
||||
? _value._transactionReport
|
||||
: transactionReport // ignore: cast_nullable_to_non_nullable
|
||||
as List<ItemOrder>,
|
||||
as List<Order>,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -833,12 +833,12 @@ class __$$LoadedImplCopyWithImpl<$Res>
|
||||
/// @nodoc
|
||||
|
||||
class _$LoadedImpl implements _Loaded {
|
||||
const _$LoadedImpl(final List<ItemOrder> transactionReport)
|
||||
const _$LoadedImpl(final List<Order> transactionReport)
|
||||
: _transactionReport = transactionReport;
|
||||
|
||||
final List<ItemOrder> _transactionReport;
|
||||
final List<Order> _transactionReport;
|
||||
@override
|
||||
List<ItemOrder> get transactionReport {
|
||||
List<Order> get transactionReport {
|
||||
if (_transactionReport is EqualUnmodifiableListView)
|
||||
return _transactionReport;
|
||||
// ignore: implicit_dynamic_type
|
||||
@@ -877,7 +877,7 @@ class _$LoadedImpl implements _Loaded {
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String message) error,
|
||||
required TResult Function(List<ItemOrder> transactionReport) loaded,
|
||||
required TResult Function(List<Order> transactionReport) loaded,
|
||||
}) {
|
||||
return loaded(transactionReport);
|
||||
}
|
||||
@@ -888,7 +888,7 @@ class _$LoadedImpl implements _Loaded {
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String message)? error,
|
||||
TResult? Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult? Function(List<Order> transactionReport)? loaded,
|
||||
}) {
|
||||
return loaded?.call(transactionReport);
|
||||
}
|
||||
@@ -899,7 +899,7 @@ class _$LoadedImpl implements _Loaded {
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String message)? error,
|
||||
TResult Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult Function(List<Order> transactionReport)? loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
@@ -947,9 +947,9 @@ class _$LoadedImpl implements _Loaded {
|
||||
}
|
||||
|
||||
abstract class _Loaded implements TransactionReportState {
|
||||
const factory _Loaded(final List<ItemOrder> transactionReport) = _$LoadedImpl;
|
||||
const factory _Loaded(final List<Order> transactionReport) = _$LoadedImpl;
|
||||
|
||||
List<ItemOrder> get transactionReport;
|
||||
List<Order> get transactionReport;
|
||||
|
||||
/// Create a copy of TransactionReportState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
||||
@@ -5,6 +5,6 @@ class TransactionReportState with _$TransactionReportState {
|
||||
const factory TransactionReportState.initial() = _Initial;
|
||||
const factory TransactionReportState.loading() = _Loading;
|
||||
const factory TransactionReportState.error(String message) = _Error;
|
||||
const factory TransactionReportState.loaded(
|
||||
List<ItemOrder> transactionReport) = _Loaded;
|
||||
const factory TransactionReportState.loaded(List<Order> transactionReport) =
|
||||
_Loaded;
|
||||
}
|
||||
|
||||
@@ -2,20 +2,19 @@ import 'dart:developer';
|
||||
|
||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
|
||||
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||
import 'package:enaklo_pos/core/utils/helper_pdf_service.dart';
|
||||
import 'package:enaklo_pos/presentation/report/widgets/report_page_title.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:enaklo_pos/core/utils/permession_handler.dart';
|
||||
import 'package:enaklo_pos/core/utils/transaction_sales_invoice.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:horizontal_data_table/horizontal_data_table.dart';
|
||||
|
||||
class TransactionReportWidget extends StatelessWidget {
|
||||
final String title;
|
||||
final String searchDateFormatted;
|
||||
final List<ItemOrder> transactionReport;
|
||||
final List<Order> transactionReport;
|
||||
final List<Widget>? headerWidgets;
|
||||
const TransactionReportWidget({
|
||||
super.key,
|
||||
@@ -91,86 +90,88 @@ class TransactionReportWidget extends StatelessWidget {
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
transactionReport[index].total!.currencyFormatRp,
|
||||
transactionReport[index]
|
||||
.totalAmount!
|
||||
.currencyFormatRp,
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
width: 120,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
transactionReport[index].subTotal!.currencyFormatRp,
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
width: 100,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
transactionReport[index].tax!.currencyFormatRp,
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
width: 100,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
int.parse(transactionReport[index]
|
||||
.discountAmount!
|
||||
.replaceAll('.00', ''))
|
||||
.currencyFormatRp,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 100,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
transactionReport[index]
|
||||
.serviceCharge!
|
||||
.currencyFormatRp,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 100,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
transactionReport[index].totalItem.toString()),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 150,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(transactionReport[index].namaKasir!),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 230,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(transactionReport[index]
|
||||
.transactionTime!
|
||||
.toFormattedDate()),
|
||||
),
|
||||
),
|
||||
// Container(
|
||||
// width: 120,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// transactionReport[index].subTotal!.currencyFormatRp,
|
||||
// )),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 100,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// transactionReport[index].tax!.currencyFormatRp,
|
||||
// )),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 100,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// int.parse(transactionReport[index]
|
||||
// .discountAmount!
|
||||
// .replaceAll('.00', ''))
|
||||
// .currencyFormatRp,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 100,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// transactionReport[index]
|
||||
// .serviceCharge!
|
||||
// .currencyFormatRp,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 100,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// transactionReport[index].totalItem.toString()),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 150,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(transactionReport[index].namaKasir!),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 230,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(transactionReport[index]
|
||||
// .transactionTime!
|
||||
// .toFormattedDate()),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user