import 'package:fcs/domain/entities/invoice.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/entities/receipt.dart';
import 'package:fcs/pages/main/model/base_model.dart';

class InvoiceModel extends BaseModel {
  List<Invoice> invoices = [
    Invoice(
        invoiceNumber: 'A092(A)-30',
        invoiceDate: DateTime(2020, 4, 5, 12, 30),
        customerName: 'Ko Nyi',
        customerPhoneNumber: '+959 888888888',
        amount: 500,
        status: 'Pending',
        packages: [
          Package(
            shipmentNumber: "A202",
            receiverNumber: "3",
            boxNumber: "1",
            rate: 7,
            packageType: "General",
            weight: 25,
            status: "Received",
            receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
            arrivedDate: DateTime(2020, 6, 1),
          ),
          Package(
              shipmentNumber: "A202",
              receiverNumber: "3",
              boxNumber: "2",
              rate: 7,
              packageType: "General",
              weight: 20,
              status: "Received",
              arrivedDate: DateTime(2020, 6, 1),
              receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon'),
        ],
        receipts: [
          Receipt(amount: 200, date: DateTime(2020, 6, 1)),
          Receipt(amount: 100, date: DateTime(2020, 6, 16)),
        ]),
    Invoice(
        invoiceNumber: 'A092(A)-31',
        invoiceDate: DateTime(2020, 4, 5, 9, 30),
        customerName: 'Ko Aung Myo',
        customerPhoneNumber: '+959 444444444',
        amount: 300,
        status: 'Paid',
        packages: [
          Package(
              shipmentNumber: "A202",
              receiverNumber: "3",
              boxNumber: "3",
              rate: 7,
              packageType: "General",
              weight: 15,
              status: "Received",
              arrivedDate: DateTime(2020, 6, 1),
              receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon'),
          Package(
              shipmentNumber: "A202",
              receiverNumber: "2",
              boxNumber: "1",
              rate: 8,
              packageType: "Medicine",
              weight: 15,
              status: "Processing",
              arrivedDate: DateTime(2020, 6, 1),
              receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon'),
        ],
        receipts: [
          Receipt(amount: 200, date: DateTime(2020, 6, 1)),
        ]),
    Invoice(
        invoiceNumber: 'A092(A)-32',
        invoiceDate: DateTime(2020, 4, 6, 10, 10),
        customerName: 'Ko Zaw Thu',
        customerPhoneNumber: '+959 777777777',
        amount: 200,
        status: 'Paid',
        packages: [
          Package(
              shipmentNumber: "A202",
              receiverNumber: "2",
              boxNumber: "2",
              rate: 7,
              packageType: "General",
              weight: 55,
              status: "Ready to ship",
              arrivedDate: DateTime(2020, 6, 1),
              receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon'),
          Package(
              shipmentNumber: "A201",
              receiverNumber: "1",
              boxNumber: "1",
              rate: 9,
              packageType: "Dangerous",
              weight: 25,
              status: "Delivered",
              arrivedDate: DateTime(2020, 5, 21),
              receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon'),
        ],
        receipts: [
          Receipt(amount: 200, date: DateTime(2020, 6, 1)),
        ]),
    Invoice(
        invoiceNumber: 'A092(A)-33',
        invoiceDate: DateTime(2020, 4, 6, 12, 15),
        customerName: 'Ko Myo Min',
        customerPhoneNumber: '+959 555555555',
        amount: 300,
        status: 'Pending',
        receipts: [
          Receipt(amount: 200, date: DateTime(2020, 6, 1)),
        ],
        packages: [
          Package(
              shipmentNumber: "A201",
              receiverNumber: "1",
              boxNumber: "1",
              rate: 9,
              packageType: "Dangerous",
              weight: 25,
              status: "Delivered",
              arrivedDate: DateTime(2020, 5, 21),
              receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon'),
          Package(
              shipmentNumber: "A201",
              receiverNumber: "1",
              boxNumber: "2",
              rate: 7,
              packageType: "General",
              weight: 5,
              status: "Delivered",
              arrivedDate: DateTime(2020, 5, 21),
              receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon'),
        ])
  ];

  List<Invoice> get pending {
    List<Invoice> _i = invoices.where((e) => e.status == "Pending").toList()
      ..sort((e1, e2) {
        return e2.invoiceNumber.compareTo(e1.invoiceNumber);
      });
    return _i;
  }

  List<Invoice> get paided {
    return invoices.where((e) => e.status == "Paid").toList()
      ..sort((e1, e2) {
        return e2.invoiceNumber.compareTo(e1.invoiceNumber);
      });
  }

  void initUser(user) {
    super.initUser(user);
  }

  @override
  logout() async {
    invoices = [];
  }
}
