split bill

This commit is contained in:
efrilm
2025-10-31 20:43:37 +07:00
parent 6b42cd86ff
commit 35f02e6b76
18 changed files with 1763 additions and 27 deletions
@@ -35,3 +35,37 @@ class PaymentItemRequest with _$PaymentItemRequest {
factory PaymentItemRequest.empty() =>
const PaymentItemRequest(orderItemId: '', amount: 0);
}
@freezed
class PaymentSplitBillRequest with _$PaymentSplitBillRequest {
const factory PaymentSplitBillRequest({
required String orderId,
required String paymentMethodId,
required String customerId,
required String customerName,
required SplitType type, // e.g., "AMOUNT" or "ITEM"
required int amount,
required List<PaymentItemSplitBillRequest> items,
}) = _PaymentSplitBillRequest;
factory PaymentSplitBillRequest.empty() => const PaymentSplitBillRequest(
orderId: '',
paymentMethodId: '',
customerId: '',
type: SplitType.unknown,
amount: 0,
items: [],
customerName: '',
);
}
@freezed
class PaymentItemSplitBillRequest with _$PaymentItemSplitBillRequest {
const factory PaymentItemSplitBillRequest({
required String orderItemId,
required int quantity,
}) = _PaymentItemSplitBillRequest;
factory PaymentItemSplitBillRequest.empty() =>
const PaymentItemSplitBillRequest(orderItemId: '', quantity: 0);
}
+1
View File
@@ -2,6 +2,7 @@ import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../common/api/api_failure.dart';
import '../../common/types/split_type.dart';
part 'order.freezed.dart';
+464
View File
@@ -2455,6 +2455,470 @@ abstract class _PaymentItemRequest implements PaymentItemRequest {
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$PaymentSplitBillRequest {
String get orderId => throw _privateConstructorUsedError;
String get paymentMethodId => throw _privateConstructorUsedError;
String get customerId => throw _privateConstructorUsedError;
String get customerName => throw _privateConstructorUsedError;
SplitType get type =>
throw _privateConstructorUsedError; // e.g., "AMOUNT" or "ITEM"
int get amount => throw _privateConstructorUsedError;
List<PaymentItemSplitBillRequest> get items =>
throw _privateConstructorUsedError;
/// Create a copy of PaymentSplitBillRequest
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$PaymentSplitBillRequestCopyWith<PaymentSplitBillRequest> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $PaymentSplitBillRequestCopyWith<$Res> {
factory $PaymentSplitBillRequestCopyWith(
PaymentSplitBillRequest value,
$Res Function(PaymentSplitBillRequest) then,
) = _$PaymentSplitBillRequestCopyWithImpl<$Res, PaymentSplitBillRequest>;
@useResult
$Res call({
String orderId,
String paymentMethodId,
String customerId,
String customerName,
SplitType type,
int amount,
List<PaymentItemSplitBillRequest> items,
});
}
/// @nodoc
class _$PaymentSplitBillRequestCopyWithImpl<
$Res,
$Val extends PaymentSplitBillRequest
>
implements $PaymentSplitBillRequestCopyWith<$Res> {
_$PaymentSplitBillRequestCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of PaymentSplitBillRequest
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? orderId = null,
Object? paymentMethodId = null,
Object? customerId = null,
Object? customerName = null,
Object? type = null,
Object? amount = null,
Object? items = null,
}) {
return _then(
_value.copyWith(
orderId: null == orderId
? _value.orderId
: orderId // ignore: cast_nullable_to_non_nullable
as String,
paymentMethodId: null == paymentMethodId
? _value.paymentMethodId
: paymentMethodId // ignore: cast_nullable_to_non_nullable
as String,
customerId: null == customerId
? _value.customerId
: customerId // ignore: cast_nullable_to_non_nullable
as String,
customerName: null == customerName
? _value.customerName
: customerName // ignore: cast_nullable_to_non_nullable
as String,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as SplitType,
amount: null == amount
? _value.amount
: amount // ignore: cast_nullable_to_non_nullable
as int,
items: null == items
? _value.items
: items // ignore: cast_nullable_to_non_nullable
as List<PaymentItemSplitBillRequest>,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$PaymentSplitBillRequestImplCopyWith<$Res>
implements $PaymentSplitBillRequestCopyWith<$Res> {
factory _$$PaymentSplitBillRequestImplCopyWith(
_$PaymentSplitBillRequestImpl value,
$Res Function(_$PaymentSplitBillRequestImpl) then,
) = __$$PaymentSplitBillRequestImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String orderId,
String paymentMethodId,
String customerId,
String customerName,
SplitType type,
int amount,
List<PaymentItemSplitBillRequest> items,
});
}
/// @nodoc
class __$$PaymentSplitBillRequestImplCopyWithImpl<$Res>
extends
_$PaymentSplitBillRequestCopyWithImpl<
$Res,
_$PaymentSplitBillRequestImpl
>
implements _$$PaymentSplitBillRequestImplCopyWith<$Res> {
__$$PaymentSplitBillRequestImplCopyWithImpl(
_$PaymentSplitBillRequestImpl _value,
$Res Function(_$PaymentSplitBillRequestImpl) _then,
) : super(_value, _then);
/// Create a copy of PaymentSplitBillRequest
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? orderId = null,
Object? paymentMethodId = null,
Object? customerId = null,
Object? customerName = null,
Object? type = null,
Object? amount = null,
Object? items = null,
}) {
return _then(
_$PaymentSplitBillRequestImpl(
orderId: null == orderId
? _value.orderId
: orderId // ignore: cast_nullable_to_non_nullable
as String,
paymentMethodId: null == paymentMethodId
? _value.paymentMethodId
: paymentMethodId // ignore: cast_nullable_to_non_nullable
as String,
customerId: null == customerId
? _value.customerId
: customerId // ignore: cast_nullable_to_non_nullable
as String,
customerName: null == customerName
? _value.customerName
: customerName // ignore: cast_nullable_to_non_nullable
as String,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as SplitType,
amount: null == amount
? _value.amount
: amount // ignore: cast_nullable_to_non_nullable
as int,
items: null == items
? _value._items
: items // ignore: cast_nullable_to_non_nullable
as List<PaymentItemSplitBillRequest>,
),
);
}
}
/// @nodoc
class _$PaymentSplitBillRequestImpl implements _PaymentSplitBillRequest {
const _$PaymentSplitBillRequestImpl({
required this.orderId,
required this.paymentMethodId,
required this.customerId,
required this.customerName,
required this.type,
required this.amount,
required final List<PaymentItemSplitBillRequest> items,
}) : _items = items;
@override
final String orderId;
@override
final String paymentMethodId;
@override
final String customerId;
@override
final String customerName;
@override
final SplitType type;
// e.g., "AMOUNT" or "ITEM"
@override
final int amount;
final List<PaymentItemSplitBillRequest> _items;
@override
List<PaymentItemSplitBillRequest> get items {
if (_items is EqualUnmodifiableListView) return _items;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_items);
}
@override
String toString() {
return 'PaymentSplitBillRequest(orderId: $orderId, paymentMethodId: $paymentMethodId, customerId: $customerId, customerName: $customerName, type: $type, amount: $amount, items: $items)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PaymentSplitBillRequestImpl &&
(identical(other.orderId, orderId) || other.orderId == orderId) &&
(identical(other.paymentMethodId, paymentMethodId) ||
other.paymentMethodId == paymentMethodId) &&
(identical(other.customerId, customerId) ||
other.customerId == customerId) &&
(identical(other.customerName, customerName) ||
other.customerName == customerName) &&
(identical(other.type, type) || other.type == type) &&
(identical(other.amount, amount) || other.amount == amount) &&
const DeepCollectionEquality().equals(other._items, _items));
}
@override
int get hashCode => Object.hash(
runtimeType,
orderId,
paymentMethodId,
customerId,
customerName,
type,
amount,
const DeepCollectionEquality().hash(_items),
);
/// Create a copy of PaymentSplitBillRequest
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PaymentSplitBillRequestImplCopyWith<_$PaymentSplitBillRequestImpl>
get copyWith =>
__$$PaymentSplitBillRequestImplCopyWithImpl<
_$PaymentSplitBillRequestImpl
>(this, _$identity);
}
abstract class _PaymentSplitBillRequest implements PaymentSplitBillRequest {
const factory _PaymentSplitBillRequest({
required final String orderId,
required final String paymentMethodId,
required final String customerId,
required final String customerName,
required final SplitType type,
required final int amount,
required final List<PaymentItemSplitBillRequest> items,
}) = _$PaymentSplitBillRequestImpl;
@override
String get orderId;
@override
String get paymentMethodId;
@override
String get customerId;
@override
String get customerName;
@override
SplitType get type; // e.g., "AMOUNT" or "ITEM"
@override
int get amount;
@override
List<PaymentItemSplitBillRequest> get items;
/// Create a copy of PaymentSplitBillRequest
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PaymentSplitBillRequestImplCopyWith<_$PaymentSplitBillRequestImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$PaymentItemSplitBillRequest {
String get orderItemId => throw _privateConstructorUsedError;
int get quantity => throw _privateConstructorUsedError;
/// Create a copy of PaymentItemSplitBillRequest
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$PaymentItemSplitBillRequestCopyWith<PaymentItemSplitBillRequest>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $PaymentItemSplitBillRequestCopyWith<$Res> {
factory $PaymentItemSplitBillRequestCopyWith(
PaymentItemSplitBillRequest value,
$Res Function(PaymentItemSplitBillRequest) then,
) =
_$PaymentItemSplitBillRequestCopyWithImpl<
$Res,
PaymentItemSplitBillRequest
>;
@useResult
$Res call({String orderItemId, int quantity});
}
/// @nodoc
class _$PaymentItemSplitBillRequestCopyWithImpl<
$Res,
$Val extends PaymentItemSplitBillRequest
>
implements $PaymentItemSplitBillRequestCopyWith<$Res> {
_$PaymentItemSplitBillRequestCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of PaymentItemSplitBillRequest
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? orderItemId = null, Object? quantity = null}) {
return _then(
_value.copyWith(
orderItemId: null == orderItemId
? _value.orderItemId
: orderItemId // ignore: cast_nullable_to_non_nullable
as String,
quantity: null == quantity
? _value.quantity
: quantity // ignore: cast_nullable_to_non_nullable
as int,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$PaymentItemSplitBillRequestImplCopyWith<$Res>
implements $PaymentItemSplitBillRequestCopyWith<$Res> {
factory _$$PaymentItemSplitBillRequestImplCopyWith(
_$PaymentItemSplitBillRequestImpl value,
$Res Function(_$PaymentItemSplitBillRequestImpl) then,
) = __$$PaymentItemSplitBillRequestImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String orderItemId, int quantity});
}
/// @nodoc
class __$$PaymentItemSplitBillRequestImplCopyWithImpl<$Res>
extends
_$PaymentItemSplitBillRequestCopyWithImpl<
$Res,
_$PaymentItemSplitBillRequestImpl
>
implements _$$PaymentItemSplitBillRequestImplCopyWith<$Res> {
__$$PaymentItemSplitBillRequestImplCopyWithImpl(
_$PaymentItemSplitBillRequestImpl _value,
$Res Function(_$PaymentItemSplitBillRequestImpl) _then,
) : super(_value, _then);
/// Create a copy of PaymentItemSplitBillRequest
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? orderItemId = null, Object? quantity = null}) {
return _then(
_$PaymentItemSplitBillRequestImpl(
orderItemId: null == orderItemId
? _value.orderItemId
: orderItemId // ignore: cast_nullable_to_non_nullable
as String,
quantity: null == quantity
? _value.quantity
: quantity // ignore: cast_nullable_to_non_nullable
as int,
),
);
}
}
/// @nodoc
class _$PaymentItemSplitBillRequestImpl
implements _PaymentItemSplitBillRequest {
const _$PaymentItemSplitBillRequestImpl({
required this.orderItemId,
required this.quantity,
});
@override
final String orderItemId;
@override
final int quantity;
@override
String toString() {
return 'PaymentItemSplitBillRequest(orderItemId: $orderItemId, quantity: $quantity)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PaymentItemSplitBillRequestImpl &&
(identical(other.orderItemId, orderItemId) ||
other.orderItemId == orderItemId) &&
(identical(other.quantity, quantity) ||
other.quantity == quantity));
}
@override
int get hashCode => Object.hash(runtimeType, orderItemId, quantity);
/// Create a copy of PaymentItemSplitBillRequest
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PaymentItemSplitBillRequestImplCopyWith<_$PaymentItemSplitBillRequestImpl>
get copyWith =>
__$$PaymentItemSplitBillRequestImplCopyWithImpl<
_$PaymentItemSplitBillRequestImpl
>(this, _$identity);
}
abstract class _PaymentItemSplitBillRequest
implements PaymentItemSplitBillRequest {
const factory _PaymentItemSplitBillRequest({
required final String orderItemId,
required final int quantity,
}) = _$PaymentItemSplitBillRequestImpl;
@override
String get orderItemId;
@override
int get quantity;
/// Create a copy of PaymentItemSplitBillRequest
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PaymentItemSplitBillRequestImplCopyWith<_$PaymentItemSplitBillRequestImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$Payment {
String get id => throw _privateConstructorUsedError;
@@ -36,4 +36,8 @@ abstract class IOrderRepository {
String type = "ITEM", // TYPE: ALL, ITEM
required List<OrderItem> orderItems,
});
Future<Either<OrderFailure, Payment>> createSplitBill(
PaymentSplitBillRequest request,
);
}