You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
168 lines
4.9 KiB
168 lines
4.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Domain.Entities.Auditing;
|
|
using Volo.Abp.Guids;
|
|
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
|
|
|
|
namespace Win_in.Sfs.Scp.WebApi
|
|
{
|
|
/// <summary>
|
|
/// 采购订单主表
|
|
/// </summary>
|
|
public class PurchaseOrder: EntityBase<Guid>
|
|
{
|
|
/// <summary>
|
|
/// 订单号(PoNumber)
|
|
/// </summary>
|
|
[Display(Name = "订单号(PoNumber)")]
|
|
public string PoNumber { set; get; }
|
|
|
|
/// <summary>
|
|
/// 供应商代码(SupplierCode)
|
|
/// </summary>
|
|
[Display(Name = "供应商代码(SupplierCode)")]
|
|
public string SupplierCode { set; get; }
|
|
|
|
/// <summary>
|
|
/// 订单类型(PoType)
|
|
/// </summary>
|
|
[Display(Name = "订单类型(PoType)")]
|
|
public string PoType { set; get; }
|
|
|
|
/// <summary>
|
|
/// 订单状态(Status)
|
|
/// </summary>
|
|
[Display(Name = "订单状态(Status)")]
|
|
public int Status { set; get; }
|
|
|
|
/// <summary>
|
|
/// 是否寄存订单(IsConsignment)
|
|
/// </summary>
|
|
[Display(Name = "是否寄存订单(IsConsignment)")]
|
|
public bool IsConsignment { set; get; }
|
|
|
|
/// <summary>
|
|
/// 订单日期(OrderDate)
|
|
/// </summary>
|
|
[Display(Name = "订单日期(OrderDate)")]
|
|
public DateTime OrderDate { set; get; }
|
|
|
|
/// <summary>
|
|
/// 截止日期(DueDate)
|
|
/// </summary>
|
|
[Display(Name = "截止日期(DueDate)")]
|
|
public DateTime DueDate { set; get; }
|
|
|
|
/// <summary>
|
|
/// 版本(version)
|
|
/// </summary>
|
|
[Display(Name = "版本")]
|
|
public string Version { get; set; }
|
|
|
|
/// <summary>
|
|
/// 税率(TaxRate)
|
|
/// </summary>
|
|
[Display(Name = "税率(TaxRate)")]
|
|
public decimal? TaxRate { set; get; }
|
|
|
|
/// <summary>
|
|
/// 联系人(ContactName)
|
|
/// </summary>
|
|
[Display(Name = "联系人(ContactName)")]
|
|
public string ContactName { set; get; }
|
|
|
|
/// <summary>
|
|
/// 联系电话(ContactPhone)
|
|
/// </summary>
|
|
[Display(Name = "联系电话(ContactPhone)")]
|
|
public string ContactPhone { set; get; }
|
|
|
|
/// <summary>
|
|
/// 备注(Remark)
|
|
/// </summary>
|
|
[Display(Name = "备注(Remark)")]
|
|
public string Remark { set; get; }
|
|
|
|
|
|
/// <summary>
|
|
/// 地点(Site)
|
|
/// </summary>
|
|
[Display(Name = "地点(Site)")]
|
|
public string Site { set; get; }
|
|
|
|
/// <summary>
|
|
/// 公司(Company)
|
|
/// </summary>
|
|
[Display(Name = "公司(Company)")]
|
|
public string Company { set; get; }
|
|
|
|
public virtual ICollection<PurchaseOrderDetail> Details { get; set; }
|
|
|
|
|
|
#region details handler
|
|
public virtual void AddDetail(IGuidGenerator guidGenerator, PurchaseOrderDetail detail)
|
|
{
|
|
Check.NotNull(guidGenerator, nameof(guidGenerator));
|
|
Check.NotNull(detail, nameof(PurchaseOrderDetail));
|
|
if (IsInDetails(detail.PoNumber,detail.PoLine))
|
|
{
|
|
throw new Exception(detail.PoNumber+ detail.PoLine + "已经在明细中存在!");
|
|
}
|
|
|
|
Details.Add(new PurchaseOrderDetail(guidGenerator.Create(),detail.PoNumber, detail.PoLine, detail.PartCode, detail.Uom, detail.OrderQty,detail.StdPackUom, detail.StdPackQty,
|
|
detail.SupplierPackConvertRate, detail.IsConsignment, detail.LineStatus, detail.Remark));
|
|
}
|
|
|
|
public virtual void AddDetails(IGuidGenerator guidGenerator, IEnumerable<PurchaseOrderDetail> details)
|
|
{
|
|
Check.NotNull(guidGenerator, nameof(guidGenerator));
|
|
foreach (var detail in details)
|
|
{
|
|
AddDetail(guidGenerator, detail);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public virtual bool IsInDetails(string ponumber , string poline)
|
|
{
|
|
return Details.Any(di => di.PoNumber == ponumber && di.PoLine == poline);
|
|
}
|
|
|
|
public virtual bool IsInDetails(Guid itemId)
|
|
{
|
|
return Details.Any(di => di.Id == itemId);
|
|
}
|
|
|
|
public virtual bool UpdateDetail(IGuidGenerator guidGenerator, PurchaseOrderDetail detail)
|
|
{
|
|
Check.NotNull(detail, nameof(PurchaseOrderDetail));
|
|
|
|
var item = FindDetail(detail.Id);
|
|
|
|
if (item == null)
|
|
{
|
|
AddDetail(guidGenerator, detail);
|
|
}
|
|
else
|
|
{
|
|
Check.NotNull(item, nameof(PurchaseOrderDetail));
|
|
|
|
//item.Set(detail.Remark, detail.Enabled);
|
|
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public virtual PurchaseOrderDetail FindDetail(Guid itemId)
|
|
{
|
|
var item = Details.FirstOrDefault(p => p.Id == itemId);
|
|
return item;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|