package com.example.orders;

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        ProductRepository repo = new ProductRepository();
        OrderService service = new OrderService(repo);

        List<OrderLine> lines1 = new ArrayList<OrderLine>();
        lines1.add(new OrderLine("P-001", 1));
        lines1.add(new OrderLine("P-005", 2));
        Order o1 = service.createOrder("tanaka", lines1, "GOLD", "WELCOME");
        System.out.println("created: " + o1.getId() + " total=" + o1.getTotalPrice() + " yen");

        List<OrderLine> lines2 = new ArrayList<OrderLine>();
        lines2.add(new OrderLine("P-006", 3));
        Order o2 = service.createOrder("tamura", lines2, null, null);
        System.out.println("created: " + o2.getId() + " total=" + o2.getTotalPrice() + " yen");

        System.out.println("search 'ta' -> " + service.findByCustomerPrefix("ta").size() + " orders");

        ReportGenerator gen = new ReportGenerator(repo);
        List<Order> all = new ArrayList<Order>();
        all.add(o1);
        all.add(o2);
        java.util.Calendar cal = java.util.Calendar.getInstance();
        System.out.println(gen.generateMonthlyReport(all, cal.get(java.util.Calendar.YEAR), cal.get(java.util.Calendar.MONTH) + 1));
    }
}
