private static List <AllocationsModel.MyPodData> GroupAllocations(AllocationsModel.AllocationDataBlock monthyear) { try { List <AllocationsModel.MyPodData> elst; elst = (from s in Enumerable.OrderBy <AsycudaSalesAllocations, string>(monthyear.Allocations, p => p.TariffCode) .GroupBy(x => x.PreviousDocumentItem) .Where(z => z.ToList().Any(q => q.EntryDataDetails.Quantity < 0) == false) .SelectMany(x => x.ToList()) select new AllocationsModel.MyPodData { Allocations = new List <AsycudaSalesAllocations>() { s }, EntlnData = new AllocationsModel.AlloEntryLineData { ItemNumber = s.EntryDataDetails.ItemNumber, InventoryItem = s.EntryDataDetails.InventoryItem, ItemDescription = s.EntryDataDetails.ItemDescription, TariffCode = s.PreviousDocumentItem.xcuda_Tarification.xcuda_HScode.Commodity_code, Cost = Convert.ToDouble(s.PreviousDocumentItem.ItemCost), Quantity = s.QtyAllocated, EntryDataDetails = new List <IEntryDataDetail>() { s.EntryDataDetails }, PreviousDocumentItemId = s.PreviousDocumentItem.Item_Id.ToString() } }).ToList(); // group the returns var returnlst = (from s in Enumerable.OrderBy <AsycudaSalesAllocations, string>(monthyear.Allocations, p => p.TariffCode) .GroupBy(x => x.PreviousDocumentItem) .Where(z => z.ToList().Where(q => q.EntryDataDetails.Quantity < 0).Any() == true) select new AllocationsModel.MyPodData { Allocations = s.ToList(), EntlnData = new AllocationsModel.AlloEntryLineData { ItemNumber = s.LastOrDefault().EntryDataDetails.ItemNumber, ItemDescription = s.LastOrDefault().EntryDataDetails.ItemDescription, TariffCode = s.Key.TariffCode, Cost = s.Key.ItemCost, Quantity = s.Sum(x => x.QtyAllocated), EntryDataDetails = s.Select(x => x.EntryDataDetails as IEntryDataDetail).ToList(), PreviousDocumentItemId = s.Key.Item_Id.ToString() } }).ToList(); elst.AddRange(returnlst); return(elst); } catch (Exception) { throw; } }
private static List <AllocationsModel.MyPodData> GroupAllocationsByEx9( AllocationsModel.AllocationDataBlock monthyear) { try { List <AllocationsModel.MyPodData> elst; elst = (from s in Enumerable.OrderBy <AsycudaSalesAllocations, string>(monthyear.Allocations, p => p.TariffCode) .Where(x => x.PreviousDocumentItem.ItemCost != null) // where s.EntryDataDetails.ItemNumber == "SPG20331" group s by new { // s.EntryDataDetails.ItemNumber, // s.EntryDataDetails.ItemDescription, // s.EntryDataDetails.TariffCode, //Cost = Math.Round(s.EntryDataDetails.Cost, 2), // s.EntryDataDetails.InventoryItems, s.PreviousDocumentItem } into g select new AllocationsModel.MyPodData { Allocations = g.ToList(), EntlnData = new AllocationsModel.AlloEntryLineData { //ItemNumber = g.Key.ItemNumber, ItemNumber = g.LastOrDefault().EntryDataDetails.ItemNumber, InventoryItem = g.LastOrDefault().EntryDataDetails.InventoryItem, //ItemDescription = g.Key.ItemDescription, ItemDescription = g.LastOrDefault().EntryDataDetails.ItemDescription, //TariffCode = g.Key.TariffCode, TariffCode = g.Key.PreviousDocumentItem.xcuda_Tarification.xcuda_HScode.Commodity_code, Cost = Convert.ToDouble(g.Key.PreviousDocumentItem.ItemCost), // InventoryItem = g.Key.InventoryItems, Quantity = g.Sum(x => x.QtyAllocated), EntryDataDetails = g.Select(x => x.EntryDataDetails as IEntryDataDetail).ToList(), PreviousDocumentItemId = g.Key.PreviousDocumentItem.Item_Id.ToString(), PreviousDocumentItem = g.Key.PreviousDocumentItem } }).ToList(); return(elst); } catch (Exception) { throw; } }
private List <AllocationsModel.MyPodData> PrepareAllocationsData(AllocationsModel.AllocationDataBlock monthyear) { try { List <AllocationsModel.MyPodData> elst; if (BaseDataModel.Instance.CurrentApplicationSettings.GroupEX9 == true) { elst = GroupAllocationsByEx9(monthyear); } else { elst = GroupAllocations(monthyear); } return(elst.Where(x => (x.EntlnData.PreviousDocumentItem as xcuda_Item).DoNotEX != true).ToList()); } catch (Exception) { throw; } }
private bool IsPerIM7(string prevIM7, AllocationsModel.AllocationDataBlock monthyear) { return(PerIM7 == true && (string.IsNullOrEmpty(prevIM7) || (!string.IsNullOrEmpty(prevIM7) && prevIM7 != monthyear.CNumber))); }
private async Task <int> InitializeDocumentCT(int itmcount, string prevEntryId, AllocationsModel.MyPodData mypod, DocumentCT cdoc, AsycudaDocumentSet docSet, string prevIM7, AllocationsModel.AllocationDataBlock monthyear, Document_Type dt, string dfp) { try { if (MaxLineCount(itmcount) || InvoicePerEntry(prevEntryId, mypod) || (cdoc.Document == null || itmcount == 0) || IsPerIM7(prevIM7, monthyear)) { if (itmcount != 0) { if (cdoc.Document != null) { await SaveDocumentCT(cdoc).ConfigureAwait(false); //} //else //{ cdoc = await BaseDataModel.Instance.CreateDocumentCt(docSet).ConfigureAwait(true); } } Ex9InitializeCdoc(dt, dfp, cdoc, docSet); if (PerIM7 == true) { cdoc.Document.xcuda_Declarant.Number = cdoc.Document.xcuda_Declarant.Number.Replace( docSet.Declarant_Reference_Number, docSet.Declarant_Reference_Number + "-" + monthyear.CNumber); } InsertEntryIdintoRefNum(cdoc, mypod.EntlnData.EntryDataDetails[0].EntryDataId); itmcount = 0; } return(itmcount); } catch (Exception) { throw; } }