QueenFruits/Mobile Operasional/lib/features/stock_in/domain/entities/stock_in.dart

201 lines
5.1 KiB
Dart

import 'package:niogu_app/core/enums/item_type.dart';
import 'package:niogu_app/core/enums/payment_status.dart';
import 'package:niogu_app/core/enums/stock_card_type.dart';
import 'package:niogu_app/core/enums/sync_status.dart';
import 'package:uuid/uuid.dart';
enum DisplayItemEmpty { loading, empty_database, empty_search_result, has_data }
class DisplayItem {
final String id;
final String itemId;
final String? localImagePath;
final String name;
final String? variantName;
final double costPrice;
final double purchasePrice;
final double remainingStock;
final String unit;
final double sellingPrice;
const DisplayItem({
required this.id,
required this.itemId,
this.localImagePath,
required this.name,
this.variantName,
required this.costPrice,
required this.purchasePrice,
required this.remainingStock,
required this.unit,
required this.sellingPrice,
});
}
enum SelectedItemType { production, transfer_in, purchase }
class SelectedItem {
final String id;
final ItemType itemType;
final String itemId;
final String? localImagePath;
final String name;
final String? variantName;
final double costPrice;
final double purchasePrice;
final double remainingStock;
final String unit;
final double sellingPrice;
final double quantity;
final SelectedItemType type;
const SelectedItem({
required this.id,
required this.itemType,
required this.itemId,
this.localImagePath,
required this.name,
this.variantName,
required this.costPrice,
required this.purchasePrice,
required this.remainingStock,
required this.unit,
required this.sellingPrice,
this.quantity = 1.0,
required this.type,
});
SelectedItem copyWith({double? quantity}) {
return SelectedItem(
id: id,
itemType: itemType,
itemId: itemId,
localImagePath: localImagePath,
name: name,
variantName: variantName,
costPrice: costPrice,
remainingStock: remainingStock,
unit: unit,
sellingPrice: sellingPrice,
quantity: quantity ?? this.quantity,
purchasePrice: purchasePrice,
type: type,
);
}
}
class UpdateStockItem {
final String id;
final String outletInventoryId;
final StockCardType stockCardType;
final String? receiveFromId;
final double remainingStock;
final double qtyChange;
final double updateStock;
final double currentStock;
final double purchasePrice;
final double costPrice;
final String? referenceId;
final String? documentNumber;
final String? notes;
final SyncStatus syncStatus;
UpdateStockItem({
required this.outletInventoryId,
required this.stockCardType,
this.receiveFromId,
required this.remainingStock,
required this.qtyChange,
required this.updateStock,
required this.currentStock,
required this.costPrice,
required this.purchasePrice,
this.referenceId,
this.documentNumber,
this.notes,
this.syncStatus = SyncStatus.dirty,
}) : id = const Uuid().v7().toString();
}
class SupplierInformation {
final String localId;
final String name;
final String phoneNumber;
final String address;
SupplierInformation({
String? localId,
required this.name,
required this.phoneNumber,
required this.address,
}) : this.localId = localId ?? const Uuid().v7().toString();
}
class OtherInformation {
final double discount;
final double tax;
final String? note;
const OtherInformation({this.discount = 0.0, this.tax = 0.0, this.note});
}
class NewPurchase {
final String localId;
final String? supplierId;
final String? supplierNameSnapshot;
final String? supplierPhoneNumberSnapshot;
final double totalPurchase;
final OtherInformation otherInformation;
final PaymentStatus paymentStatus;
final double totalAmount;
final double amountPaid;
final double changeAmount;
final double underPaymentAmount;
final double debtAmount;
final String? paymentProofPath;
final SyncStatus syncStatus;
NewPurchase({
this.supplierId,
this.supplierNameSnapshot,
this.supplierPhoneNumberSnapshot,
required this.totalPurchase,
required this.paymentStatus,
required this.totalAmount,
required this.otherInformation,
required this.amountPaid,
required this.changeAmount,
required this.underPaymentAmount,
required this.debtAmount,
this.paymentProofPath,
this.syncStatus = SyncStatus.dirty,
}) : this.localId = const Uuid().v7().toString();
}
class ItemPurchase {
final String localId;
final String purchaseId;
final ItemType itemType;
final String itemId;
final double quantity;
final String? imagePath;
final String itemNameSnapshot;
final String? itemVariantNameSnapshot;
final double purchasePriceSnaphot;
final double subtotal;
final SyncStatus syncStatus;
ItemPurchase({
required this.purchaseId,
required this.itemType,
required this.itemId,
required this.quantity,
required this.imagePath,
required this.itemNameSnapshot,
required this.itemVariantNameSnapshot,
required this.purchasePriceSnaphot,
required this.subtotal,
this.syncStatus = SyncStatus.dirty,
}) : localId = const Uuid().v7().toString();
}