public async Task <int> CreateInventoryDocumentAsync(Models.FpRegradingResultDocs Model, string Type) { string storageURI = "master/storages"; string uomURI = "master/uoms"; IHttpService httpClient = (IHttpService)this.ServiceProvider.GetService(typeof(IHttpService)); /* Get UOM */ Dictionary <string, object> filterUOM = new Dictionary <string, object> { { "unit", "MTR" } }; var responseUOM = httpClient.GetAsync($@"{APIEndpoint.Core}{uomURI}?filter=" + JsonConvert.SerializeObject(filterUOM)).Result.Content.ReadAsStringAsync(); Dictionary <string, object> resultUOM = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseUOM.Result); var jsonUOM = resultUOM.Single(p => p.Key.Equals("data")).Value; Dictionary <string, object> uom = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonUOM.ToString())[0]; /* Get Storage */ var storageName = Model.UnitName.Equals("PRINTING") ? "Gudang Greige Printing" : "Gudang Greige Finishing"; Dictionary <string, object> filterStorage = new Dictionary <string, object> { { "name", storageName } }; var responseStorage = httpClient.GetAsync($@"{APIEndpoint.Core}{storageURI}?filter=" + JsonConvert.SerializeObject(filterStorage)).Result.Content.ReadAsStringAsync(); Dictionary <string, object> resultStorage = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseStorage.Result); var jsonStorage = resultStorage.Single(p => p.Key.Equals("data")).Value; Dictionary <string, object> storage = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonStorage.ToString())[0]; /* Create Inventory Document */ List <InventoryDocumentItem> inventoryDocumentItems = new List <InventoryDocumentItem>(); InventoryDocumentItem inventoryDocumentItem = new InventoryDocumentItem(); double TotalLength = 0; foreach (FpRegradingResultDocsDetails o in Model.Details) { TotalLength += o.Length; } inventoryDocumentItem.ProductId = int.Parse(Model.ProductId); inventoryDocumentItem.ProductCode = Model.ProductCode; inventoryDocumentItem.ProductName = Model.ProductName; inventoryDocumentItem.Quantity = TotalLength; inventoryDocumentItem.UomId = int.Parse(uom["Id"].ToString()); inventoryDocumentItem.UomUnit = uom["Unit"].ToString(); inventoryDocumentItems.Add(inventoryDocumentItem); InventoryDocument inventoryDocument = new InventoryDocument { Date = DateTimeOffset.UtcNow, ReferenceNo = Model.Code, ReferenceType = "Bon Hasil Re-grading", Type = Type, StorageId = int.Parse(storage["_id"].ToString()), StorageCode = storage["code"].ToString(), StorageName = storage["name"].ToString(), Items = inventoryDocumentItems }; var inventoryDocumentFacade = ServiceProvider.GetService <IInventoryDocumentService>(); return(await inventoryDocumentFacade.Create(inventoryDocument)); }
protected void OnButtonFineClicked(object sender, EventArgs e) { var selected = ytreeviewItems.GetSelectedObject <InventoryDocumentItem>(); FineDlg fineDlg; if (selected.Fine != null) { fineDlg = new FineDlg(selected.Fine); fineDlg.EntitySaved += FineDlgExist_EntitySaved; } else { fineDlg = new FineDlg("Недостача"); fineDlg.EntitySaved += FineDlgNew_EntitySaved; } fineDlg.Entity.TotalMoney = selected.SumOfDamage; FineEditItem = selected; MyTab.TabParent.AddSlaveTab(MyTab, fineDlg); }
public async Task <int> CreateInventoryDocument(StockTransferNote Model, string Type, string Context) { StockTransferNoteViewModel ViewModel = MapToViewModel(Model); IHttpServiceRepository httpClient = (IHttpServiceRepository)this.ServiceProvider.GetService(typeof(IHttpServiceRepository)); /* Create Inventory Document */ List <InventoryDocumentItem> inventoryDocumentItems = new List <InventoryDocumentItem>(); foreach (StockTransferNoteItemViewModel stni in ViewModel.StockTransferNoteItems) { InventoryDocumentItem inventoryDocumentItem = new InventoryDocumentItem { ProductId = stni.Summary.ProductId, ProductCode = stni.Summary.ProductCode, ProductName = stni.Summary.ProductName, Quantity = stni.TransferedQuantity != null ? (double)stni.TransferedQuantity : 0, UomId = stni.Summary.UomId, UomUnit = stni.Summary.Uom }; inventoryDocumentItems.Add(inventoryDocumentItem); } InventoryDocument inventoryDocument = new InventoryDocument { Date = DateTimeOffset.UtcNow, ReferenceNo = Model.ReferenceNo, ReferenceType = Model.ReferenceType, Type = Type, StorageId = string.Equals(Context.ToUpper(), "CREATE") || string.Equals(Context.ToUpper(), "DELETE-SOURCE") ? int.Parse(Model.SourceStorageId) : int.Parse(Model.TargetStorageId), StorageCode = string.Equals(Context.ToUpper(), "CREATE") || string.Equals(Context.ToUpper(), "DELETE-SOURCE") ? Model.SourceStorageCode : Model.TargetStorageCode, StorageName = string.Equals(Context.ToUpper(), "CREATE") || string.Equals(Context.ToUpper(), "DELETE-SOURCE") ? Model.SourceStorageName : Model.TargetStorageName, Items = inventoryDocumentItems }; var inventoryDocumentFacade = ServiceProvider.GetService <IInventoryDocumentRepository>(); return(await inventoryDocumentFacade.Create(inventoryDocument)); }
void FineDlgNew_EntitySaved(object sender, EntitySavedEventArgs e) { FineEditItem.Fine = e.Entity as Fine; FineEditItem = null; }
public async Task <int> CreateInventoryDocument(MaterialDistributionNote model, string type) { string storageURI = "master/storages"; string uomURI = "master/uoms"; IHttpServiceRepository httpClient = (IHttpServiceRepository)_serviceProvider.GetService(typeof(IHttpServiceRepository)); /* Get UOM */ Dictionary <string, object> filterUom = new Dictionary <string, object> { { "Unit", "MTR" } }; var responseUom = httpClient.GetAsync($@"{APIEndpoint.Core}{uomURI}?filter=" + JsonConvert.SerializeObject(filterUom)).Result.Content.ReadAsStringAsync(); Dictionary <string, object> resultUom = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseUom.Result); var jsonUom = resultUom.Single(p => p.Key.Equals("data")).Value; Dictionary <string, object> Uom = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonUom.ToString())[0]; /* Get Storage */ var storageName = model.UnitName.Equals("PRINTING") ? "Warehouse Here Printing" : "Warehouse Here Finishing"; Dictionary <string, object> filterStorage = new Dictionary <string, object> { { "name", storageName } }; var responseStorage = httpClient.GetAsync($@"{APIEndpoint.Core}{storageURI}?filter=" + JsonConvert.SerializeObject(filterStorage)).Result.Content.ReadAsStringAsync(); Dictionary <string, object> resultStorage = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseStorage.Result); var jsonStorage = resultStorage.Single(p => p.Key.Equals("data")).Value; Dictionary <string, object> storage = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonStorage.ToString())[0]; /* Create Inventory Document */ List <InventoryDocumentItem> inventoryDocumentItems = new List <InventoryDocumentItem>(); List <MaterialDistributionNoteDetail> mdnds = new List <MaterialDistributionNoteDetail>(); foreach (MaterialDistributionNoteItem mdni in model.MaterialDistributionNoteItems) { mdnds.AddRange(mdni.MaterialDistributionNoteDetails); } foreach (MaterialDistributionNoteDetail mdnd in mdnds) { InventoryDocumentItem inventoryDocumentItem = new InventoryDocumentItem { ProductId = int.Parse(mdnd.ProductId), ProductCode = mdnd.ProductCode, ProductName = mdnd.ProductName, Quantity = mdnd.ReceivedLength, StockPlanning = model.Type != "RE-GRADING" ? (mdnd.DistributedLength == 0 ? mdnd.MaterialRequestNoteItemLength - mdnd.ReceivedLength : mdnd.ReceivedLength * -1) : mdnd.ReceivedLength * -1, UomId = int.Parse(Uom["Id"].ToString()), UomUnit = Uom["Unit"].ToString() }; inventoryDocumentItems.Add(inventoryDocumentItem); } List <InventoryDocumentItem> list = inventoryDocumentItems .GroupBy(m => new { m.ProductId, m.ProductCode, m.ProductName }) .Select(s => new InventoryDocumentItem { ProductId = s.First().ProductId, ProductCode = s.First().ProductCode, ProductName = s.First().ProductName, Quantity = s.Sum(d => d.Quantity), StockPlanning = s.Sum(d => d.StockPlanning), UomUnit = s.First().UomUnit, UomId = s.First().UomId }).ToList(); InventoryDocument inventoryDocument = new InventoryDocument { Date = DateTimeOffset.UtcNow, ReferenceNo = model.No, ReferenceType = "Bon introduction to Here", Type = type, StorageId = int.Parse(storage["Id"].ToString()), StorageCode = storage["Code"].ToString(), StorageName = storage["Name"].ToString(), Items = list }; var inventoryDocumentFacade = _serviceProvider.GetService <IInventoryDocumentRepository>(); return(await inventoryDocumentFacade.Create(inventoryDocument)); }
public async Task <int> CreateInventoryDocumentAsync(FPReturnInvToPurchasing model, string Type) { string storageURI = "master/storages"; string uomURI = "master/uoms"; IHttpService httpClient = (IHttpService)this.ServiceProvider.GetService(typeof(IHttpService)); #region UOM Dictionary <string, object> filterUOM = new Dictionary <string, object> { { "unit", "MTR" } }; var responseUOM = httpClient.GetAsync($@"{APIEndpoint.Core}{uomURI}?filter=" + JsonConvert.SerializeObject(filterUOM)).Result.Content.ReadAsStringAsync(); Dictionary <string, object> resultUOM = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseUOM.Result); var jsonUOM = resultUOM.Single(p => p.Key.Equals("data")).Value; Dictionary <string, object> uom = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonUOM.ToString())[0]; #endregion UOM #region Storage var storageName = model.UnitName.Equals("PRINTING") ? "Gudang Greige Printing" : "Gudang Greige Finishing"; Dictionary <string, object> filterStorage = new Dictionary <string, object> { { "name", storageName } }; var responseStorage = httpClient.GetAsync($@"{APIEndpoint.Core}{storageURI}?filter=" + JsonConvert.SerializeObject(filterStorage)).Result.Content.ReadAsStringAsync(); Dictionary <string, object> resultStorage = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseStorage.Result); var jsonStorage = resultStorage.Single(p => p.Key.Equals("data")).Value; Dictionary <string, object> storage = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonStorage.ToString())[0]; #endregion Storage #region Inventory Document List <InventoryDocumentItem> inventoryDocumentItems = new List <InventoryDocumentItem>(); foreach (FPReturnInvToPurchasingDetail detail in model.FPReturnInvToPurchasingDetails) { InventoryDocumentItem inventoryDocumentItem = new InventoryDocumentItem { ProductId = int.Parse(detail.ProductId), ProductCode = detail.ProductCode, ProductName = detail.ProductName, Quantity = detail.Length, UomId = int.Parse(uom["Id"].ToString()), UomUnit = uom["Unit"].ToString() }; inventoryDocumentItems.Add(inventoryDocumentItem); } InventoryDocument inventoryDocument = new InventoryDocument { Date = DateTimeOffset.UtcNow, ReferenceNo = model.No, ReferenceType = "Bon Retur Barang - Pembelian", Type = Type, StorageId = int.Parse(storage["_id"].ToString()), StorageCode = storage["code"].ToString(), StorageName = storage["name"].ToString(), Items = inventoryDocumentItems }; var inventoryDocumentFacade = ServiceProvider.GetService <IInventoryDocumentService>(); return(await inventoryDocumentFacade.Create(inventoryDocument)); #endregion Inventory Document }
public async Task CreateInventoryDocument(MaterialsRequestNote Model, string Type) { //string inventoryDocumentURI = "inventory/inventory-documents"; string storageURI = "master/storages"; string uomURI = "master/uoms"; HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token); /* Get UOM */ Dictionary <string, object> filterUOM = new Dictionary <string, object> { { "unit", "MTR" } }; var responseUOM = httpClient.GetAsync($@"{APIEndpoint.Core}{uomURI}?filter=" + JsonConvert.SerializeObject(filterUOM)).Result.Content.ReadAsStringAsync(); Dictionary <string, object> resultUOM = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseUOM.Result); var jsonUOM = resultUOM.Single(p => p.Key.Equals("data")).Value; Dictionary <string, object> uom = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonUOM.ToString())[0]; /* Get Storage */ var storageName = Model.UnitName.Equals("PRINTING") ? "Gudang Greige Printing" : "Gudang Greige Finishing"; Dictionary <string, object> filterStorage = new Dictionary <string, object> { { "name", storageName } }; var responseStorage = httpClient.GetAsync($@"{APIEndpoint.Core}{storageURI}?filter=" + JsonConvert.SerializeObject(filterStorage)).Result.Content.ReadAsStringAsync(); Dictionary <string, object> resultStorage = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseStorage.Result); var jsonStorage = resultStorage.Single(p => p.Key.Equals("data")).Value; Dictionary <string, object> storage = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonStorage.ToString())[0]; /* Create Inventory Document */ List <InventoryDocumentItem> inventoryDocumentItems = new List <InventoryDocumentItem>(); List <MaterialsRequestNote_Item> list = Model.MaterialsRequestNote_Items .GroupBy(m => new { m.ProductId, m.ProductCode, m.ProductName }) .Select(s => new MaterialsRequestNote_Item { ProductId = s.First().ProductId, ProductCode = s.First().ProductCode, ProductName = s.First().ProductName, Length = s.Sum(d => d.Length) }).ToList(); foreach (MaterialsRequestNote_Item item in list) { InventoryDocumentItem inventoryDocumentItem = new InventoryDocumentItem(); inventoryDocumentItem.ProductId = int.Parse(item.ProductId); inventoryDocumentItem.ProductCode = item.ProductCode; inventoryDocumentItem.ProductName = item.ProductName; inventoryDocumentItem.Quantity = item.Length; inventoryDocumentItem.UomId = int.Parse(uom["Id"].ToString()); inventoryDocumentItem.UomUnit = uom["Unit"].ToString(); inventoryDocumentItems.Add(inventoryDocumentItem); } InventoryDocument inventoryDocument = new InventoryDocument { Date = DateTimeOffset.UtcNow, ReferenceNo = Model.Code, ReferenceType = "Surat Permintaan Barang", Type = Type, StorageId = int.Parse(storage["_id"].ToString()), StorageCode = storage["code"].ToString(), StorageName = storage["name"].ToString(), Items = inventoryDocumentItems }; InventoryDocumentFacade inventoryDocumentFacade = (InventoryDocumentFacade)ServiceProvider.GetService(typeof(InventoryDocumentFacade)); await inventoryDocumentFacade.Create(inventoryDocument, Username); //var response = httpClient.PostAsync($"{APIEndpoint.Inventory}{inventoryDocumentURI}", new StringContent(JsonConvert.SerializeObject(inventoryDocument).ToString(), Encoding.UTF8, General.JsonMediaType)).Result; //response.EnsureSuccessStatusCode(); }