223 lines
5.5 KiB
Dart
223 lines
5.5 KiB
Dart
import 'package:niogu_app/core/enums/order_source.dart';
|
|
import 'package:niogu_app/core/enums/order_status.dart';
|
|
import 'package:niogu_app/core/enums/stock_type.dart';
|
|
import 'package:niogu_app/core/enums/sync_status.dart';
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
class DisplayProductPos {
|
|
final String productId;
|
|
final String productVariantId;
|
|
final String outletInventoryId;
|
|
final String? imagePath;
|
|
final String name;
|
|
final String variantName;
|
|
final double currentSold;
|
|
final StockType stockType;
|
|
final double remainingStock;
|
|
final String unitName;
|
|
final double costPrice;
|
|
final double sellingPrice;
|
|
final bool hasVariant;
|
|
|
|
DisplayProductPos({
|
|
required this.productId,
|
|
required this.productVariantId,
|
|
required this.outletInventoryId,
|
|
this.imagePath,
|
|
required this.name,
|
|
required this.variantName,
|
|
required this.currentSold,
|
|
required this.stockType,
|
|
required this.remainingStock,
|
|
required this.unitName,
|
|
required this.costPrice,
|
|
required this.sellingPrice,
|
|
required this.hasVariant,
|
|
});
|
|
}
|
|
|
|
class CartItems {
|
|
final String currentOutletId;
|
|
final String outletInventoryId;
|
|
final String id;
|
|
final String? imagePath;
|
|
final String name;
|
|
final String? variantName;
|
|
final double currentSold;
|
|
final double quantity;
|
|
final double costPrice;
|
|
final double sellingPrice;
|
|
final StockType stockType;
|
|
final double remainingStock;
|
|
final String unit;
|
|
|
|
const CartItems({
|
|
required this.currentOutletId,
|
|
required this.outletInventoryId,
|
|
required this.id,
|
|
this.imagePath,
|
|
required this.name,
|
|
this.variantName,
|
|
required this.currentSold,
|
|
this.quantity = 0.0,
|
|
required this.costPrice,
|
|
required this.sellingPrice,
|
|
required this.stockType,
|
|
required this.remainingStock,
|
|
required this.unit,
|
|
});
|
|
|
|
CartItems copyWith({double? quantity}) {
|
|
return CartItems(
|
|
currentOutletId: currentOutletId,
|
|
outletInventoryId: outletInventoryId,
|
|
id: id,
|
|
imagePath: imagePath,
|
|
name: name,
|
|
variantName: variantName,
|
|
currentSold: currentSold,
|
|
quantity: quantity ?? this.quantity,
|
|
costPrice: costPrice,
|
|
sellingPrice: sellingPrice,
|
|
stockType: stockType,
|
|
remainingStock: remainingStock,
|
|
unit: unit,
|
|
);
|
|
}
|
|
}
|
|
|
|
enum AlreadyCustomerEmpty {
|
|
loading,
|
|
empty_database,
|
|
empty_search_result,
|
|
has_data,
|
|
}
|
|
|
|
class AlreadyCustomer {
|
|
final String id;
|
|
final String name;
|
|
final String phoneNumber;
|
|
final List<String> addresses;
|
|
|
|
const AlreadyCustomer({
|
|
required this.id,
|
|
required this.name,
|
|
required this.phoneNumber,
|
|
required this.addresses,
|
|
});
|
|
}
|
|
|
|
class SelectedCustomer {
|
|
final String id;
|
|
final String outletId;
|
|
final String name;
|
|
final String phoneNumber;
|
|
final String address;
|
|
|
|
const SelectedCustomer({
|
|
required this.id,
|
|
required this.outletId,
|
|
required this.name,
|
|
required this.phoneNumber,
|
|
required this.address,
|
|
});
|
|
}
|
|
|
|
class OtherInformation {
|
|
final double discount;
|
|
final double tax;
|
|
final String? note;
|
|
|
|
const OtherInformation({this.discount = 0.0, this.tax = 0.0, this.note});
|
|
}
|
|
|
|
class CustomerInformation {
|
|
final String id;
|
|
final String name;
|
|
final String? phoneNumber;
|
|
final String? address;
|
|
|
|
CustomerInformation({
|
|
String? id,
|
|
required this.name,
|
|
this.phoneNumber,
|
|
this.address,
|
|
}) : id = id ?? const Uuid().v7().toString();
|
|
}
|
|
|
|
class NewSale {
|
|
final String localId;
|
|
final String? customerId;
|
|
final String? customerNameSnapshot;
|
|
final String? customerPhoneNumberSnapshot;
|
|
final OrderSource orderSource;
|
|
final OrderStatus orderStatus;
|
|
final double totalOrder;
|
|
final OtherInformation otherInformation;
|
|
final double totalAmount;
|
|
final double amountPaid;
|
|
final double changeAmount;
|
|
final String? paymentProofPath;
|
|
final Map<String, dynamic> customerAddressSnapshot;
|
|
final SyncStatus syncStatus;
|
|
|
|
NewSale({
|
|
this.customerId,
|
|
required this.customerNameSnapshot,
|
|
required this.customerPhoneNumberSnapshot,
|
|
this.orderSource = OrderSource.pos,
|
|
this.orderStatus = OrderStatus.completed,
|
|
required this.totalOrder,
|
|
required this.otherInformation,
|
|
required this.totalAmount,
|
|
required this.amountPaid,
|
|
required this.changeAmount,
|
|
required this.paymentProofPath,
|
|
required this.customerAddressSnapshot,
|
|
this.syncStatus = SyncStatus.dirty,
|
|
}) : localId = const Uuid().v7().toString();
|
|
}
|
|
|
|
class ItemSale {
|
|
final String localId;
|
|
final String orderId;
|
|
final String outletInventoryId;
|
|
final String productVariantId;
|
|
final StockType stockType;
|
|
final double stock;
|
|
final double currentSold;
|
|
final double quantity;
|
|
final double costPrice;
|
|
final String? productImageSnapshot;
|
|
final String productNameSnapshot;
|
|
final String? productVariantNameSnapshot;
|
|
final double sellingPriceSnapshot;
|
|
final double subtotal;
|
|
final SyncStatus syncStatus;
|
|
|
|
ItemSale({
|
|
required this.orderId,
|
|
required this.outletInventoryId,
|
|
required this.productVariantId,
|
|
required this.stockType,
|
|
required this.stock,
|
|
required this.currentSold,
|
|
required this.quantity,
|
|
required this.costPrice,
|
|
this.productImageSnapshot,
|
|
required this.productNameSnapshot,
|
|
this.productVariantNameSnapshot,
|
|
required this.sellingPriceSnapshot,
|
|
required this.subtotal,
|
|
this.syncStatus = SyncStatus.dirty,
|
|
}) : localId = const Uuid().v7().toString();
|
|
}
|
|
|
|
class UpdateTotalSold {
|
|
final String id;
|
|
final double qtySold;
|
|
final double currentSold;
|
|
|
|
const UpdateTotalSold({required this.id, required this.qtySold, required this.currentSold});
|
|
}
|