public MaterialLog(string userId, DateTime time, MaterialOp type, int mode, string purpose, decimal number, decimal oldNumber, string relatedPerson, string manager, int itemId,
                           MaterialBillDetail bill, IEnumerable <MaterialBatch> batches, ProductPlan plan = null)
        {
            CreateUserId    = userId;
            MarkedDateTime  = time;
            Time            = time;
            BillId          = bill.Id;
            Code            = bill.Code;
            CategoryId      = bill.CategoryId;
            Category        = bill.Category;
            NameId          = bill.NameId;
            Name            = bill.Name;
            SpecificationId = bill.SpecificationId;
            Specification   = bill.Specification;

            BIds         = batches.Select(x => x.Id).Join();
            Batches      = batches.Select(x => x.Batch).Join();
            BatchNumbers = batches.Select(x => x.Number).Join();
            BatchAmount  = batches.Sum(x => x.Number * x.Price);

            Type          = type;
            Mode          = mode;
            Purpose       = plan?.Plan ?? purpose;
            PlanId        = plan?.Id ?? 0;
            Plan          = plan?.Plan ?? "";
            Number        = number;
            OldNumber     = oldNumber;
            RelatedPerson = relatedPerson;
            Manager       = manager;
            ItemId        = itemId;
        }
 public MaterialLog(string userId, DateTime time, MaterialOp type, int mode, string purpose, decimal number, decimal oldNumber, string relatedPerson, string manager,
                    MaterialBillDetail bill, IEnumerable <MaterialBatch> batches, ProductPlan plan = null)
     : this(userId, time, type, mode, purpose, number, oldNumber, relatedPerson, manager, 0, bill, batches, plan)
 {
 }