internal static IPostingLine ToDomain(this PostingLineModel postingLineModel, IAccount account, IBudgetAccount budgetAccount, IContactAccount contactAccount, MapperCache mapperCache) { NullGuard.NotNull(postingLineModel, nameof(postingLineModel)) .NotNull(account, nameof(account)) .NotNull(mapperCache, nameof(mapperCache)); Guid postingLineIdentification = Guid.Parse(postingLineModel.PostingLineIdentification); lock (mapperCache.SyncRoot) { if (mapperCache.PostingLineDictionary.TryGetValue(postingLineIdentification, out IPostingLine postingLine)) { return(postingLine); } ICreditInfo creditInfo = account.CreditInfoCollection.Find(postingLineModel.PostingDate); ICreditInfoValues accountValuesAtPostingDate = new CreditInfoValues(creditInfo?.Credit ?? 0M, postingLineModel.PostingValueForAccount); IBudgetInfoValues budgetAccountValuesAtPostingDate = null; if (budgetAccount != null) { IBudgetInfo budgetInfo = budgetAccount.BudgetInfoCollection.Find(postingLineModel.PostingDate); budgetAccountValuesAtPostingDate = new BudgetInfoValues(budgetInfo?.Budget ?? 0M, postingLineModel.PostingValueForBudgetAccount ?? 0M); } IContactInfoValues contactAccountValuesAtPostingDate = null; if (contactAccount != null) { contactAccountValuesAtPostingDate = new ContactInfoValues(postingLineModel.PostingValueForContactAccount ?? 0M); } postingLine = new PostingLine(postingLineIdentification, postingLineModel.PostingDate, postingLineModel.Reference, account, postingLineModel.Details, budgetAccount, postingLineModel.Debit ?? 0M, postingLineModel.Credit ?? 0M, contactAccount, postingLineModel.PostingLineIdentifier, accountValuesAtPostingDate, budgetAccountValuesAtPostingDate, contactAccountValuesAtPostingDate); postingLine.AddAuditInformation(postingLineModel.CreatedUtcDateTime, postingLineModel.CreatedByIdentifier, postingLineModel.ModifiedUtcDateTime, postingLineModel.ModifiedByIdentifier); mapperCache.PostingLineDictionary.Add(postingLineIdentification, postingLine); if (account.PostingLineCollection.Contains(postingLine) == false) { account.PostingLineCollection.Add(postingLine); } if (budgetAccount != null && budgetAccount.PostingLineCollection.Contains(postingLine) == false) { budgetAccount.PostingLineCollection.Add(postingLine); } if (contactAccount != null && contactAccount.PostingLineCollection.Contains(postingLine) == false) { contactAccount.PostingLineCollection.Add(postingLine); } return(postingLine); } }
/// <summary> /// Adds the line <c>fsSODetRow</c> to the List <c>FSPostingLineDetailsToPostInAR_AP</c> or <c>FSPostingLineDetailsToPostInSO</c> depending on <c>addToArApList</c> and <c>addToSoList</c> flags. /// </summary> private void AddSOLineToList(PXGraph graph, FSSODet fsSODetRow, ServiceOrderInfo serviceOrderInfo, bool addToArApList, bool addToSoList) { PostingLine soLineRow = new PostingLine(); if (fsSODetRow != null) { int?itemID = fsSODetRow.InventoryID; soLineRow.TableSource = ID.TablePostSource.FSSO_DET; soLineRow.LineType = fsSODetRow.LineType; soLineRow.LineID = fsSODetRow.SODetID; soLineRow.BranchID = serviceOrderInfo.FSServiceOrderRow.BranchID; soLineRow.InventoryID = itemID; soLineRow.UOM = fsSODetRow.UOM; soLineRow.AcctID = this.GetAcct(graph, fsSODetRow, null, serviceOrderInfo.FSServiceOrderRow, serviceOrderInfo.FSSrvOrdTypeRow); soLineRow.SubID = fsSODetRow.SubID; soLineRow.SiteID = fsSODetRow.SiteID; soLineRow.LocationID = fsSODetRow.SiteLocationID; soLineRow.SubItemID = fsSODetRow.SubItemID; soLineRow.TranDesc = fsSODetRow.TranDesc; soLineRow.ProjectID = fsSODetRow.ProjectID; soLineRow.ProjectTaskID = fsSODetRow.ProjectTaskID; soLineRow.CuryUnitPrice = fsSODetRow.CuryUnitPrice; soLineRow.Qty = fsSODetRow.EstimatedQty; soLineRow.CuryTranAmt = fsSODetRow.CuryEstimatedTranAmt; soLineRow.PostID = fsSODetRow.PostID; soLineRow.IsBillable = fsSODetRow.IsBillable; } if (addToArApList) { this.FSPostingLineDetailsToPostInAR_AP.Add(soLineRow); } else if (addToSoList) { this.FSPostingLineDetailsToPostInSO.Add(soLineRow); } }
public PostingLine CreatePostingLine(int subAccountId, PostingLine postingLine) { throw new NotImplementedException(); }
/// <summary> /// Adds the line <c>fsAppointmentDetRow</c> or <c>fsAppointmentInventoryItem</c> to the List <c>fsAppointmentDetailsToPostInAR_AP</c> or <c>fsAppointmentDetailsToPostInSO</c> depending on <c>addToArApList</c> and <c>addToSoList</c> flags. /// </summary> private void AddAppointmentLineToList(PXGraph graph, FSAppointmentDet fsAppointmentDetRow, FSAppointmentDet fsAppointmentInventoryItem, AppointmentInfo appointmentInfo, bool addToArApList, bool addToSoList) { PostingLine appointmentLineRow = new PostingLine(); if (fsAppointmentDetRow != null) { int?itemID = fsAppointmentDetRow.InventoryID; appointmentLineRow.TableSource = ID.TablePostSource.FSAPPOINTMENT_DET; appointmentLineRow.LineType = fsAppointmentDetRow.LineType; appointmentLineRow.LineID = fsAppointmentDetRow.AppDetID; appointmentLineRow.BranchID = appointmentInfo.FSServiceOrderRow.BranchID; appointmentLineRow.InventoryID = itemID; appointmentLineRow.UOM = fsAppointmentDetRow.UOM; appointmentLineRow.AcctID = this.GetAcct(graph, fsAppointmentDetRow, null, appointmentInfo.FSServiceOrderRow, appointmentInfo.FSSrvOrdTypeRow); appointmentLineRow.SubID = fsAppointmentDetRow.SubID; appointmentLineRow.SiteID = fsAppointmentDetRow.SiteID; appointmentLineRow.LocationID = fsAppointmentDetRow.SiteLocationID; appointmentLineRow.SubItemID = fsAppointmentDetRow.SubItemID; appointmentLineRow.TranDesc = fsAppointmentDetRow.TranDesc; appointmentLineRow.ProjectID = fsAppointmentDetRow.ProjectID; appointmentLineRow.ProjectTaskID = fsAppointmentDetRow.ProjectTaskID; appointmentLineRow.CuryUnitPrice = fsAppointmentDetRow.CuryUnitPrice; appointmentLineRow.Qty = fsAppointmentDetRow.Qty; appointmentLineRow.CuryTranAmt = fsAppointmentDetRow.TranAmt; appointmentLineRow.PostID = fsAppointmentDetRow.PostID; appointmentLineRow.IsBillable = fsAppointmentDetRow.IsBillable; } else if (fsAppointmentInventoryItem != null) { appointmentLineRow.TableSource = ID.TablePostSource.FSAPPOINTMENT_DET; appointmentLineRow.LineType = fsAppointmentInventoryItem.LineType; appointmentLineRow.LineID = fsAppointmentInventoryItem.AppDetID; appointmentLineRow.BranchID = appointmentInfo.FSServiceOrderRow.BranchID; appointmentLineRow.InventoryID = fsAppointmentInventoryItem.InventoryID; appointmentLineRow.UOM = fsAppointmentInventoryItem.UOM; appointmentLineRow.AcctID = this.GetAcct(graph, null, fsAppointmentInventoryItem, appointmentInfo.FSServiceOrderRow, appointmentInfo.FSSrvOrdTypeRow); appointmentLineRow.SubID = null; appointmentLineRow.SiteID = fsAppointmentInventoryItem.SiteID; appointmentLineRow.SubItemID = fsAppointmentInventoryItem.SubItemID; appointmentLineRow.TranDesc = fsAppointmentInventoryItem.TranDesc; appointmentLineRow.ProjectID = fsAppointmentInventoryItem.ProjectID; appointmentLineRow.ProjectTaskID = fsAppointmentInventoryItem.ProjectTaskID; appointmentLineRow.CuryUnitPrice = fsAppointmentInventoryItem.CuryUnitPrice; appointmentLineRow.Qty = fsAppointmentInventoryItem.Qty; appointmentLineRow.CuryTranAmt = fsAppointmentInventoryItem.TranAmt; appointmentLineRow.PostID = fsAppointmentInventoryItem.PostID; appointmentLineRow.IsBillable = true; } if (addToArApList) { this.FSPostingLineDetailsToPostInAR_AP.Add(appointmentLineRow); } else if (addToSoList) { this.FSPostingLineDetailsToPostInSO.Add(appointmentLineRow); } }