using System.ComponentModel; using DS.Module.Core; using DS.Module.Core.Data; using DS.WMS.Core.Info.Entity; using DS.WMS.Core.Op.Entity; using SqlSugar; namespace DS.WMS.Core.Fee.Entity { /// /// 费用记录 /// [SugarTable("fee_record", TableDescription = "费用记录")] public class FeeRecord : BaseModelV2 { /// /// 业务Id /// [SugarColumn(ColumnDescription = "业务Id")] public long BusinessId { get; set; } /// /// 业务类型 /// [SugarColumn(ColumnDescription = "业务类型")] public BusinessType BusinessType { get; set; } /// /// 费用状态 /// [SugarColumn(ColumnDescription = "费用状态", DefaultValue = "1")] public FeeStatus FeeStatus { get; set; } = FeeStatus.Entering; /// /// 收付类型(收、付) 1应收 2 应付 /// [SugarColumn(ColumnDescription = "收付类型(收、付)", IsNullable = false, DefaultValue = "1")] public FeeType FeeType { get; set; } /// /// 费用Id /// [SugarColumn(ColumnDescription = "费用Id")] public long FeeId { get; set; } [Navigate(NavigateType.OneToOne, nameof(FeeId))] public FeeCode Fee { get; set; } /// /// 费用代码 录入费用是作为检索 /// [SugarColumn(ColumnDescription = "费用代码", Length = 50, IsNullable = true)] public string? FeeCode { get; set; } /// /// 费用名称 /// [SugarColumn(ColumnDescription = "费用名称", Length = 100, IsNullable = true)] public string FeeName { get; set; } /// /// 费用英文名称 /// [SugarColumn(ColumnDescription = "费用英文名称", Length = 100, IsNullable = true)] public string? FeeEnName { get; set; } /// /// 费用对象名称 /// [SugarColumn(ColumnDescription = "费用对象名称", Length = 100, IsNullable = true)] public string CustomerName { get; set; } /// /// 费用对象编码 /// [SugarColumn(ColumnDescription = "费用对象编码", Length = 100, IsNullable = true)] public string CustomerCode { get; set; } /// /// 费用对象Id /// [SugarColumn(ColumnDescription = "费用对象Id")] public long CustomerId { get; set; } [Navigate(NavigateType.OneToOne, nameof(CustomerId))] public InfoClient Customer { get; set; } /// /// 客户类别 /// [SugarColumn(ColumnDescription = "客户类别", Length = 50, IsNullable = true)] public string? CustomerType { get; set; } /// /// 客户类别文本 /// [SugarColumn(ColumnDescription = "客户类别文本", Length = 50, IsNullable = true)] public string CustomerTypeText { get; set; } /// /// 费用标准 /// [SugarColumn(ColumnDescription = "费用标准", Length = 20, IsNullable = true)] public string? Unit { get; set; } /// /// 费用标准文本 /// [SugarColumn(ColumnDescription = "费用标准文本", Length = 50, IsNullable = true)] public string UnitText { get; set; } /// /// 不含税单价 /// [SugarColumn(ColumnDescription = "不含税单价", IsNullable = true, Length = 18, DecimalDigits = 4, DefaultValue = "0")] public decimal UnitPrice { get; set; } /// /// 数量 /// [SugarColumn(ColumnDescription = "数量", IsNullable = true, Length = 10, DecimalDigits = 2, DefaultValue = "0")] public decimal Quantity { get; set; } = 1m; /// /// 金额 /// [SugarColumn(ColumnDescription = "金额", IsNullable = true, Length = 18, DecimalDigits = 2, DefaultValue = "0")] public decimal Amount { get; set; } /// /// 币别 /// [SugarColumn(ColumnDescription = "币别", Length = 20)] public string Currency { get; set; } /// /// 币别文本 /// [SugarColumn(ColumnDescription = "币别文本", Length = 50, IsNullable = true)] public string CurrencyText { get; set; } /// /// 汇率 /// [SugarColumn(ColumnDescription = "汇率", IsNullable = true, Length = 18, DecimalDigits = 5, DefaultValue = "1")] public decimal? ExchangeRate { get; set; } /// /// 驳回原因 /// [SugarColumn(ColumnDescription = "驳回原因", Length = 100, IsNullable = true)] public string? Reason { get; set; } /// /// 备注 /// [SugarColumn(ColumnDescription = "备注", Length = 1000, IsNullable = true)] public string? Remark { get; set; } /// /// Desc:佣金比率 /// [SugarColumn(ColumnDescription = "佣金比率", Length = 18, DecimalDigits = 3, DefaultValue = "0")] public decimal CommissionRate { get; set; } /// /// 已结算金额 /// [SugarColumn(ColumnDescription = "已结算金额", Length = 18, DecimalDigits = 2, DefaultValue = "0")] public decimal SettlementAmount { get; set; } /// /// 已开票金额 /// [SugarColumn(ColumnDescription = "已开票金额", Length = 18, DecimalDigits = 2, DefaultValue = "0")] public decimal InvoiceAmount { get; set; } /// ///已申请金额 /// [SugarColumn(ColumnDescription = "已申请金额", Length = 18, DecimalDigits = 2, DefaultValue = "0")] public decimal OrderAmount { get; set; } /// /// Desc:申请开票金额 /// [SugarColumn(ColumnDescription = "申请开票金额", Length = 18, DecimalDigits = 2, DefaultValue = "0")] public decimal OrderInvoiceAmount { get; set; } /// /// 审核人Id /// [SugarColumn(ColumnDescription = "审核人Id", IsNullable = true)] public long? AuditBy { get; set; } /// /// 审核人 /// [SugarColumn(ColumnDescription = "审核人", IsNullable = true, Length = 50)] public string? AuditOperator { get; set; } /// /// 审核日期 /// [SugarColumn(ColumnDescription = "审核日期", IsNullable = true)] public DateTime? AuditDate { get; set; } /// /// 是否公开费用 /// [SugarColumn(ColumnDescription = "是否公开费用", DefaultValue = "1")] public bool IsOpen { get; set; } = true; /// /// 对帐编号 /// [SugarColumn(ColumnDescription = "对帐编号", IsNullable = true, Length = 50)] public string DebitNo { get; set; } /// /// 是否对帐 /// [SugarColumn(ColumnDescription = "是否对帐", DefaultValue = "0")] public bool IsDebit { get; set; } = false; /// /// 是否垫付费用 /// [SugarColumn(ColumnDescription = "是否垫付费用", DefaultValue = "0")] public bool IsAdvancedPay { get; set; } = false; /// /// 是否禁开发票 /// [SugarColumn(ColumnDescription = "是否禁开发票", DefaultValue = "0")] public bool IsInvoice { get; set; } = false; /// /// 是否销售订舱 /// [SugarColumn(ColumnDescription = "是否销售订舱", DefaultValue = "0")] public bool IsCrmOrderFee { get; set; } = false; /// /// 发票号 /// [SugarColumn(ColumnDescription = "发票号", IsNullable = true, Length = 200)] public string InvoiceNO { get; set; } /// /// 支票号 /// [SugarColumn(ColumnDescription = "支票号", IsNullable = true, Length = 200)] [Description("支票号")] public string ChequeNO { get; set; } /// /// 仓储编号 /// [SugarColumn(ColumnDescription = "仓储编号", IsNullable = true, Length = 100)] public string WmsOutBSNO { get; set; } /// /// 税率 /// [SugarColumn(ColumnDescription = "税率", Length = 18, DecimalDigits = 4, DefaultValue = "0")] public decimal TaxRate { get; set; } /// /// 不含税金额 /// [SugarColumn(ColumnDescription = "不含税金额", Length = 18, DecimalDigits = 2, DefaultValue = "0")] public decimal NoTaxAmount { get; set; } /// /// 财务税率 (销项税率) /// [SugarColumn(ColumnDescription = "财务税率 (销项税率)", Length = 18, DecimalDigits = 4, DefaultValue = "0")] public decimal AccTaxRate { get; set; } /// /// 是否生成凭证 /// [SugarColumn(ColumnDescription = "是否生成凭证", IsNullable = true, DefaultValue = "0")] public bool IsVou { get; set; } /// /// 报销编号 /// [SugarColumn(ColumnDescription = "报销编号", IsNullable = true, Length = 50)] public string BxId { get; set; } /// /// 税额 /// [SugarColumn(ColumnDescription = "税额", Length = 18, DecimalDigits = 2, DefaultValue = "0")] public decimal Tax { get; set; } /// /// 申请金额已结算 /// [SugarColumn(ColumnDescription = "申请金额已结算", Length = 18, DecimalDigits = 2, DefaultValue = "0")] public decimal OrderSettlementAmount { get; set; } /// /// 含税单价 /// [SugarColumn(ColumnDescription = "含税单价", Length = 18, DecimalDigits = 4, DefaultValue = "0")] public decimal TaxUnitPrice { get; set; } /// /// 申请发票金额已开票 /// [SugarColumn(ColumnDescription = "申请发票金额已开票", Length = 18, DecimalDigits = 3, DefaultValue = "0")] public decimal OrderInvSettlementAmount { get; set; } /// /// 凭证号 /// [SugarColumn(ColumnDescription = "凭证号", IsNullable = true, Length = 50)] public string VoucherNo { get; set; } /// /// /// [SugarColumn(ColumnDescription = "SalesNo", IsNullable = true, Length = 50)] public string? SalesNo { get; set; } /// /// 借款编号 /// [SugarColumn(ColumnDescription = "借款编号", IsNullable = true, Length = 50)] public string? JkId { get; set; } /// /// /// [SugarColumn(ColumnDescription = "DeliveryNo", IsNullable = true, Length = 50)] public string? DeliveryNo { get; set; } /// /// 本位币 /// [SugarColumn(ColumnDescription = "本位币", IsNullable = true, Length = 30, IsOnlyIgnoreUpdate = true)] public string? LocalCurrency { get; set; } /// /// 责任人 /// [SugarColumn(ColumnDescription = "责任人", IsNullable = true, Length = 50)] public string? Manager { get; set; } /// /// 是否财务费用 /// [SugarColumn(ColumnDescription = "是否财务费用", IsNullable = true, DefaultValue = "0")] public bool IsAcc { get; set; } /// /// /// [SugarColumn(ColumnDescription = "PaymentId", IsNullable = true, Length = 50)] public string? PaymentId { get; set; } /// /// /// [SugarColumn(ColumnDescription = "StatementNo", IsNullable = true, Length = 50)] public string? StatementNo { get; set; } /// /// 核算单位 /// [SugarColumn(ColumnDescription = "核算单位", IsNullable = true, Length = 50)] public string? SaleOrg { get; set; } /// /// 核算单位Id /// [SugarColumn(ColumnDescription = "核算单位Id", IsNullable = true)] public long? SaleOrgId { get; set; } /// /// 发票自助连接 /// [SugarColumn(ColumnDescription = "发票自助连接", IsNullable = true, Length = 50)] public string? InvLinkId { get; set; } /// /// 提交日期 /// [SugarColumn(ColumnDescription = "提交日期", IsNullable = true)] public DateTime? SubmitDate { get; set; } /// /// 提交人 /// [SugarColumn(ColumnDescription = "提交人", IsNullable = true, Length = 50)] public long? SubmitBy { get; set; } //[SugarColumn(ColumnDescription = "当前审批ID", IsNullable = true)] //public long? FlowId { get; set; } /// /// 排序 /// [SugarColumn(ColumnDescription = "排序", IsNullable = true)] public int? OrderNo { get; set; } /// /// 录入方式 /// [SugarColumn(ColumnDescription = "录入方式", IsNullable = true)] public InputMethod? InputMethod { get; set; } /// /// 费用模板Id /// [SugarColumn(ColumnDescription = "费用模板Id")] public long? TemplateId { get; set; } /// /// 通过含税单价数量 和税率 /// 计算不含税单价 不含税金额 /// public void SetTax() { if (TaxRate == 0) { if (TaxUnitPrice == 0) { TaxUnitPrice = UnitPrice; } else if (UnitPrice == 0) { UnitPrice = TaxUnitPrice; } if (Amount == 0) { Amount = NoTaxAmount; } else if (NoTaxAmount == 0) { NoTaxAmount = Amount; } } else { var taxrateb = 1 + TaxRate / 100; NoTaxAmount = Amount / taxrateb; Tax = Amount - NoTaxAmount; if (Quantity > 0) { UnitPrice = NoTaxAmount / Quantity; TaxUnitPrice = Amount / Quantity; } else { UnitPrice = NoTaxAmount; TaxUnitPrice = Amount; } } NoTaxAmount = Math.Round(UnitPrice * Quantity, 2, MidpointRounding.AwayFromZero); Amount = Math.Round(TaxUnitPrice * Quantity, 2, MidpointRounding.AwayFromZero); } } /// /// 费用录入方式 /// public enum InputMethod { /// /// 手工录入 /// [Description("手工录入")] Manual, /// /// 模板自动生成 /// [Description("模板自动生成")] Automatic } }