import 'package:drift/drift.dart';
import 'package:niogu_app/core/database/tables/outlets.dart';
import 'package:uuid/uuid.dart';

class OutletInventories extends Table {
  TextColumn get localId => text().clientDefault(() => const Uuid().v7().toString())();
  TextColumn get serverId => text().nullable()();
  TextColumn get outletId => text().references(Outlets, #localId)();
  TextColumn get itemType => text()();
  TextColumn get itemId => text()();
  TextColumn get stockType => text().withDefault(const Constant("fixed"))();
  RealColumn get stock => real().withDefault(const Constant(0.0))();
  RealColumn get sellingPrice => real().withDefault(const Constant(0.0))();
  RealColumn get costPrice => real().withDefault(const Constant(0.0))();
  RealColumn get purchasePrice => real().withDefault(const Constant(0.0))();
  BoolColumn get isDeleteByOwner => boolean().nullable()();
  TextColumn get syncStatus => text().withDefault(const Constant("dirty"))();
  DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
  DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
  DateTimeColumn get deletedAt => dateTime().nullable()();

  @override
  // TODO: implement primaryKey
  Set<Column<Object>>? get primaryKey => {localId};
}