public GarmentSubconCutting(Guid identity, string roNo, SizeId sizeId, string sizeName, double quantity, ProductId productId, string productCode, string productName, GarmentComodityId comodityId, string comodityCode, string comodityName, string designColor, string remark, double basicPrice) : base(identity) { RONo = roNo; SizeId = sizeId; SizeName = sizeName; Quantity = quantity; ProductId = productId; ProductCode = productCode; ProductName = productName; ComodityId = comodityId; ComodityName = comodityName; ComodityCode = comodityCode; DesignColor = designColor; Remark = remark; BasicPrice = basicPrice; ReadModel = new GarmentSubconCuttingReadModel(Identity) { RONo = RONo, SizeId = SizeId.Value, SizeName = SizeName, Quantity = Quantity, ProductId = ProductId.Value, ProductCode = ProductCode, ProductName = ProductName, ComodityId = ComodityId.Value, ComodityName = ComodityName, ComodityCode = ComodityCode, DesignColor = DesignColor, Remark = Remark, BasicPrice = BasicPrice }; ReadModel.AddDomainEvent(new OnGarmentSubconCuttingPlaced(Identity)); }
public GarmentFinishedGoodStockHistory(GarmentFinishedGoodStockHistoryReadModel readModel) : base(readModel) { FinishedGoodStockId = readModel.FinishedGoodStockId; FinishingOutItemId = readModel.FinishingOutItemId; FinishingOutDetailId = readModel.FinishingOutDetailId; ExpenditureGoodId = readModel.ExpenditureGoodId; ExpenditureGoodItemId = readModel.ExpenditureGoodItemId; AdjustmentItemId = readModel.AdjustmentItemId; AdjustmentId = readModel.AdjustmentId; ExpenditureGoodReturnId = readModel.ExpenditureGoodReturnId; ExpenditureGoodReturnItemId = readModel.ExpenditureGoodReturnItemId; StockType = readModel.StockType; RONo = readModel.RONo; Article = readModel.Article; UnitId = new UnitDepartmentId(readModel.UnitId); UnitCode = readModel.UnitCode; UnitName = readModel.UnitName; ComodityId = new GarmentComodityId(readModel.ComodityId); ComodityCode = readModel.ComodityCode; ComodityName = readModel.ComodityName; SizeId = new SizeId(readModel.SizeId); SizeName = readModel.SizeName; Quantity = readModel.Quantity; UomUnit = readModel.UomUnit; UomId = new UomId(readModel.UomId); BasicPrice = readModel.BasicPrice; Price = readModel.Price; }
public GarmentSubconCuttingOutDetail(Guid identity, Guid cutOutItemId, SizeId sizeId, string sizeName, string color, double remainingQuantity, double cuttingOutQuantity, UomId cuttingOutUomId, string cuttingOutUomUnit, double basicPrice, double price, string remark) : base(identity) { //MarkTransient(); CutOutItemId = cutOutItemId; Color = color; SizeId = sizeId; SizeName = sizeName; RemainingQuantity = remainingQuantity; CuttingOutQuantity = cuttingOutQuantity; CuttingOutUomId = cuttingOutUomId; CuttingOutUomUnit = cuttingOutUomUnit; BasicPrice = basicPrice; Price = price; Remark = remark; ReadModel = new GarmentCuttingOutDetailReadModel(Identity) { CutOutItemId = CutOutItemId, Color = Color, SizeId = SizeId.Value, SizeName = SizeName, RemainingQuantity = RemainingQuantity, CuttingOutQuantity = CuttingOutQuantity, CuttingOutUomId = CuttingOutUomId.Value, CuttingOutUomUnit = CuttingOutUomUnit, BasicPrice = BasicPrice, Price = Price, Remark = Remark }; ReadModel.AddDomainEvent(new OnGarmentSubconCuttingOutPlaced(Identity)); }
public async Task ChangeSize(Product prod, SizeId sizeId) { var product = await _context.Products.FindAsync(prod.Id); product.UpdateSize(await GetSizeAsync(sizeId)); await _context.SaveChangesAsync(); }
public GarmentExpenditureGoodReturnItem(Guid identity, Guid returId, Guid expenditureGoodId, Guid expenditureGoodItemId, Guid finishedGoodStockId, SizeId sizeId, string sizeName, double quantity, UomId uomId, string uomUnit, string description, double basicPrice, double price) : base(identity) { ReturId = returId; ExpenditureGoodId = expenditureGoodId; ExpenditureGoodItemId = expenditureGoodItemId; FinishedGoodStockId = finishedGoodStockId; SizeId = sizeId; SizeName = sizeName; Quantity = quantity; UomId = uomId; UomUnit = uomUnit; Description = description; BasicPrice = basicPrice; Price = price; ReadModel = new GarmentExpenditureGoodReturnItemReadModel(Identity) { ReturId = ReturId, ExpenditureGoodId = ExpenditureGoodId, ExpenditureGoodItemId = ExpenditureGoodItemId, FinishedGoodStockId = FinishedGoodStockId, SizeId = SizeId.Value, SizeName = SizeName, Quantity = Quantity, UomId = UomId.Value, UomUnit = UomUnit, Description = Description, BasicPrice = BasicPrice, Price = Price }; ReadModel.AddDomainEvent(new OnGarmentExpenditureGoodReturnPlaced(Identity)); }
public void Size_created() { var sizeId = new SizeId(SequentialGuid.NewSequentialGuid()); var sut = Size.Create(sizeId, "Perfect fit"); Assert.NotNull(sut); Assert.Contains("Perfect", sut.Amount); }
public void SetSizeId(SizeId SizeId) { if (this.SizeId != SizeId) { this.SizeId = SizeId; ReadModel.SizeId = SizeId.Value; } }
public GarmentFinishingOutDetail(GarmentFinishingOutDetailReadModel readModel) : base(readModel) { FinishingOutItemId = readModel.FinishingOutItemId; SizeId = new SizeId(readModel.SizeId); SizeName = readModel.SizeName; Quantity = readModel.Quantity; UomId = new UomId(readModel.UomId); UomUnit = readModel.UomUnit; }
public GarmentCuttingOutDetail(GarmentCuttingOutDetailReadModel readModel) : base(readModel) { CutOutItemId = readModel.CutOutItemId; Color = readModel.Color; SizeId = new SizeId(readModel.SizeId); SizeName = readModel.SizeName; RemainingQuantity = readModel.RemainingQuantity; CuttingOutQuantity = readModel.CuttingOutQuantity; CuttingOutUomId = new UomId(readModel.CuttingOutUomId); CuttingOutUomUnit = readModel.CuttingOutUomUnit; BasicPrice = readModel.BasicPrice; Price = readModel.Price; }
public GarmentExpenditureGoodItem(GarmentExpenditureGoodItemReadModel readModel) : base(readModel) { ExpenditureGoodId = readModel.ExpenditureGoodId; FinishedGoodStockId = readModel.FinishedGoodStockId; SizeId = new SizeId(readModel.SizeId); SizeName = readModel.SizeName; Quantity = readModel.Quantity; ReturQuantity = readModel.ReturQuantity; UomId = new UomId(readModel.UomId); UomUnit = readModel.UomUnit; Description = readModel.Description; BasicPrice = readModel.BasicPrice; Price = readModel.Price; }
public GarmentSewingInItem(Guid identity, Guid sewingInId, Guid sewingOutItemId, Guid sewingOutDetailId, Guid loadingItemId, Guid finishingOutItemId, Guid finishingOutDetailId, ProductId productId, string productCode, string productName, string designColor, SizeId sizeId, string sizeName, double quantity, UomId uomId, string uomUnit, string color, double remainingQuantity, double basicPrice, double price) : base(identity) { Identity = identity; SewingInId = sewingInId; SewingOutItemId = sewingOutItemId; SewingOutDetailId = sewingOutDetailId; LoadingItemId = loadingItemId; FinishingOutItemId = finishingOutItemId; FinishingOutDetailId = finishingOutDetailId; ProductId = productId; ProductCode = productCode; ProductName = productName; DesignColor = designColor; SizeId = sizeId; SizeName = sizeName; Quantity = quantity; UomId = uomId; UomUnit = uomUnit; Color = color; RemainingQuantity = remainingQuantity; BasicPrice = basicPrice; Price = price; ReadModel = new GarmentSewingInItemReadModel(identity) { SewingInId = SewingInId, SewingOutItemId = SewingOutItemId, SewingOutDetailId = SewingOutDetailId, LoadingItemId = LoadingItemId, FinishingOutItemId = FinishingOutItemId, FinishingOutDetailId = FinishingOutDetailId, ProductId = ProductId.Value, ProductCode = ProductCode, ProductName = ProductName, DesignColor = DesignColor, SizeId = SizeId.Value, SizeName = SizeName, Quantity = Quantity, UomId = UomId.Value, UomUnit = UomUnit, Color = Color, RemainingQuantity = RemainingQuantity, BasicPrice = BasicPrice, Price = Price }; ReadModel.AddDomainEvent(new OnGarmentSewingInPlaced(Identity)); }
public GarmentFinishedGoodStock(Guid identity, string finishedGoodStockNo, string rONo, string article, UnitDepartmentId unitId, string unitCode, string unitName, GarmentComodityId comodityId, string comodityCode, string comodityName, SizeId sizeId, string sizeName, UomId uomId, string uomUnit, double quantity, double basicPrice, double price) : base(identity) { Validator.ThrowIfNull(() => unitId); Validator.ThrowIfNull(() => rONo); //MarkTransient(); Identity = identity; FinishedGoodStockNo = finishedGoodStockNo; RONo = rONo; Article = article; UnitId = unitId; UnitCode = unitCode; UnitName = unitName; ComodityId = comodityId; ComodityCode = comodityCode; ComodityName = comodityName; SizeId = sizeId; SizeName = sizeName; Quantity = quantity; UomId = uomId; UomUnit = uomUnit; BasicPrice = basicPrice; Price = price; ReadModel = new GarmentFinishedGoodStockReadModel(Identity) { FinishedGoodStockNo = FinishedGoodStockNo, RONo = RONo, Article = Article, UnitId = UnitId.Value, UnitCode = UnitCode, UnitName = UnitName, ComodityId = ComodityId.Value, ComodityCode = ComodityCode, ComodityName = ComodityName, SizeId = SizeId.Value, SizeName = SizeName, Quantity = Quantity, UomId = UomId.Value, UomUnit = UomUnit, BasicPrice = BasicPrice, Price = Price }; ReadModel.AddDomainEvent(new OnGarmentFinishedGoodStockPlaced(Identity)); }
public GarmentSubconCutting(GarmentSubconCuttingReadModel readModel) : base(readModel) { RONo = readModel.RONo; SizeId = new SizeId(readModel.SizeId); SizeName = readModel.SizeName; Quantity = readModel.Quantity; FinishingInQuantity = readModel.FinishingInQuantity; ProductId = new ProductId(readModel.ProductId); ProductCode = readModel.ProductCode; ProductName = readModel.ProductName; ComodityId = new GarmentComodityId(readModel.ComodityId); ComodityName = readModel.ComodityName; ComodityCode = readModel.ComodityCode; DesignColor = readModel.DesignColor; Remark = readModel.Remark; BasicPrice = readModel.BasicPrice; }
public GarmentLoadingItem(GarmentLoadingItemReadModel readModel) : base(readModel) { LoadingId = readModel.LoadingId; SewingDOItemId = readModel.SewingDOItemId; ProductId = new ProductId(readModel.ProductId); ProductCode = readModel.ProductCode; ProductName = readModel.ProductCode; DesignColor = readModel.DesignColor; SizeId = new SizeId(readModel.SizeId); SizeName = readModel.SizeName; Quantity = readModel.Quantity; UomId = new UomId(readModel.UomId); UomUnit = readModel.UomUnit; Color = readModel.Color; RemainingQuantity = readModel.RemainingQuantity; BasicPrice = readModel.BasicPrice; Price = readModel.Price; }
public GarmentAvalComponentItem(GarmentAvalComponentItemReadModel readModel) : base(readModel) { AvalComponentId = readModel.AvalComponentId; CuttingInDetailId = readModel.CuttingInDetailId; SewingOutItemId = readModel.SewingOutItemId; SewingOutDetailId = readModel.SewingOutDetailId; ProductId = new ProductId((int)readModel.ProductId); ProductCode = readModel.ProductCode; ProductName = readModel.ProductName; DesignColor = readModel.DesignColor; Color = readModel.Color; Quantity = readModel.Quantity; RemainingQuantity = readModel.RemainingQuantity; SizeId = new SizeId((int)readModel.SizeId); SizeName = readModel.SizeName; Price = readModel.Price; BasicPrice = readModel.BasicPrice; }
public GarmentAdjustmentItem(Guid identity, Guid loadingId, Guid sewingDOItemId, Guid sewingInItemId, Guid finishingInItemId, Guid finishedGoodStockId, SizeId sizeId, string sizeName, ProductId productId, string productCode, string productName, string designColor, double quantity, double basicPrice, UomId uomId, string uomUnit, string color, double price) : base(identity) { Id = identity; AdjustmentId = loadingId; SewingDOItemId = sewingDOItemId; SewingInItemId = sewingInItemId; FinishingInItemId = finishingInItemId; FinishedGoodStockId = finishedGoodStockId; ProductId = productId; ProductCode = productCode; ProductName = productCode; DesignColor = designColor; SizeId = sizeId; SizeName = sizeName; Quantity = quantity; UomId = uomId; UomUnit = uomUnit; Color = color; BasicPrice = basicPrice; Price = price; ReadModel = new GarmentAdjustmentItemReadModel(Identity) { AdjustmentId = loadingId, SewingDOItemId = SewingDOItemId, SewingInItemId = SewingInItemId, FinishedGoodStockId = FinishedGoodStockId, FinishingInItemId = FinishingInItemId, ProductId = ProductId.Value, ProductCode = ProductCode, ProductName = ProductName, DesignColor = DesignColor, SizeId = SizeId.Value, SizeName = SizeName, Quantity = Quantity, UomId = UomId.Value, UomUnit = UomUnit, Color = Color, BasicPrice = BasicPrice, Price = Price }; ReadModel.AddDomainEvent(new OnGarmentAdjustmentPlaced(Identity)); }
public GarmentFinishedGoodStock(GarmentFinishedGoodStockReadModel readModel) : base(readModel) { FinishedGoodStockNo = readModel.FinishedGoodStockNo; RONo = readModel.RONo; Article = readModel.Article; UnitId = new UnitDepartmentId(readModel.UnitId); UnitCode = readModel.UnitCode; UnitName = readModel.UnitName; ComodityId = new GarmentComodityId(readModel.ComodityId); ComodityCode = readModel.ComodityCode; ComodityName = readModel.ComodityName; SizeId = new SizeId(readModel.SizeId); SizeName = readModel.SizeName; Quantity = readModel.Quantity; UomUnit = readModel.UomUnit; UomId = new UomId(readModel.UomId); BasicPrice = readModel.BasicPrice; Price = readModel.Price; }
public GarmentFinishingOutItem(GarmentFinishingOutItemReadModel readModel) : base(readModel) { FinishingOutId = readModel.FinishingOutId; FinishingInId = readModel.FinishingInId; FinishingInItemId = readModel.FinishingInItemId; ProductId = new ProductId(readModel.ProductId); ProductCode = readModel.ProductCode; ProductName = readModel.ProductName; DesignColor = readModel.DesignColor; SizeId = new SizeId(readModel.SizeId); SizeName = readModel.SizeName; Quantity = readModel.Quantity; UomId = new UomId(readModel.UomId); UomUnit = readModel.UomUnit; Color = readModel.Color; RemainingQuantity = readModel.RemainingQuantity; BasicPrice = readModel.BasicPrice; Price = readModel.Price; }
public GarmentAdjustmentItem(GarmentAdjustmentItemReadModel readModel) : base(readModel) { AdjustmentId = readModel.AdjustmentId; SewingDOItemId = readModel.SewingDOItemId; SewingInItemId = readModel.SewingInItemId; FinishingInItemId = readModel.FinishingInItemId; FinishedGoodStockId = readModel.FinishedGoodStockId; ProductId = new ProductId(readModel.ProductId); ProductCode = readModel.ProductCode; ProductName = readModel.ProductCode; DesignColor = readModel.DesignColor; SizeId = new SizeId(readModel.SizeId); SizeName = readModel.SizeName; Quantity = readModel.Quantity; UomId = new UomId(readModel.UomId); UomUnit = readModel.UomUnit; Color = readModel.Color; BasicPrice = readModel.BasicPrice; Price = readModel.Price; }
public GarmentFinishingOutDetail(Guid identity, Guid sewingOutItemId, SizeId sizeId, string sizeName, double quantity, UomId uomId, string uomUnit) : base(identity) { //MarkTransient(); FinishingOutItemId = sewingOutItemId; SizeId = sizeId; SizeName = sizeName; Quantity = quantity; UomId = uomId; UomUnit = uomUnit; ReadModel = new GarmentFinishingOutDetailReadModel(Identity) { FinishingOutItemId = FinishingOutItemId, SizeId = SizeId.Value, SizeName = SizeName, Quantity = Quantity, UomId = UomId.Value, UomUnit = UomUnit }; ReadModel.AddDomainEvent(new OnGarmentFinishingOutPlaced(Identity)); }
public GarmentAvalComponentItem(Guid Identity, Guid avalComponentId, Guid cuttingInDetailId, Guid sewingOutItemId, Guid sewingOutDetailId, ProductId productId, string productCode, string productName, string designColor, string color, double quantity, double remainingQuantity, SizeId sizeId, string sizeName, decimal price, decimal basicPrice) : base(Identity) { AvalComponentId = avalComponentId; CuttingInDetailId = cuttingInDetailId; SewingOutItemId = sewingOutItemId; SewingOutDetailId = sewingOutDetailId; ProductId = productId; ProductCode = productCode; ProductName = productName; DesignColor = designColor; Color = color; Quantity = quantity; RemainingQuantity = remainingQuantity; SizeId = sizeId; SizeName = sizeName; Price = price; BasicPrice = basicPrice; ReadModel = new GarmentAvalComponentItemReadModel(Identity) { AvalComponentId = avalComponentId, CuttingInDetailId = cuttingInDetailId, SewingOutItemId = sewingOutItemId, SewingOutDetailId = sewingOutDetailId, ProductId = productId.Value, ProductCode = productCode, ProductName = productName, DesignColor = designColor, Color = color, Quantity = quantity, RemainingQuantity = remainingQuantity, SizeId = sizeId.Value, SizeName = sizeName, Price = price, BasicPrice = basicPrice }; }
public GarmentFinishedGoodStockHistory(Guid identity, Guid finishedGoodStockId, Guid finishingOutItemId, Guid finishingOutDetailId, Guid expenditureGoodId, Guid expenditureGoodItemId, Guid adjustmentId, Guid adjustmentItemId, Guid expenditureGoodReturnId, Guid expenditureGoodReturnItemId, string stockType, string rONo, string article, UnitDepartmentId unitId, string unitCode, string unitName, GarmentComodityId comodityId, string comodityCode, string comodityName, SizeId sizeId, string sizeName, UomId uomId, string uomUnit, double quantity, double basicPrice, double price) : base(identity) { Validator.ThrowIfNull(() => unitId); Validator.ThrowIfNull(() => rONo); //MarkTransient(); Identity = identity; FinishedGoodStockId = finishedGoodStockId; FinishingOutItemId = finishingOutItemId; FinishingOutDetailId = finishingOutDetailId; ExpenditureGoodId = expenditureGoodId; ExpenditureGoodItemId = expenditureGoodItemId; ExpenditureGoodReturnId = expenditureGoodReturnId; ExpenditureGoodReturnItemId = expenditureGoodReturnItemId; AdjustmentId = adjustmentId; AdjustmentItemId = adjustmentItemId; StockType = stockType; RONo = rONo; Article = article; UnitId = unitId; UnitCode = unitCode; UnitName = unitName; ComodityId = comodityId; ComodityCode = comodityCode; ComodityName = comodityName; SizeId = sizeId; SizeName = sizeName; Quantity = quantity; UomId = uomId; UomUnit = uomUnit; BasicPrice = basicPrice; Price = price; ReadModel = new GarmentFinishedGoodStockHistoryReadModel(Identity) { FinishedGoodStockId = FinishedGoodStockId, FinishingOutItemId = FinishingOutItemId, FinishingOutDetailId = FinishingOutDetailId, ExpenditureGoodId = ExpenditureGoodId, ExpenditureGoodItemId = ExpenditureGoodItemId, ExpenditureGoodReturnId = ExpenditureGoodReturnId, ExpenditureGoodReturnItemId = ExpenditureGoodReturnItemId, AdjustmentId = AdjustmentId, AdjustmentItemId = AdjustmentItemId, StockType = StockType, RONo = RONo, Article = Article, UnitId = UnitId.Value, UnitCode = UnitCode, UnitName = UnitName, ComodityId = ComodityId.Value, ComodityCode = ComodityCode, ComodityName = ComodityName, SizeId = SizeId.Value, SizeName = SizeName, Quantity = Quantity, UomId = UomId.Value, UomUnit = UomUnit, BasicPrice = BasicPrice, Price = Price }; ReadModel.AddDomainEvent(new OnGarmentFinishedGoodStockHistoryPlaced(Identity)); }
public void Size_not_created(SizeId id, string amount) { Action sut = () => Size.Create(id, amount); Assert.Throws <ArgumentNullException>(sut.Invoke); }
public async Task <GarmentFinishingOut> Handle(PlaceGarmentFinishingOutCommand request, CancellationToken cancellationToken) { request.Items = request.Items.Where(item => item.IsSave == true).ToList(); GarmentComodityPrice garmentComodityPrice = _garmentComodityPriceRepository.Query.Where(a => a.IsValid == true && a.UnitId == request.UnitTo.Id && a.ComodityId == request.Comodity.Id).Select(s => new GarmentComodityPrice(s)).Single(); Guid garmentFinishingOutId = Guid.NewGuid(); GarmentFinishingOut garmentFinishingOut = new GarmentFinishingOut( garmentFinishingOutId, GenerateFinOutNo(request), new UnitDepartmentId(request.UnitTo.Id), request.UnitTo.Code, request.UnitTo.Name, request.FinishingTo, request.FinishingOutDate.GetValueOrDefault(), request.RONo, request.Article, new UnitDepartmentId(request.Unit.Id), request.Unit.Code, request.Unit.Name, new GarmentComodityId(request.Comodity.Id), request.Comodity.Code, request.Comodity.Name, request.IsDifferentSize ); Dictionary <Guid, double> finishingInItemToBeUpdated = new Dictionary <Guid, double>(); Dictionary <string, double> finGood = new Dictionary <string, double>(); foreach (var item in request.Items) { if (item.IsSave) { Guid garmentFinishingOutItemId = Guid.NewGuid(); GarmentFinishingOutItem garmentFinishingOutItem = new GarmentFinishingOutItem( garmentFinishingOutItemId, garmentFinishingOut.Identity, item.FinishingInId, item.FinishingInItemId, new ProductId(item.Product.Id), item.Product.Code, item.Product.Name, item.DesignColor, new SizeId(item.Size.Id), item.Size.Size, request.IsDifferentSize ? item.TotalQuantity : item.Quantity, new UomId(item.Uom.Id), item.Uom.Unit, item.Color, request.IsDifferentSize ? item.TotalQuantity : item.Quantity, item.BasicPrice, item.Price ); item.Id = garmentFinishingOutItemId; if (request.IsDifferentSize) { foreach (var detail in item.Details) { Guid garmentFinishingOutDetailId = Guid.NewGuid(); GarmentFinishingOutDetail garmentFinishingOutDetail = new GarmentFinishingOutDetail( garmentFinishingOutDetailId, garmentFinishingOutItem.Identity, new SizeId(detail.Size.Id), detail.Size.Size, detail.Quantity, new UomId(detail.Uom.Id), detail.Uom.Unit ); detail.Id = garmentFinishingOutDetailId; if (finishingInItemToBeUpdated.ContainsKey(item.FinishingInItemId)) { finishingInItemToBeUpdated[item.FinishingInItemId] += detail.Quantity; } else { finishingInItemToBeUpdated.Add(item.FinishingInItemId, detail.Quantity); } await _garmentFinishingOutDetailRepository.Update(garmentFinishingOutDetail); if (request.FinishingTo == "GUDANG JADI") { string finStock = detail.Size.Id + "~" + detail.Size.Size + "~" + detail.Uom.Id + "~" + detail.Uom.Unit + "~" + item.BasicPrice; if (finGood.ContainsKey(finStock)) { finGood[finStock] += detail.Quantity; } else { finGood.Add(finStock, detail.Quantity); } } } } else { if (finishingInItemToBeUpdated.ContainsKey(item.FinishingInItemId)) { finishingInItemToBeUpdated[item.FinishingInItemId] += item.Quantity; } else { finishingInItemToBeUpdated.Add(item.FinishingInItemId, item.Quantity); } if (request.FinishingTo == "GUDANG JADI") { string finStock = item.Size.Id + "~" + item.Size.Size + "~" + item.Uom.Id + "~" + item.Uom.Unit + "~" + item.BasicPrice; if (finGood.ContainsKey(finStock)) { finGood[finStock] += item.Quantity; } else { finGood.Add(finStock, item.Quantity); } } } await _garmentFinishingOutItemRepository.Update(garmentFinishingOutItem); } } foreach (var finInItem in finishingInItemToBeUpdated) { var garmentFinishingInItem = _garmentFinishingInItemRepository.Query.Where(x => x.Identity == finInItem.Key).Select(s => new GarmentFinishingInItem(s)).Single(); garmentFinishingInItem.SetRemainingQuantity(garmentFinishingInItem.RemainingQuantity - finInItem.Value); garmentFinishingInItem.Modify(); await _garmentFinishingInItemRepository.Update(garmentFinishingInItem); } if (request.FinishingTo == "GUDANG JADI") { int count = 1; List <GarmentFinishedGoodStock> finGoodStocks = new List <GarmentFinishedGoodStock>(); foreach (var finGoodStock in finGood) { SizeId sizeId = new SizeId(Convert.ToInt32(finGoodStock.Key.Split("~")[0])); string sizeName = finGoodStock.Key.Split("~")[1]; UomId uomId = new UomId(Convert.ToInt32(finGoodStock.Key.Split("~")[2])); string uomUnit = finGoodStock.Key.Split("~")[3]; double basicPrice = Convert.ToDouble(finGoodStock.Key.Split("~")[4]); var garmentFinishedGoodExist = _garmentFinishedGoodStockRepository.Query.Where( a => a.RONo == request.RONo && a.Article == request.Article && a.BasicPrice == basicPrice && a.UnitId == request.UnitTo.Id && new SizeId(a.SizeId) == sizeId && a.ComodityId == request.Comodity.Id && new UomId(a.UomId) == uomId ).Select(s => new GarmentFinishedGoodStock(s)).SingleOrDefault(); double qty = garmentFinishedGoodExist == null ? finGoodStock.Value : (finGoodStock.Value + garmentFinishedGoodExist.Quantity); double price = (basicPrice + (double)garmentComodityPrice.Price) * qty; if (garmentFinishedGoodExist == null) { var now = DateTime.Now; var year = now.ToString("yy"); var month = now.ToString("MM"); var prefix = $"ST{request.UnitTo.Code.Trim()}{year}{month}"; var lastFnGoodNo = _garmentFinishedGoodStockRepository.Query.Where(w => w.FinishedGoodStockNo.StartsWith(prefix)) .OrderByDescending(o => o.FinishedGoodStockNo) .Select(s => int.Parse(s.FinishedGoodStockNo.Replace(prefix, ""))) .FirstOrDefault(); var FinGoodNo = $"{prefix}{(lastFnGoodNo + count).ToString("D4")}"; GarmentFinishedGoodStock finishedGood = new GarmentFinishedGoodStock( Guid.NewGuid(), FinGoodNo, request.RONo, request.Article, new UnitDepartmentId(request.UnitTo.Id), request.UnitTo.Code, request.UnitTo.Name, new GarmentComodityId(request.Comodity.Id), request.Comodity.Code, request.Comodity.Name, sizeId, sizeName, uomId, uomUnit, qty, basicPrice, price ); count++; await _garmentFinishedGoodStockRepository.Update(finishedGood); finGoodStocks.Add(finishedGood); } else { garmentFinishedGoodExist.SetQuantity(qty); garmentFinishedGoodExist.SetPrice(price); garmentFinishedGoodExist.Modify(); await _garmentFinishedGoodStockRepository.Update(garmentFinishedGoodExist); var stock = finGoodStocks.Where(a => a.RONo == request.RONo && a.Article == request.Article && a.BasicPrice == garmentFinishedGoodExist.BasicPrice && a.UnitId == new UnitDepartmentId(request.UnitTo.Id) && a.SizeId == garmentFinishedGoodExist.SizeId && a.ComodityId == new GarmentComodityId(request.Comodity.Id) && a.UomId == garmentFinishedGoodExist.UomId).SingleOrDefault(); finGoodStocks.Add(garmentFinishedGoodExist); } } foreach (var item in request.Items) { if (item.IsSave) { if (request.IsDifferentSize) { foreach (var detail in item.Details) { var stock = finGoodStocks.Where(a => a.RONo == request.RONo && a.Article == request.Article && a.BasicPrice == item.BasicPrice && a.UnitId == new UnitDepartmentId(request.UnitTo.Id) && a.SizeId == new SizeId(detail.Size.Id) && a.ComodityId == new GarmentComodityId(request.Comodity.Id) && a.UomId == new UomId(detail.Uom.Id)).Single(); double price = (stock.BasicPrice + (double)garmentComodityPrice.Price) * detail.Quantity; GarmentFinishedGoodStockHistory garmentFinishedGoodStockHistory = new GarmentFinishedGoodStockHistory( Guid.NewGuid(), stock.Identity, item.Id, detail.Id, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, "IN", stock.RONo, stock.Article, stock.UnitId, stock.UnitCode, stock.UnitName, stock.ComodityId, stock.ComodityCode, stock.ComodityName, stock.SizeId, stock.SizeName, stock.UomId, stock.UomUnit, detail.Quantity, stock.BasicPrice, price ); await _garmentFinishedGoodStockHistoryRepository.Update(garmentFinishedGoodStockHistory); } } else { var stock = finGoodStocks.Where(a => a.RONo == request.RONo && a.Article == request.Article && a.BasicPrice == item.BasicPrice && a.UnitId == new UnitDepartmentId(request.UnitTo.Id) && a.SizeId == new SizeId(item.Size.Id) && a.ComodityId == new GarmentComodityId(request.Comodity.Id) && a.UomId == new UomId(item.Uom.Id)).Single(); double price = (stock.BasicPrice + (double)garmentComodityPrice.Price) * item.Quantity; GarmentFinishedGoodStockHistory garmentFinishedGoodStockHistory = new GarmentFinishedGoodStockHistory( Guid.NewGuid(), stock.Identity, item.Id, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, "IN", stock.RONo, stock.Article, stock.UnitId, stock.UnitCode, stock.UnitName, stock.ComodityId, stock.ComodityCode, stock.ComodityName, stock.SizeId, stock.SizeName, stock.UomId, stock.UomUnit, item.Quantity, stock.BasicPrice, price ); await _garmentFinishedGoodStockHistoryRepository.Update(garmentFinishedGoodStockHistory); } } } } await _garmentFinishingOutRepository.Update(garmentFinishingOut); _storage.Save(); return(garmentFinishingOut); }
public async Task <Size> GetSizeAsync(SizeId sizeId) { return(await _context.Size.FindAsync(sizeId)); }