/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.arrebol.taxiservicios.controller.sp.report;

import com.arrebol.taxiservicios.model.admin.Sale;
import com.arrebol.taxiservicios.model.sp.report.ReportCustomerPay;
import com.arrebol.taxiservicios.model.stocktaking.Invoice;
import com.arrebol.taxiservicios.model.stocktaking.ServiceOrder;
import java.util.Calendar;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Picasso
 */
public class ReportCustomerPayControllerTest {

    private ReportCustomerPayController controller;
    private final String START_DATE = "2021-04-04";
    private final String END_DATE = "2021-05-04";
    private final String TAXI_ID = "82e456a7-3795-48ff-a54a-3d72cc6cc2cf";

    public ReportCustomerPayControllerTest() {
    }

    @Before
    public void setUp() {
        controller = new ReportCustomerPayController();
    }

    //@Test
    public void callReportCustomerPayToMySQLQuery() {
        try {
            List<ReportCustomerPay> list = controller.callReportCustomerPayToMySQLQuery(START_DATE, END_DATE, TAXI_ID);

            list.forEach(System.out::println);
            assertFalse(list.isEmpty());
        } catch (Exception e) {
            assertFalse(true);
        }
    }

    //@Test
    public void fillInvoiceDatatableLeftJoin() {
        try {
            Calendar star = Calendar.getInstance();
            Calendar end = Calendar.getInstance();

            star.add(Calendar.YEAR, 2018);
            star.add(Calendar.DAY_OF_MONTH, 04);
            star.add(Calendar.MONTH, 03);

            end.add(Calendar.YEAR, 2021);
            end.add(Calendar.DAY_OF_MONTH, 04);
            end.add(Calendar.MONTH, 04);

            List<Invoice> list = controller.fillInvoiceDatatableLeftJoin(TAXI_ID, star.getTime(), end.getTime());

            list.forEach(System.out::println);
            assertFalse(list.isEmpty());
        } catch (Exception e) {
            assertFalse(true);
        }
    }

    //@Test
    public void testDates() {
        Calendar start = Calendar.getInstance();

        System.out.println(start.getTime());

        start.set(Calendar.WEEK_OF_YEAR, start.get(Calendar.WEEK_OF_YEAR) - 1);
        start.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);

        System.out.println(start.getTime());
    }

    //@Test
    public void getAllServiceOrderActiveAndStatusInTuple() {
        Calendar start = Calendar.getInstance();
        Calendar end = Calendar.getInstance();

        start.set(2021, 7, 4);
        end.set(2021, 11, 20);

        List<ServiceOrder> results = controller.getAllServiceOrderActiveAndStatusInTuple("82e456a7-3795-48ff-a54a-3d72cc6cc2cf", start.getTime(), end.getTime());

        results.forEach(System.out::println);

        assertFalse(results.isEmpty());
    }

    @Test
    public void getSalesbyTaxiTuple() {
        Calendar start = Calendar.getInstance();
        Calendar end = Calendar.getInstance();

        start.set(2021, 7, 4);
        end.set(2021, 11, 20);

        List<Sale> results = controller.getSalesbyTaxiTuple("82e456a7-3795-48ff-a54a-3d72cc6cc2cf", start.getTime(), end.getTime());

        results.forEach(System.out::println);

        assertFalse(results.isEmpty());
    }
}
