39 lines
2.1 KiB
Dart
39 lines
2.1 KiB
Dart
import 'package:drift/drift.dart';
|
|
import 'package:niogu_app/core/database/tables/outlets.dart';
|
|
import 'package:niogu_app/core/database/tables/suppliers.dart';
|
|
import 'package:niogu_app/core/database/tables/users.dart';
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
class Purchases extends Table {
|
|
TextColumn get localId => text().clientDefault(() => const Uuid().v7().toString())();
|
|
TextColumn get serverId => text().nullable()();
|
|
TextColumn get purchaseNumber => text().unique()();
|
|
TextColumn get outletId => text().references(Outlets, #localId)();
|
|
TextColumn get outletNameSnapshot => text()();
|
|
TextColumn get supplierId => text().references(Suppliers, #localId).nullable()();
|
|
TextColumn get supplierNameSnapshot => text().nullable()();
|
|
TextColumn get supplierEmailSnapshot => text().nullable()();
|
|
TextColumn get supplierPhoneNumberSnapshot => text().nullable()();
|
|
TextColumn get userId => text().references(Users, #localId)();
|
|
TextColumn get adminNameSnapshot => text()();
|
|
TextColumn get purchaseStatus => text()();
|
|
RealColumn get totalPurchase => real().withDefault(const Constant(0.0))();
|
|
RealColumn get discount => real().withDefault(const Constant(0.0))();
|
|
RealColumn get tax => real().withDefault(const Constant(0.0))();
|
|
TextColumn get paymentStatus => text()();
|
|
RealColumn get totalAmount => real().withDefault(const Constant(0.0))();
|
|
RealColumn get amountPaid => real().withDefault(const Constant(0.0))();
|
|
RealColumn get changeAmount => real().withDefault(const Constant(0.0))();
|
|
RealColumn get underPaymentAmount => real().withDefault(const Constant(0.0))();
|
|
RealColumn get debtAmount => real().withDefault(const Constant(0.0))();
|
|
TextColumn get paymentProofPath => text().nullable()();
|
|
TextColumn get paymentProofUrl => text().nullable()();
|
|
TextColumn get notes => text().nullable()();
|
|
TextColumn get syncStatus => text().withDefault(const Constant('dirty'))();
|
|
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
|
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
|
|
|
|
@override
|
|
// TODO: implement primaryKey
|
|
Set<Column<Object>>? get primaryKey => {localId};
|
|
} |