const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");

class TaxinfoService extends ServiceBase {
    constructor() {
        super("all", ServiceBase.getDaoName(TaxinfoService));
    }

    async signPage(params) {
        var currentPage = Number(params.currentPage || 0);
        var pageSize = Number(params.pageSize || 10);

        var where = {};
        if (params.id_no) {
            where.id_no = {
                [this.db.Op.like]: "%" + params.id_no + "%"
            };
        }
        if(params.sign_body){
            where.sign_body = params.sign_body;
        }
        if(params.id_no){
            where.id_no = params.id_no
        }
        this.addWhereTime(where, 'tax_time', params.signBegin, params.signEnd, true);
        var orderby = [
            ["id", 'desc']
        ];
        var attributes = [`id`, `company_name`, `name`, `id_no`, `actual_amount`, `income_tax`, `tax_time`, `sign_body`];
        var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
        if (page && page.rows) {
            for (var row of page.rows) {
                this.handleDate(row, ["tax_time"]);
            }
        }
        return page;
    }

}

module.exports = TaxinfoService;