package com.jwipc.finance.controller;


import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import static com.jwipc.finance.constant.ModuleConst.MODULE_ROOT;

/**
 * <p>
 *     入库凭证查询 前台控制器
 * </p>
 *
 * @author shenyang.ou
 * @version 1.0
 * @since 2024/03/04
 */
@Controller
@RequestMapping(MODULE_ROOT + "/receipt/voucher")
@RequiredArgsConstructor
public class ReceiptVoucherPageController {

    /**
     * 入库凭证查询首页
     *
     * @return 页面
     */
    @GetMapping("/index")
    public String index(Model model){
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        Date theDate = calendar.getTime();
        GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance();
        gcLast.setTime(theDate);
        //设置为第一天
        gcLast.set(Calendar.DAY_OF_MONTH, 1);
        String dayFirst = sf.format(gcLast.getTime());
        //当前月  开始
        model.addAttribute("begin_time", dayFirst);
        //设置日期为本月最大日期
        calendar.set(Calendar.DATE, calendar.getActualMaximum(calendar.DATE));
        //设置日期格式
        String endTime = sf.format(calendar.getTime());
        //当前月  结束
        model.addAttribute("end_time", endTime);
        return MODULE_ROOT + "/receive/index";
    }

    @GetMapping("/updateRatioPage")
    public String updateRatioPage(String ids, Model model){
        model.addAttribute("ids",ids);
        return MODULE_ROOT + "/receive/update_ratio_page";
    }

    @GetMapping("/updatePaymentTermPage")
    public String updatePaymentTermPage(String ids, Model model){
        model.addAttribute("ids",ids);
        return MODULE_ROOT + "/receive/update_payment_page";
    }

    @RequestMapping("/importRatioPage")
    public String importRatioPage() {
        return MODULE_ROOT + "/receive/import_ratio_page";
    }

    @RequestMapping("/importTaxPricePage")
    public String importTaxPricePage() {
        return MODULE_ROOT + "/receive/import_tax_price_page";
    }
}
