protected virtual void ARInvoice_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { ARInvoiceRUTROT row = RUTROTHelper.GetExtensionNullable <ARInvoice, ARInvoiceRUTROT>((ARInvoice)e.Row); ARInvoiceRUTROT oldRow = RUTROTHelper.GetExtensionNullable <ARInvoice, ARInvoiceRUTROT>((ARInvoice)e.OldRow); RRManager.RUTROTDeductibleUpdated(row, oldRow, Rutrots.SelectSingle()); }
protected virtual void HiddenInventoryItem_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { var item = (HiddenInventoryItem)e.Row; if (item == null) { return; } HiddenInventoryItemRUTROT itemRR = PXCache <HiddenInventoryItem> .GetExtension <HiddenInventoryItemRUTROT>(item); Branch branch = PXSelect <GL.Branch, Where <GL.Branch.branchID, Equal <Required <GL.Branch.branchID> > > > .Select(Base, PXAccess.GetBranchID()); BranchRUTROT branchRR = RUTROTHelper.GetExtensionNullable <Branch, BranchRUTROT>(branch); bool allowRUTROT = branchRR?.AllowsRUTROT == true; bool isOtherCostOrNull = itemRR.RUTROTItemType == null || itemRR.RUTROTItemType == RUTROTItemTypes.OtherCost; PXUIFieldAttribute.SetVisible <HiddenInventoryItemRUTROT.rUTROTItemType>(Base.Item.Cache, item, allowRUTROT); PXUIFieldAttribute.SetVisible <HiddenInventoryItemRUTROT.rUTROTType>(Base.Item.Cache, item, allowRUTROT); PXUIFieldAttribute.SetVisible <HiddenInventoryItemRUTROT.rUTROTWorkTypeID>(Base.Item.Cache, item, allowRUTROT); PXUIFieldAttribute.SetEnabled <HiddenInventoryItemRUTROT.rUTROTWorkTypeID>(sender, item, !isOtherCostOrNull); PXUIFieldAttribute.SetEnabled <HiddenInventoryItemRUTROT.rUTROTItemType>(sender, item, true); PXUIFieldAttribute.SetEnabled <HiddenInventoryItemRUTROT.rUTROTType>(sender, item, true); if (!isOtherCostOrNull && !RUTROTHelper.IsUpToDateWorkType(itemRR.RUTROTWorkTypeID, this.Base.Accessinfo.BusinessDate ?? DateTime.Now, this.Base)) { sender.RaiseExceptionHandling <HiddenInventoryItemRUTROT.rUTROTWorkTypeID>(item, itemRR.RUTROTWorkTypeID, new PXSetPropertyException(RUTROTMessages.ObsoleteWorkTypeWarning, PXErrorLevel.Warning)); } else { sender.RaiseExceptionHandling <HiddenInventoryItemRUTROT.rUTROTWorkTypeID>(item, itemRR.RUTROTWorkTypeID, null); } }
public void Doc_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { DocExt row = RUTROTHelper.GetExtensionNullable <Doc, DocExt>((Doc)e.Row); DocExt oldRow = RUTROTHelper.GetExtensionNullable <Doc, DocExt>((Doc)e.OldRow); RUTROTDeductibleUpdated(row, oldRow, Rutrots.SelectSingle()); }
protected virtual void RUTROT_RUTROTType_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { DocExt document = RUTROTHelper.GetExtensionNullable <Doc, DocExt>(Document.Current); RUTROT rutrot = (RUTROT)e.Row; if (document != null && document.IsRUTROTDeductible == true) { string value = (string)e.NewValue; foreach (Tran tran in Transactions.Select()) { TranExt tranRR = RUTROTHelper.GetExtensionNullable <Tran, TranExt>(tran); if (tranRR.GetInventoryID() != null) { InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, tranRR.GetInventoryID()); InventoryItemRUTROT itemRR = PXCache <InventoryItem> .GetExtension <InventoryItemRUTROT>(item); if (!RUTROTHelper.IsItemMatchRUTROTType(value, item, itemRR, itemRR?.IsRUTROTDeductible == true)) { sender.RaiseExceptionHandling <RUTROT.rUTROTType>(rutrot, rutrot.RUTROTType, new PXSetPropertyException <RUTROT.rUTROTType>(RUTROTMessages.LineDoesNotMatchDoc)); e.NewValue = rutrot.RUTROTType; break; } } } } }
public virtual void InsertSOAdjustments(SOOrder order, ARPaymentEntry docgraph, ARPayment payment, InsertSOAdjustmentsDelegate baseMethod) { baseMethod(order, docgraph, payment); SOOrderRUTROT orderRR = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>(order); if (orderRR.IsRUTROTDeductible == true) { RUTROT rutrot = PXSelect <RUTROT, Where <RUTROT.docType, Equal <Required <SOOrder.orderType> >, And <RUTROT.refNbr, Equal <Required <SOOrder.orderNbr> > > > > .Select(Base, order.OrderType, order.OrderNbr); foreach (SOAdjust adj in docgraph.SOAdjustments.Select()) { SOAdjust other = PXSelectGroupBy <SOAdjust, Where <SOAdjust.voided, Equal <False>, And <SOAdjust.adjdOrderType, Equal <Required <SOAdjust.adjdOrderType> >, And <SOAdjust.adjdOrderNbr, Equal <Required <SOAdjust.adjdOrderNbr> >, And <Where <SOAdjust.adjgDocType, NotEqual <Required <SOAdjust.adjgDocType> >, Or <SOAdjust.adjgRefNbr, NotEqual <Required <SOAdjust.adjgRefNbr> > > > > > > >, Aggregate <GroupBy <SOAdjust.adjdOrderType, GroupBy <SOAdjust.adjdOrderNbr, Sum <SOAdjust.curyAdjdAmt, Sum <SOAdjust.adjAmt> > > > > > .Select(Base, adj.AdjdOrderType, adj.AdjdOrderNbr, adj.AdjgDocType, adj.AdjgRefNbr); if (other == null || other.AdjdOrderNbr == null) { docgraph.SOAdjustments.Cache.SetValueExt <SOAdjust.curyAdjgAmt>(adj, adj.CuryAdjgAmt - rutrot.CuryTotalAmt); docgraph.SOAdjustments.Update(adj); } } } }
public void Update(Doc document) { if (document == null) { return; } RUTROT rutrot = Rutrots.Current ?? Rutrots.SelectSingle(); DocExt documentRR = PXCache <Doc> .GetExtension <DocExt>(document); Branch branch = PXSelect <Branch, Where <Branch.branchID, Equal <Required <Branch.branchID> > > > .Select(Base, documentRR.GetDocumentBranchID()); BranchRUTROT branchRR = RUTROTHelper.GetExtensionNullable <Branch, BranchRUTROT>(branch); PXErrorLevel errorLevel = documentRR.GetDocumentHold() != true ? PXErrorLevel.Error : PXErrorLevel.Warning; bool enableEdit = documentRR.GetRUTROTCompleted() != true && RUTROTHelper.CurrenciesMatch(branchRR, documentRR); bool showSection = documentRR.IsRUTROTDeductible == true; bool showROTSection = showSection && rutrot?.RUTROTType == RUTROTTypes.ROT; bool isAutoDistribution = rutrot?.AutoDistribution == true; UpdateRUTROTCheckbox(enableEdit, RUTROTHelper.IsRUTROTAllowed(branchRR, documentRR)); UpdateRUTROTSection(showSection, enableEdit, showROTSection); UpdateDistributionControls(showSection, enableEdit, isAutoDistribution); SetPersistingChecks(documentRR, rutrot); WarnOnDeductionExceedsAllowance(documentRR, rutrot, errorLevel); WarnUndistributedAmount(documentRR, rutrot, errorLevel, currencyinfo.Current ?? currencyinfo.SelectSingle()); }
protected virtual void InventoryItem_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { InventoryItem item = e.Row as InventoryItem; if (item == null) { return; } InventoryItemRUTROT itemRR = PXCache <InventoryItem> .GetExtension <InventoryItemRUTROT>(item); Branch branch = Base.CurrentBranch.SelectSingle(PXAccess.GetBranchID()); BranchRUTROT branchRR = RUTROTHelper.GetExtensionNullable <Branch, BranchRUTROT>(branch); bool allowRUTROT = branchRR?.AllowsRUTROT == true; bool isOtherCostOrNull = itemRR.RUTROTItemType == null || itemRR.RUTROTItemType == RUTROTItemTypes.OtherCost; PXUIFieldAttribute.SetVisible <InventoryItemRUTROT.isRUTROTDeductible>(sender, item, allowRUTROT); PXUIFieldAttribute.SetVisible <InventoryItemRUTROT.isRUTROTDeductible>(Base.Item.Cache, item, allowRUTROT); PXUIFieldAttribute.SetVisible <InventoryItemRUTROT.rUTROTItemType>(Base.Item.Cache, item, allowRUTROT); PXUIFieldAttribute.SetVisible <InventoryItemRUTROT.rUTROTType>(Base.Item.Cache, item, allowRUTROT); PXUIFieldAttribute.SetVisible <InventoryItemRUTROT.rUTROTWorkTypeID>(Base.Item.Cache, item, allowRUTROT); PXUIFieldAttribute.SetEnabled <InventoryItemRUTROT.rUTROTWorkTypeID>(sender, item, !isOtherCostOrNull && itemRR.IsRUTROTDeductible == true); PXUIFieldAttribute.SetEnabled <InventoryItemRUTROT.rUTROTItemType>(sender, item, itemRR.IsRUTROTDeductible == true); PXUIFieldAttribute.SetEnabled <InventoryItemRUTROT.rUTROTType>(sender, item, itemRR.IsRUTROTDeductible == true); if (!isOtherCostOrNull && !RUTROTHelper.IsUpToDateWorkType(itemRR.RUTROTWorkTypeID, this.Base.Accessinfo.BusinessDate ?? DateTime.Now, this.Base)) { sender.RaiseExceptionHandling <InventoryItemRUTROT.rUTROTWorkTypeID>(item, itemRR.RUTROTWorkTypeID, new PXSetPropertyException(RUTROTMessages.ObsoleteWorkTypeWarning, PXErrorLevel.Warning)); } else { sender.RaiseExceptionHandling <InventoryItemRUTROT.rUTROTWorkTypeID>(item, itemRR.RUTROTWorkTypeID, null); } }
public void UpdateTranDeductibleFromInventory(IRUTROTableLine line, IRUTROTable document) { if (line == null) { return; } InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, line.GetInventoryID()); InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(item); if (itemRR == null) { return; } if (document?.IsRUTROTDeductible == true) { line.IsRUTROTDeductible = itemRR.IsRUTROTDeductible == true; } else { line.IsRUTROTDeductible = false; } if (itemRR.RUTROTItemType != null) { line.RUTROTItemType = itemRR.RUTROTItemType; } if (itemRR.RUTROTWorkTypeID != null) { line.RUTROTWorkTypeID = itemRR.RUTROTWorkTypeID; } }
public void ValidateWorkTypes(IEnumerable <DocumentDetails> documents) { Dictionary <int, RUTROTWorkType> availableWorkTypes = GetAvailableWorkTypes(this, this.Accessinfo.BusinessDate); bool haveUnavailableWorkTypes = false; for (int i = 0; i < documents.Count(); i++) { foreach (ARTran tran in documents.ElementAt(i).Lines) { ARTranRUTROT tranRR = RUTROTHelper.GetExtensionNullable <ARTran, ARTranRUTROT>(tran); if (tranRR?.IsRUTROTDeductible == true && (tranRR.RUTROTItemType == RUTROTItemTypes.MaterialCost || tranRR.RUTROTItemType == RUTROTItemTypes.Service)) { if (!availableWorkTypes.ContainsKey(tranRR.RUTROTWorkTypeID.Value)) { haveUnavailableWorkTypes = true; PXProcessing.SetError(i, new PXException(RUTROTMessages.CannotClaimWorkType)); } } } } if (haveUnavailableWorkTypes) { throw new PXException(RUTROTMessages.CannotClaimWorkType); } }
protected virtual void ARTran_RUTROTType_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { ARTranRUTROT row = RUTROTHelper.GetExtensionNullable <ARTran, ARTranRUTROT>((ARTran)e.Row); if (row != null) { row.RUTROTWorkTypeID = null; } }
protected virtual void RUTROT_RUTROTType_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { DocExt document = RUTROTHelper.GetExtensionNullable <Doc, DocExt>(Document.Current); RUTROT rutrot = (RUTROT)e.Row; ClearROTFields(rutrot); ClearWorkTypes(rutrot); RecalcFormulas(rutrot, document); }
private static void CheckProperUnitOfMeasure(PXCache sender, PXFieldUpdatedEventArgs e) { InventoryItem row = (InventoryItem)e.Row; InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <InventoryItem, InventoryItemRUTROT>(row); if (row != null && itemRR?.RUTROTItemType == RUTROTItemTypes.Service) { sender.RaiseExceptionHandling <InventoryItemRUTROT.rUTROTItemType>(row, itemRR.RUTROTItemType, new PXSetPropertyException(RUTROTMessages.ServiceMustBeHour, PXErrorLevel.Warning)); } }
protected virtual void HiddenInventoryItem_RUTROTItemType_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { var row = (HiddenInventoryItem)e.Row; HiddenInventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <HiddenInventoryItem, HiddenInventoryItemRUTROT>(row); if (row != null && itemRR?.RUTROTItemType == RUTROTItemTypes.OtherCost) { sender.SetValueExt <HiddenInventoryItemRUTROT.rUTROTWorkTypeID>(row, null); } }
protected virtual void RUTROT_RowInserted(PXCache sender, PXRowInsertedEventArgs e) { RUTROT rutrot = (RUTROT)e.Row; rutrot.CuryAllowedAmt = 0m; rutrot.CuryMaterialCost = 0m; rutrot.CuryOtherCost = 0m; rutrot.CuryWorkPrice = 0m; RecalcFormulas(rutrot, RUTROTHelper.GetExtensionNullable <Doc, DocExt>(Document.Current)); }
protected virtual void ARTran_RowInserting(PXCache sender, PXRowInsertingEventArgs e) { if (e.Row == null) { return; } ARTran row = e.Row as ARTran; ARTranRUTROT rowRR = RUTROTHelper.GetExtensionNullable <ARTran, ARTranRUTROT>(row); rowRR.CuryRUTROTTaxAmountDeductible = decimal.Zero; }
protected virtual void ARInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e) { ARInvoiceRUTROT doc = RUTROTHelper.GetExtensionNullable <ARInvoice, ARInvoiceRUTROT>(e.Row as ARInvoice); if (doc == null) { return; } RRManager.Update((ARInvoice)e.Row); UpdateLinesControls(doc.IsRUTROTDeductible == true); }
protected virtual void SOLine_RowInserting(PXCache sender, PXRowInsertingEventArgs e) { if (e.Row == null) { return; } var row = (SOLine)e.Row; SOLineRUTROT rowRR = RUTROTHelper.GetExtensionNullable <SOLine, SOLineRUTROT>(row); rowRR.CuryRUTROTTaxAmountDeductible = decimal.Zero; }
private void ClearWorkTypes(RUTROT rutrot) { foreach (Tran line in Transactions.Select()) { TranExt lineRR = RUTROTHelper.GetExtensionNullable <Tran, TranExt>(line); RUTROTWorkType workType = PXSelect <RUTROTWorkType, Where <RUTROTWorkType.workTypeID, Equal <Required <RUTROTWorkType.workTypeID> > > > .Select(this.Base, lineRR.RUTROTWorkTypeID); if (workType?.RUTROTType != rutrot.RUTROTType) { lineRR.RUTROTWorkTypeID = null; Transactions.Update(line); } } }
protected virtual void ARTran_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { var row = (ARTran)e.Row; if (row == null) { return; } IN.InventoryItem item = PXSelect <IN.InventoryItem, Where <IN.InventoryItem.inventoryID, Equal <Required <IN.InventoryItem.inventoryID> > > > .Select(Base, row.InventoryID); InventoryItemRUTROT itemRR = RUTROTHelper.GetExtensionNullable <IN.InventoryItem, InventoryItemRUTROT>(item); Base.Transactions.Cache.SetValueExt <ARTranRUTROT.isRUTROTDeductible>(e.Row, itemRR?.IsRUTROTDeductible ?? false); }
protected virtual void ARInvoice_CuryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { var row = (ARInvoice)e.Row; if (row == null) { return; } ARInvoiceRUTROT doc = RUTROTHelper.GetExtensionNullable <ARInvoice, ARInvoiceRUTROT>(row); if (!RUTROTHelper.CurrenciesMatch(RUTROTHelper.GetBranchRUTROT(Base), doc)) { doc.IsRUTROTDeductible = false; } }