public void ProcessTransForReclassification(List <GLTranForReclassification> origTransForReclass, ReclassGraphState state) { State = state; TransGroupKey?transGroupKeyToPutToExistingBatch = null; JournalEntryInstance = CreateInstance <JournalEntryForReclassification>(); var hasError = false; Batch batchForEditing = null; IReadOnlyCollection <GLTranForReclassTriple> transForReclassTripleGroupsToBatchForEditing = null; var workOrigTranMap = origTransForReclass.ToDictionary(origTran => PXCache <GLTranForReclassification> .CreateCopy(origTran), origTran => origTran); var transForReclass = workOrigTranMap.Keys.ToList(); if (State.ReclassScreenMode == ReclassScreenMode.Editing) { transGroupKeyToPutToExistingBatch = DefineTransGroupKeyToPutToExistingBatch(transForReclass); } PrepareJournalEntryGraph(); var transForReclassTriples = BuildTranForReclasTriples(transForReclass); var transForReclassTripleGroups = transForReclassTriples.GroupBy(tranWithCury => new TransGroupKey() { FinPeriodID = tranWithCury.Tran.FinPeriodID, CuryID = tranWithCury.CuryInfo.CuryID }); foreach (var tranCuryPairsGroup in transForReclassTripleGroups) { var tranForReclassTriples = tranCuryPairsGroup.ToArray(); if (State.ReclassScreenMode == ReclassScreenMode.Editing && tranCuryPairsGroup.Key.Equals(transGroupKeyToPutToExistingBatch.Value)) { batchForEditing = JournalEntry.FindBatch(JournalEntryInstance, State.EditingBatchModule, State.EditingBatchNbr); transForReclassTripleGroupsToBatchForEditing = tranForReclassTriples; //existing batch must be processed in the end continue; } hasError |= !ProcessTranForReclassGroup(tranForReclassTriples, workOrigTranMap, origTransForReclass); } if (State.ReclassScreenMode == ReclassScreenMode.Editing) { hasError |= !ProcessTranForReclassGroup(transForReclassTripleGroupsToBatchForEditing, workOrigTranMap, origTransForReclass, batchForEditing); } if (hasError) { throw new PXException(ErrorMessages.SeveralItemsFailed); } }
public void ProcessTransForReclassification(List <GLTranForReclassification> origTransForReclass, ReclassGraphState state) { State = state; TransGroupKey?transGroupKeyToPutToExistingBatch = null; JournalEntryInstance = CreateJournalEntry(); var hasError = false; Batch batchForEditing = null; IReadOnlyCollection <ReclassificationItem> reclassItemGroupsToBatchForEditing = null; var workOrigTranMap = new Dictionary <GLTranForReclassification, GLTranForReclassification>(); var allReclassItemsByHeaderKey = BuildReclassificationItems(origTransForReclass, out workOrigTranMap); var transForReclass = workOrigTranMap.Keys.ToList(); if (State.ReclassScreenMode == ReclassScreenMode.Editing) { transGroupKeyToPutToExistingBatch = DefineTransGroupKeyToPutToExistingBatch(transForReclass); } PrepareJournalEntryGraph(); var reclassItemGroups = allReclassItemsByHeaderKey.Values.GroupBy(tranWithCury => new TransGroupKey() { MasterPeriodID = tranWithCury.HeadTranForReclass.TranPeriodID, CuryID = tranWithCury.CuryInfo.CuryID }); foreach (var reclassItemGroup in reclassItemGroups) { var reclassItems = reclassItemGroup.ToArray(); if (State.ReclassScreenMode == ReclassScreenMode.Editing && reclassItemGroup.Key.Equals(transGroupKeyToPutToExistingBatch.Value)) { batchForEditing = JournalEntry.FindBatch(JournalEntryInstance, State.EditingBatchModule, State.EditingBatchNbr); reclassItemGroupsToBatchForEditing = reclassItems; //existing batch must be processed last continue; } hasError |= !ProcessTranForReclassGroup(reclassItems, workOrigTranMap, origTransForReclass, allReclassItemsByHeaderKey); } if (State.ReclassScreenMode == ReclassScreenMode.Editing) { hasError |= !ProcessTranForReclassGroup(reclassItemGroupsToBatchForEditing, workOrigTranMap, origTransForReclass, allReclassItemsByHeaderKey, batchForEditing); } if (hasError) { throw new PXException(ErrorMessages.SeveralItemsFailed); } }