using Newtonsoft.Json;
using OASystem.Domain.Entities.PersonnelModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OASystem.Domain.ViewModels.PersonnelModule
{
    /// <summary>
    /// 工资表详情
    /// </summary>
    public class WageSheetView : Pm_WageSheet
    {

    }

    /// <summary>
    /// 工资年月 View
    /// </summary>
    public class WageYearMonthView 
    {
        public string YearMonth { get; set; }
        public string StartDate { get; set; }
        public string EndDate { get; set; }
        public int Workdays { get; set; }
    }

    /// <summary>
    /// 工资表单详情
    /// </summary>
    public class WageSheetInfoView
    {
        public int Id { get; set; }

        /// <summary>
        /// 员工Id
        /// </summary>
        public int UserId { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string? Name { get; set; }

        /// <summary>
        /// 年月
        /// </summary>
        public string? YearMonth { get; set; }

        /// <summary>
        /// 工资日期 起
        /// </summary>
        public string? StartDate { get; set; }

        /// <summary>
        /// 工资日期 止
        /// </summary>
        public string? EndDate { get; set; }

        /// <summary>
        /// 应出勤天数
        /// </summary>
        public int WorkDays { get; set; }

        /// <summary>
        /// 正常出勤天数
        /// </summary>
        public int RegularDays { get; set; }


        /// <summary>
        /// 基本工资
        /// </summary>
        public decimal Basic { get; set; }

        /// <summary>
        /// 绩效工资
        /// </summary>
        public decimal Floats { get; set; }

        /// <summary>
        /// 岗位津贴
        /// </summary>
        public decimal PostAllowance { get; set; }

        /// <summary>
        /// 保密费
        /// </summary>
        public decimal InformationSecurityFee { get; set; }


        /// <summary>
        /// 月度补贴/其他补贴
        /// </summary>
        public decimal OtherSubsidies { get; set; }

        /// <summary>
        /// 餐补
        /// </summary>
        public decimal Mealsupplement { get; set; }

        /// <summary>
        /// 代扣保险
        /// </summary>
        public decimal WithholdingInsurance { get; set; }

        /// <summary>
        /// 代扣公积金
        /// </summary>
        public decimal ReservedFunds { get; set; }

        /// <summary>
        /// 病假
        /// </summary>
        public decimal SickLeave { get; set; }

        /// <summary>
        /// 事假
        /// </summary>
        public decimal SomethingFalse { get; set; }

        /// <summary>
        /// 迟到 
        /// </summary>
        public decimal LateTo { get; set; }

        /// <summary>
        /// 早退 
        /// </summary>
        public decimal LeaveEarly { get; set; }

        /// <summary>
        /// 旷工 
        /// 小时计算 7.5小时一天
        /// </summary>
        public decimal Absenteeism { get; set; }

        /// <summary>
        /// 未打卡
        /// </summary>
        public decimal NotPunch { get; set; }

        /// <summary>
        /// 其他扣款
        /// </summary>
        public decimal OtherDeductions { get; set; }

        /// <summary>
        /// 考勤/打卡 详情
        /// </summary>
        public string Ex_ItemsRemark { get; set; }

        /// <summary>
        /// 应发合计
        /// </summary>
        public decimal Should { get; set; }

        /// <summary>
        /// 扣款合计
        /// </summary>
        public decimal TotalDeductions { get; set; }

        /// <summary>
        /// 税前合计
        /// </summary>
        public decimal BeforeTax
        {
            get
            {
                return Should - TotalDeductions;
            }
        }

        /// <summary>
        /// 代扣个税
        /// </summary>
        public decimal WithholdingTax { get; set; }

        /// <summary>
        /// 实发合计(税后工资)
        /// </summary>
        public decimal TotalRealHair { get; set; }

        /// <summary>
        /// 最后操作人
        /// </summary>
        public int LastUpdateUserId { get; set; }

        /// <summary>
        /// 最后操作人Name
        /// </summary>
        public string? LastUpdateUserName { get; set; }

        /// <summary>
        /// 最后操作时间
        /// </summary>
        public string? LastUpdateDt { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remark { get; set; }
    }


    public class WageSheetItemInfoView
    {
        /// <summary>
        /// 序号
        /// </summary>
        public int Row_Number { get; set; }

        /// <summary>
        /// 公司Id
        /// </summary>
        public int CompanyId { get; set; }

        /// <summary>
        /// 公司名称
        /// </summary>
        public string? CompanyName { get; set; }

        /// <summary>
        /// 部门Id
        /// </summary>
        public int DepId { get; set; }
        /// <summary>
        /// 部门名称
        /// </summary>
        public string? DepName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 年月
        /// </summary>
        public string? YearMonth { get; set; }

        /// <summary>
        /// 工资日期 起
        /// </summary>
        public string? StartDate { get; set; }

        /// <summary>
        /// 工资日期 止
        /// </summary>
        public string? EndDate { get; set; }

        /// <summary>
        /// 应出勤天数
        /// </summary>
        public int WorkDays { get; set; }

        /// <summary>
        /// 正常出勤天数
        /// </summary>
        public int RegularDays { get; set; }

        /// <summary>
        /// 员工Id
        /// </summary>
        public int UserId { get; set; }

        /// <summary>
        /// 员工Name
        /// </summary>
        public string? Name { get; set; }

        /// <summary>
        /// 应发合计
        /// </summary>
        public decimal Should { get; set; }

        /// <summary>
        /// 扣款合计
        /// </summary>
        public decimal TotalDeductions { get; set; }

        /// <summary>
        /// 假勤  / 打卡补卡 明细 string
        /// </summary>
        public string? Ex_ItemsRemark { get; set; }

        /// <summary>
        /// 代扣个税
        /// </summary>
        public decimal WithholdingTax { get; set; }

        /// <summary>
        /// 税前合计
        /// </summary>
        public decimal BeforeTax
        {
            get
            {
                return Should - TotalDeductions;
            }
        }

        /// <summary>
        /// 实发合计(税后工资)
        /// </summary>
        public decimal TotalRealHair { get; set; }

        /// <summary>
        /// 最后操作人
        /// </summary>
        public int LastUpdateUserId { get; set; }

        /// <summary>
        /// 员工Name
        /// </summary>
        public string? LastUpdateUserName { get; set; }

        /// <summary>
        /// 最后操作时间
        /// </summary>
        public DateTime? LastUpdateDt { get; set; }
    }


    public class ExportWageSheetItemView:Pm_WageSheet
    {
        
        /// <summary>
        /// 公司Id
        /// </summary>
        public int CompanyId { get; set; }

        /// <summary>
        /// 公司名称
        /// </summary>
        public string? CompanyName { get; set; }

        /// <summary>
        /// 部门Id
        /// </summary>
        public int DepId { get; set; }
        /// <summary>
        /// 部门名称
        /// </summary>
        public string? DepName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 年月
        /// </summary>
        public string? YearMonth { get; set; }

        /// <summary>
        /// 工资日期 起
        /// </summary>
        public string? StartDate { get; set; }

        /// <summary>
        /// 工资日期 止
        /// </summary>
        public string? EndDate { get; set; }

        /// <summary>
        /// 应出勤天数
        /// </summary>
        public int WorkDays { get; set; }

        /// <summary>
        /// 员工Id
        /// </summary>
        public int UserId { get; set; }

        /// <summary>
        /// 员工Name
        /// </summary>
        public string? Name { get; set; }

        /// <summary>
        /// 税前合计
        /// </summary>
        public decimal BeforeTax
        {
            get
            {
                return Should - TotalDeductions;
            }
        }

        /// <summary>
        /// 实发合计(税后工资)
        /// </summary>
        public decimal TotalRealHair { get; set; }

        /// <summary>
        /// 最后操作人
        /// </summary>
        public int LastUpdateUserId { get; set; }

        /// <summary>
        /// 员工Name
        /// </summary>
        public string? LastUpdateUserName { get; set; }

        /// <summary>
        /// 最后操作时间
        /// </summary>
        public DateTime? LastUpdateDt { get; set; }
    }

    /// <summary>
    /// 工资列表信息
    /// </summary>
    public class WageSheetInfos : Pm_WageSheet
    {
        public string Name { get; set; }
    }

    #region 假勤 和 打卡 统计

    /// <summary>
    /// 假期详情
    /// </summary>
    public class LeaveDetails
    {
        /// <summary>
        /// 假期类型Id
        /// </summary>
        public int TypeId { get; set; }

        /// <summary>
        /// 假期名称
        /// </summary>
        public string TypeName { get; set; }

        /// <summary>
        /// 开始日期
        /// </summary>
        public DateTime StartDt { get; set; }

        /// <summary>
        /// 结束日期
        /// </summary>
        public DateTime EndDt { get; set; }

        /// <summary>
        /// 时间展示类型：halfday-日期；hour-日期+时间
        /// </summary>
        public string DtType { get; set; }

        /// <summary>
        /// 时长单位
        /// 小时/天
        /// </summary>
        public string Unit { get; set; }

        /// <summary>
        /// 请假时长
        /// </summary>
        public decimal New_Duration { get; set; }

        /// <summary>
        /// 申请时间
        /// </summary>
        public DateTime  ApplyDt { get; set; }
    }


    public class Ex_Items
    {
        /// <summary>
        /// 类型
        /// 假勤 打卡
        /// </summary>
        public string? Type { get; set; }

        public Object Ex_ItemInfo { get; set; }
    }


    public class Ex_Item
    {
        /// <summary>
        /// 子类型Id
        /// </summary>
        public int SubTypeId { get; set; }

        /// <summary>
        /// 子类型
        /// </summary>
        public string? SubType { get; set; }

        /// <summary>
        /// 扣款金额
        /// </summary>
        public decimal Deduction { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTimeDt { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime EndTimeDt { get; set; }

        /// <summary>
        /// 请假时长
        /// </summary>
        public decimal Duration { get; set; }

        /// <summary>
        /// 请假时长，单位小时
        /// </summary>
        public string Unit { get; set; } = "小时";

        /// <summary>
        /// 请假事由
        /// </summary>
        public string? Reason { get; set; }

        /// <summary>
        /// 申请时间
        /// </summary>
        public DateTime Apply_time_dt { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        public List<string>? Approval_name { get; set; }
    }

    #endregion

    #region 法定节假日

    public class HoliDaysDataSourceView
    {
        /// <summary>
        /// 年
        /// </summary>
        public string Year { get; set; }

        public List<HolidaysInfo> Holidays { get; set; }
    }
    public class HolidaysInfo
    {
        /// <summary>
        /// 节假日期
        /// </summary>
        public string HoliDate { get; set; }

        /// <summary>
        /// 节假日 
        /// </summary>
        public string HoliName { get; set; }
    }
    #endregion
}
