protected override PMCommitment FromRecord(PXCache sender, object row) { SOMiscLine2 line = (SOMiscLine2)row; SOOrder order = (SOOrder)PXParentAttribute.SelectParent(sender.Graph.Caches[detailEntity], row, typeof(SOOrder)); int sign = line.Operation == SOOperation.Issue ? 1 : -1; PMCommitment commitment = new PMCommitment(); commitment.Type = PMCommitmentType.Internal; commitment.CommitmentID = line.CommitmentID ?? Guid.NewGuid(); commitment.AccountGroupID = GetAccountGroup(sender, row); commitment.ProjectID = line.ProjectID; commitment.ProjectTaskID = line.TaskID; commitment.UOM = line.UOM; commitment.Qty = sign * line.OrderQty; commitment.Amount = sign * line.LineAmt; commitment.OpenQty = sign * line.UnbilledQty; commitment.OpenAmount = sign * line.UnbilledAmt; commitment.ReceivedQty = 0; commitment.InvoicedQty = 0; commitment.InvoicedAmount = 0; commitment.InvoicedIsReadonly = true; commitment.RefNoteID = order.NoteID; commitment.InventoryID = line.InventoryID ?? PMInventorySelectorAttribute.EmptyInventoryID; commitment.CostCodeID = line.CostCodeID ?? CostCodeAttribute.GetDefaultCostCode(); return(commitment); }
public virtual void APSalesPriceFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { APSalesPriceFilter row = (APSalesPriceFilter)e.Row; Records.Cache.AllowInsert = row.VendorID != null && row.CuryID != null; Records.Cache.AllowUpdate = Records.Cache.AllowDelete = row.VendorID != null; Vendor vend = (Vendor)PXParentAttribute.SelectParent(sender, e.Row, typeof(Vendor)); if (vend != null) { PXUIFieldAttribute.SetEnabled <APSalesPriceFilter.curyID>(sender, e.Row, vend.CuryID == null || vend.AllowOverrideCury == true); } PXUIFieldAttribute.SetVisible <APSalesPrice.pendingBreakQty>(Records.Cache, null, row.PromotionalPrice == false); PXUIFieldAttribute.SetVisible <APSalesPrice.pendingPrice>(Records.Cache, null, row.PromotionalPrice == false); PXUIFieldAttribute.SetVisible <APSalesPrice.effectiveDate>(Records.Cache, null, row.PromotionalPrice == false); PXUIFieldAttribute.SetVisible <APSalesPrice.lastPrice>(Records.Cache, null, row.PromotionalPrice == false); PXUIFieldAttribute.SetVisible <APSalesPrice.lastBreakQty>(Records.Cache, null, row.PromotionalPrice == false); PXUIFieldAttribute.SetVisible <APSalesPrice.expirationDate>(Records.Cache, null, row.PromotionalPrice == true); PXUIFieldAttribute.SetEnabled <APSalesPrice.salesPrice>(Records.Cache, null, row.PromotionalPrice == true); PXUIFieldAttribute.SetEnabled <APSalesPrice.breakQty>(Records.Cache, null, row.PromotionalPrice == true); PXUIFieldAttribute.SetEnabled <APSalesPrice.lastDate>(Records.Cache, null, row.PromotionalPrice == true); PXUIFieldAttribute.SetEnabled(sender, e.Row, typeof(TM.OwnedFilter.ownerID).Name, e.Row == null || (bool?)sender.GetValue(e.Row, typeof(TM.OwnedFilter.myOwner).Name) == false); PXUIFieldAttribute.SetEnabled(sender, e.Row, typeof(TM.OwnedFilter.workGroupID).Name, e.Row == null || (bool?)sender.GetValue(e.Row, typeof(TM.OwnedFilter.myWorkGroup).Name) == false); update.SetEnabled(row.PromotionalPrice != true); }
protected virtual void Location_IsAPAccountSameAsMain_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { CR.Location record = (CR.Location)e.Row; if (record.IsAPAccountSameAsMain == false) { LocationAPAccountSub mainloc = APAccountSubLocation.Select(); record.VAPAccountID = mainloc.VAPAccountID; record.VAPSubID = mainloc.VAPSubID; record.VAPAccountLocationID = record.LocationID; LocationAPAccountSub copyloc = new LocationAPAccountSub(); copyloc.BAccountID = record.BAccountID; copyloc.LocationID = record.LocationID; copyloc.VAPAccountID = record.VAPAccountID; copyloc.VAPSubID = record.VAPSubID; BusinessAccount.Cache.Current = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); APAccountSubLocation.Insert(copyloc); } if (record.IsAPAccountSameAsMain == true) { record.VAPAccountID = null; record.VAPSubID = null; BAccount baccount = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); if (baccount != null) { record.VAPAccountLocationID = baccount.DefLocationID; } } }
protected override decimal CalcLineTotal(PXCache sender, object row) { decimal CuryLineTotal = 0m; object document = PXParentAttribute.SelectParent(sender, row, _ParentType); object[] progressiveDetails = PXParentAttribute.SelectChildren(sender.Graph.Caches[typeof(PMProformaProgressLine)], document, _ParentType); object[] transactionDetails = PXParentAttribute.SelectChildren(sender.Graph.Caches[typeof(PMProformaTransactLine)], document, _ParentType); if (progressiveDetails != null) { foreach (object detrow in progressiveDetails) { CuryLineTotal += GetCuryTranAmt(sender.Graph.Caches[typeof(PMProformaProgressLine)], sender.Graph.Caches[typeof(PMProformaProgressLine)].ObjectsEqual(detrow, row) ? row : detrow) ?? 0m; } } if (transactionDetails != null) { foreach (object detrow in transactionDetails) { CuryLineTotal += GetCuryTranAmt(sender.Graph.Caches[typeof(PMProformaTransactLine)], sender.Graph.Caches[typeof(PMProformaTransactLine)].ObjectsEqual(detrow, row) ? row : detrow) ?? 0m; } } return(CuryLineTotal); }
protected virtual void INTran_RowInserted(PXCache sender, PXRowInsertedEventArgs e) { INTran row = e.Row as INTran; if (row != null && (row.OrigModule == BatchModule.SO || row.OrigModule == BatchModule.PO)) { INRegister doc = (INRegister)PXParentAttribute.SelectParent(sender, e.Row, typeof(INRegister)); if (doc != null) { PXCache cache = issue.Cache; object copy = cache.CreateCopy(doc); doc.SOShipmentType = row.SOShipmentType; doc.SOShipmentNbr = row.SOShipmentNbr; doc.SOOrderType = row.SOOrderType; doc.SOOrderNbr = row.SOOrderNbr; doc.POReceiptType = row.POReceiptType; doc.POReceiptNbr = row.POReceiptNbr; if (!object.Equals(doc, cache.Current)) { cache.Update(doc); } else { if (cache.GetStatus(doc) == PXEntryStatus.Notchanged || cache.GetStatus(doc) == PXEntryStatus.Held) { cache.SetStatus(doc, PXEntryStatus.Updated); } cache.RaiseRowUpdated(doc, copy); } } } }
protected override PMCommitment FromRecord(PXCache sender, object row) { POLineUOpen poline = (POLineUOpen)row; POOrder order = (POOrder)PXParentAttribute.SelectParent(sender.Graph.Caches[detailEntity], row, typeof(POOrder)); PMCommitment commitment = new PMCommitment(); commitment.Type = PMCommitmentType.Internal; commitment.CommitmentID = poline.CommitmentID ?? Guid.NewGuid(); commitment.AccountGroupID = GetAccountGroup(sender, row); commitment.ProjectID = poline.ProjectID; commitment.ProjectTaskID = poline.TaskID; commitment.UOM = poline.UOM; commitment.Qty = poline.OrderQty; commitment.Amount = poline.ExtCost; commitment.OpenQty = poline.OpenQty; commitment.OpenAmount = poline.OpenAmt; commitment.ReceivedQty = poline.ReceivedQty; commitment.InvoicedQty = 0; commitment.InvoicedAmount = 0; commitment.InvoicedIsReadonly = true; commitment.RefNoteID = order.NoteID; commitment.InventoryID = poline.InventoryID ?? PMInventorySelectorAttribute.EmptyInventoryID; commitment.CostCodeID = poline.CostCodeID ?? CostCodeAttribute.GetDefaultCostCode(); return(commitment); }
protected override void Location_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { BAccount baccount = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); PXUIFieldAttribute.SetEnabled <CR.Location.isAPAccountSameAsMain>(sender, e.Row, baccount != null && !object.Equals(baccount.DefLocationID, ((Location)e.Row).LocationID)); PXUIFieldAttribute.SetEnabled <CR.Location.isAPPaymentInfoSameAsMain>(sender, e.Row, baccount != null && !object.Equals(baccount.DefLocationID, ((Location)e.Row).LocationID)); base.Location_RowSelected(sender, e); }
public EPExpenseClaim GetParentClaim(string claimRefNbr) { EPExpenseClaimDetails receiptStub = new EPExpenseClaimDetails() { RefNbr = claimRefNbr }; return(PXParentAttribute.SelectParent <EPExpenseClaim>(Receipts.Cache, receiptStub)); }
private void SetParentChanged(PXCache sender, object Row) { object parent = PXParentAttribute.SelectParent(sender, Row); if (parent != null && lotserclass.Cache.GetStatus(parent) == PXEntryStatus.Notchanged) { lotserclass.Cache.SetStatus(parent, PXEntryStatus.Updated); } }
public virtual string GetHeaderMasterFinPeriodID(PXCache cache, object row) { if (HeaderFindingMode == HeaderFindingModes.Parent) { object parentRow = PXParentAttribute.SelectParent(cache, row, BqlCommand.GetItemType(HeaderMasterFinPeriodIDType)); return((string)BqlHelper.GetOperandValue(cache.Graph, parentRow, HeaderMasterFinPeriodIDType)); } return((string)BqlHelper.GetCurrentValue(cache.Graph, HeaderMasterFinPeriodIDType)); }
protected virtual void INTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert || (e.Operation & PXDBOperation.Command) == PXDBOperation.Update) { INRegister parent = (INRegister)PXParentAttribute.SelectParent(sender, e.Row); if (parent != null) { PXDefaultAttribute.SetPersistingCheck <INTran.toLocationID>(sender, e.Row, parent.TransferType == INTransferType.OneStep ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing); ((INTran)e.Row).ToSiteID = parent.ToSiteID; } } }
public virtual void APSalesPriceFilter_VendorID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { APSalesPriceFilter row = e.Row as APSalesPriceFilter; if (row != null) { Vendor vend = (Vendor)PXParentAttribute.SelectParent(sender, e.Row, typeof(Vendor)); if (vend != null) { row.CuryID = vend.CuryID; } } }
protected virtual void _(Events.RowDeleted <APTran> e) { if (e.Row.TranType != APDocType.Prepayment || string.IsNullOrEmpty(e.Row.POOrderType) || string.IsNullOrEmpty(e.Row.PONbr)) { return; } var prepaidOrder = PXParentAttribute.SelectParent <POOrderPrepayment>(Base.Transactions.Cache, e.Row); if (prepaidOrder != null && !PXParentAttribute.SelectChildren(Base.Transactions.Cache, prepaidOrder, typeof(POOrderPrepayment)).Any()) { PrepaidOrders.Delete(prepaidOrder); } }
protected override bool EraseCommitment(PXCache sender, object row) { POLineUOpen poline = (POLineUOpen)row; POOrder order = (POOrder)PXParentAttribute.SelectParent(sender.Graph.Caches[detailEntity], row, typeof(POOrder)); if (order.OrderType == POOrderType.Blanket || order.OrderType == POOrderType.StandardBlanket || order.Hold == true || order.Approved != true || order.Cancelled == true || poline.Cancelled == true || poline.TaskID == null) { return(true); } else { return(GetAccountGroup(sender, row) == null); } }
protected override bool EraseCommitment(PXCache sender, object row) { SOOrder order = (SOOrder)PXParentAttribute.SelectParent(sender.Graph.Caches[detailEntity], row, typeof(SOOrder)); SOOrderType orderType = (SOOrderType)PXSelectorAttribute.Select <SOOrder.orderType>(sender.Graph.Caches[typeof(SOOrder)], order); if (order.Hold == true || order.Cancelled == true || orderType.CommitmentTracking != true || sender.GetValue(row, "TaskID") == null) { return(true); } else { return(GetAccountGroup(sender, row) == null); } }
public override INItemPlan DefaultValues(PXCache sender, INItemPlan plan_Row, object orig_Row) { string orderType = (string)sender.GetValue <POLine.orderType>(orig_Row); string orderNbr = (string)sender.GetValue <POLine.orderNbr>(orig_Row); int? inventoryID = (int?)sender.GetValue <POLine.inventoryID>(orig_Row); int? siteID = (int?)sender.GetValue <POLine.siteID>(orig_Row); bool? cancelled = (bool?)sender.GetValue <POLine.cancelled>(orig_Row); bool? completed = (bool?)sender.GetValue <POLine.completed>(orig_Row); if (orderType.IsNotIn(POOrderType.RegularOrder, POOrderType.DropShip, POOrderType.Blanket) || inventoryID == null || siteID == null || cancelled == true || completed == true) { return(null); } PXCache parentCache = sender.Graph.Caches[BqlCommand.GetItemType(_ParentNoteID)]; POOrder currentOrder = (POOrder)parentCache.Current; POOrder order = currentOrder?.OrderType == orderType && currentOrder.OrderNbr == orderNbr ? currentOrder : (POOrder)PXParentAttribute.SelectParent(sender, orig_Row, typeof(POOrder));; bool IsOnHold = IsOrderOnHold(order); string newPlanType; if (!TryCalcPlanType(sender, orig_Row, IsOnHold, out newPlanType)) { return(null); } plan_Row.PlanType = newPlanType; plan_Row.BAccountID = (int?)sender.GetValue <POLine.vendorID>(orig_Row); plan_Row.InventoryID = inventoryID; plan_Row.SubItemID = (int?)sender.GetValue <POLine.subItemID>(orig_Row); plan_Row.SiteID = siteID; plan_Row.PlanDate = (DateTime?)sender.GetValue <POLine.promisedDate>(orig_Row); plan_Row.PlanQty = (decimal?)sender.GetValue <POLine.baseOpenQty>(orig_Row); plan_Row.RefNoteID = (Guid?)parentCache.GetValue(order, _ParentNoteID.Name); plan_Row.Hold = IsOnHold; if (string.IsNullOrEmpty(plan_Row.PlanType)) { return(null); } return(plan_Row); }
protected override PMCommitment FromRecord(PXCache sender, object row) { SOLine4 line = (SOLine4)row; SOOrder order = (SOOrder)PXParentAttribute.SelectParent(sender.Graph.Caches[detailEntity], row, typeof(SOOrder)); int sign = line.Operation == SOOperation.Issue ? 1 : -1; PMCommitment commitment = new PMCommitment(); commitment.Type = PMCommitmentType.Internal; commitment.CommitmentID = (Guid?)sender.GetValue(row, "CommitmentID") ?? Guid.NewGuid(); commitment.AccountGroupID = GetAccountGroup(sender, row); commitment.ProjectID = (int?)sender.GetValue(row, "ProjectID"); commitment.ProjectTaskID = (int?)sender.GetValue(row, "TaskID"); commitment.UOM = line.UOM; commitment.OrigQty = sign * line.OrderQty; commitment.OrigAmount = sign * (decimal?)sender.GetValue(row, "LineAmt"); commitment.Qty = sign * line.OrderQty; commitment.Amount = sign * (decimal?)sender.GetValue(row, "LineAmt"); if (order.Hold == true || order.Cancelled == true) { //Back Order put on Hold. commitment.OpenQty = 0; commitment.OpenAmount = 0; } else { commitment.OpenQty = sign * line.OpenQty; commitment.OpenAmount = sign * line.OpenAmt; } commitment.ReceivedQty = sign * line.ShippedQty; commitment.InvoicedQty = 0; commitment.InvoicedAmount = 0; commitment.InvoicedIsReadonly = true; commitment.RefNoteID = order.NoteID; commitment.InventoryID = line.InventoryID ?? PMInventorySelectorAttribute.EmptyInventoryID; return(commitment); }
protected override PMCommitment FromRecord(PXCache sender, object row) { POLine poline = (POLine)row; POOrder order = (POOrder)PXParentAttribute.SelectParent(sender.Graph.Caches[detailEntity], row, typeof(POOrder)); PMCommitment commitment = new PMCommitment(); commitment.Type = PMCommitmentType.Internal; commitment.CommitmentID = poline.CommitmentID ?? Guid.NewGuid(); commitment.AccountGroupID = GetAccountGroup(sender, row); commitment.ProjectID = poline.ProjectID; commitment.ProjectTaskID = poline.TaskID; commitment.UOM = poline.UOM; if (poline.OrigExtCost == null) { commitment.OrigQty = poline.OrderQty; commitment.OrigAmount = poline.ExtCost + poline.RetainageAmt.GetValueOrDefault(); } else { commitment.OrigQty = poline.OrigOrderQty; commitment.OrigAmount = poline.OrigExtCost; } commitment.Qty = poline.OrderQty; commitment.Amount = poline.ExtCost + poline.RetainageAmt.GetValueOrDefault(); commitment.OpenQty = CalculateOpenQty(poline.OpenQty, poline.UnbilledQty); commitment.OpenAmount = CalculateOpenAmount(commitment.OpenQty, poline.OrderQty, poline.ExtCost, poline.UnbilledAmt); commitment.ReceivedQty = CalculateReceivedQty(poline.CompletedQty, poline.BilledQty); commitment.InvoicedQty = 0; commitment.InvoicedAmount = 0; commitment.InvoicedIsReadonly = true; commitment.RefNoteID = order.NoteID; commitment.InventoryID = poline.InventoryID ?? PMInventorySelectorAttribute.EmptyInventoryID; commitment.CostCodeID = poline.CostCodeID ?? CostCodeAttribute.GetDefaultCostCode(); return(commitment); }
public virtual void _(Events.FieldDefaulting <EPExpenseClaimDetails.corpCardID> e) { if (e.Row is EPExpenseClaimDetails row) { if (row.EmployeeID != null) { if (row.PaidWith != EPExpenseClaimDetails.paidWith.PersonalAccount) { var firstCreditCard = GetFirstCreditCardForEmployeeAlphabeticallySorted(row.EmployeeID.Value); var thereIsCreditCardForEmployee = firstCreditCard != null; if (thereIsCreditCardForEmployee) { var lastUsedCreditCard = GetLastUsedCreditCardForEmployee(row.EmployeeID.Value); var corpCardId = lastUsedCreditCard != null ? lastUsedCreditCard.CorpCardID : firstCreditCard.CorpCardID; if (row.RefNbr != null) { EPExpenseClaim claim = PXParentAttribute.SelectParent <EPExpenseClaim>(e.Cache, row); CashAccount cashAccount = CACorpCardsMaint.GetCardCashAccount(Base, corpCardId); if (cashAccount.CuryID != claim.CuryID) { corpCardId = null; } } e.Cache.SetValueExt <EPExpenseClaimDetails.corpCardID>(row, corpCardId); } } } } }
public List <PXResult <INItemPlan, INPlanType> > ProcessPOReceipt(PXGraph graph, IEnumerable <PXResult <INItemPlan, INPlanType> > list, string POReceiptType, string POReceiptNbr) { var serviceOrder = new PXSelect <FSServiceOrder>(graph); if (!graph.Views.Caches.Contains(typeof(FSServiceOrder))) { graph.Views.Caches.Add(typeof(FSServiceOrder)); } var soDetSplit = new PXSelect <FSSODetSplit>(graph); if (!graph.Views.Caches.Contains(typeof(FSSODetSplit))) { graph.Views.Caches.Add(typeof(FSSODetSplit)); } var initemplan = new PXSelect <INItemPlan>(graph); List <PXResult <INItemPlan, INPlanType> > returnList = new List <PXResult <INItemPlan, INPlanType> >(); Base.FieldVerifying.AddHandler <FSSODetSplit.lotSerialNbr>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; }); List <FSSODetSplit> splitsToDeletePlanID = new List <FSSODetSplit>(); List <FSSODetSplit> insertedSchedules = new List <FSSODetSplit>(); List <INItemPlan> deletedPlans = new List <INItemPlan>(); foreach (PXResult <INItemPlan, INPlanType> res in list) { bool includeInReturnList = true; INItemPlan plan = PXCache <INItemPlan> .CreateCopy(res); INPlanType plantype = res; //avoid ReadItem() if (initemplan.Cache.GetStatus(plan) != PXEntryStatus.Inserted) { initemplan.Cache.SetStatus(plan, PXEntryStatus.Notchanged); } //Original Schedule Marked for PO / Allocated on Remote Whse //FSSODetSplit schedule = PXSelect<FSSODetSplit, Where<FSSODetSplit.planID, Equal<Required<FSSODetSplit.planID>>, And<FSSODetSplit.completed, Equal<False>>>>.Select(this, plan.DemandPlanID); FSSODetSplit schedule = PXSelect <FSSODetSplit, Where <FSSODetSplit.planID, Equal <Required <FSSODetSplit.planID> > > > .Select(graph, plan.DemandPlanID); if (schedule != null && (schedule.Completed == false || soDetSplit.Cache.GetStatus(schedule) == PXEntryStatus.Updated)) { includeInReturnList = false; schedule = PXCache <FSSODetSplit> .CreateCopy(schedule); schedule.BaseReceivedQty += plan.PlanQty; schedule.ReceivedQty = INUnitAttribute.ConvertFromBase(soDetSplit.Cache, schedule.InventoryID, schedule.UOM, (decimal)schedule.BaseReceivedQty, INPrecision.QUANTITY); soDetSplit.Cache.Update(schedule); INItemPlan origplan = PXSelect <INItemPlan, Where <INItemPlan.planID, Equal <Required <INItemPlan.planID> > > > .Select(graph, plan.DemandPlanID); if (origplan != null) { origplan.PlanQty = schedule.BaseQty - schedule.BaseReceivedQty; initemplan.Cache.Update(origplan); } //select Allocated line if any, exclude allocated on Remote Whse PXSelectBase <INItemPlan> cmd = new PXSelectJoin <INItemPlan, InnerJoin <FSSODetSplit, On <FSSODetSplit.planID, Equal <INItemPlan.planID> > >, Where <INItemPlan.demandPlanID, Equal <Required <INItemPlan.demandPlanID> >, And <FSSODetSplit.isAllocated, Equal <True>, And <FSSODetSplit.siteID, Equal <Required <FSSODetSplit.siteID> > > > > >(graph); if (!string.IsNullOrEmpty(plan.LotSerialNbr)) { cmd.WhereAnd <Where <INItemPlan.lotSerialNbr, Equal <Required <INItemPlan.lotSerialNbr> > > >(); } PXResult <INItemPlan> allocres = cmd.Select(plan.DemandPlanID, plan.SiteID, plan.LotSerialNbr); if (allocres != null) { schedule = PXResult.Unwrap <FSSODetSplit>(allocres); soDetSplit.Cache.SetStatus(schedule, PXEntryStatus.Notchanged); schedule = PXCache <FSSODetSplit> .CreateCopy(schedule); schedule.BaseQty += plan.PlanQty; schedule.Qty = INUnitAttribute.ConvertFromBase(soDetSplit.Cache, schedule.InventoryID, schedule.UOM, (decimal)schedule.BaseQty, INPrecision.QUANTITY); schedule.POReceiptType = POReceiptType; schedule.POReceiptNbr = POReceiptNbr; soDetSplit.Cache.Update(schedule); INItemPlan allocplan = PXCache <INItemPlan> .CreateCopy(res); allocplan.PlanQty += plan.PlanQty; initemplan.Cache.Update(allocplan); plantype = PXCache <INPlanType> .CreateCopy(plantype); plantype.ReplanOnEvent = null; plantype.DeleteOnEvent = true; } else { serviceOrder.Current = (FSServiceOrder)PXParentAttribute.SelectParent(soDetSplit.Cache, schedule, typeof(FSServiceOrder)); schedule = PXCache <FSSODetSplit> .CreateCopy(schedule); long?oldPlanID = schedule.PlanID; ClearScheduleReferences(ref schedule); plantype.ReplanOnEvent = INPlanConstants.PlanF1; schedule.IsAllocated = false; schedule.LotSerialNbr = plan.LotSerialNbr; schedule.POCreate = false; schedule.POSource = null; schedule.POReceiptType = POReceiptType; schedule.POReceiptNbr = POReceiptNbr; schedule.SiteID = plan.SiteID; schedule.VendorID = null; schedule.BaseReceivedQty = 0m; schedule.ReceivedQty = 0m; schedule.BaseQty = plan.PlanQty; schedule.Qty = INUnitAttribute.ConvertFromBase(soDetSplit.Cache, schedule.InventoryID, schedule.UOM, (decimal)schedule.BaseQty, INPrecision.QUANTITY); //update SupplyPlanID in existing item plans (replenishment) foreach (PXResult <INItemPlan> demand_res in PXSelect <INItemPlan, Where <INItemPlan.supplyPlanID, Equal <Required <INItemPlan.supplyPlanID> > > > .Select(graph, oldPlanID)) { INItemPlan demand_plan = PXCache <INItemPlan> .CreateCopy(demand_res); initemplan.Cache.SetStatus(demand_plan, PXEntryStatus.Notchanged); demand_plan.SupplyPlanID = plan.PlanID; initemplan.Cache.Update(demand_plan); } schedule.PlanID = plan.PlanID; schedule = (FSSODetSplit)soDetSplit.Cache.Insert(schedule); insertedSchedules.Add(schedule); } } else if (plan.DemandPlanID == null) { //Original schedule Marked for PO //TODO: verify this is sufficient for Original SO marked for TR. schedule = PXSelect <FSSODetSplit, Where <FSSODetSplit.planID, Equal <Required <FSSODetSplit.planID> >, And <FSSODetSplit.completed, Equal <False> > > > .Select(graph, plan.PlanID); if (schedule != null) { includeInReturnList = false; soDetSplit.Cache.SetStatus(schedule, PXEntryStatus.Notchanged); schedule = PXCache <FSSODetSplit> .CreateCopy(schedule); schedule.Completed = true; schedule.POCompleted = true; splitsToDeletePlanID.Add(schedule); soDetSplit.Cache.Update(schedule); INItemPlan origplan = PXSelect <INItemPlan, Where <INItemPlan.planID, Equal <Required <INItemPlan.planID> > > > .Select(graph, plan.PlanID); deletedPlans.Add(origplan); initemplan.Cache.Delete(origplan); } } if (includeInReturnList == true) { returnList.Add(res); } else { if (plantype.ReplanOnEvent != null) { plan.PlanType = plantype.ReplanOnEvent; plan.SupplyPlanID = null; plan.DemandPlanID = null; initemplan.Cache.Update(plan); } else if (plantype.DeleteOnEvent == true) { initemplan.Delete(plan); } } } //Create new schedules for partially received schedules marked for PO. FSSODetSplit prevSplit = null; foreach (FSSODetSplit newsplit in insertedSchedules) { if (prevSplit != null && prevSplit.SrvOrdType == newsplit.SrvOrdType && prevSplit.RefNbr == newsplit.RefNbr && prevSplit.LineNbr == newsplit.LineNbr && prevSplit.InventoryID == newsplit.InventoryID && prevSplit.SubItemID == newsplit.SubItemID && prevSplit.ParentSplitLineNbr == newsplit.ParentSplitLineNbr && prevSplit.LotSerialNbr != null && newsplit.LotSerialNbr != null) { continue; } FSSODetSplit parentschedule = PXSelect <FSSODetSplit, Where <FSSODetSplit.srvOrdType, Equal <Required <FSSODetSplit.srvOrdType> >, And <FSSODetSplit.refNbr, Equal <Required <FSSODetSplit.refNbr> >, And <FSSODetSplit.lineNbr, Equal <Required <FSSODetSplit.lineNbr> >, And <FSSODetSplit.splitLineNbr, Equal <Required <FSSODetSplit.parentSplitLineNbr> > > > > > > .Select(graph, newsplit.SrvOrdType, newsplit.RefNbr, newsplit.LineNbr, newsplit.ParentSplitLineNbr); if (parentschedule != null && parentschedule.Completed == true && parentschedule.POCompleted == true && parentschedule.BaseQty > parentschedule.BaseReceivedQty && deletedPlans.Exists(x => x.PlanID == parentschedule.PlanID)) { serviceOrder.Current = (FSServiceOrder)PXParentAttribute.SelectParent(soDetSplit.Cache, parentschedule, typeof(FSServiceOrder)); parentschedule = PXCache <FSSODetSplit> .CreateCopy(parentschedule); INItemPlan demand = PXCache <INItemPlan> .CreateCopy(deletedPlans.First(x => x.PlanID == parentschedule.PlanID)); UpdateSchedulesFromCompletedPO(graph, soDetSplit, initemplan, parentschedule, serviceOrder, demand); } prevSplit = newsplit; } //Added because of MySql AutoIncrement counters behavior foreach (FSSODetSplit split in splitsToDeletePlanID) { FSSODetSplit schedule = (FSSODetSplit)soDetSplit.Cache.Locate(split); if (schedule != null) { schedule.PlanID = null; soDetSplit.Cache.Update(schedule); } } return(returnList); }
public POReceipt GetPOReceipt(PXCache cache) => PXParentAttribute.SelectParent <POReceipt>(cache, this);
protected virtual void Location_IsAPPaymentInfoSameAsMain_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { CR.Location record = (CR.Location)e.Row; if (record.IsAPPaymentInfoSameAsMain == false) { LocationAPPaymentInfo mainloc = APPaymentInfoLocation.Select(); record.VCashAccountID = mainloc.VCashAccountID; record.VPaymentMethodID = mainloc.VPaymentMethodID; record.VPaymentLeadTime = mainloc.VPaymentLeadTime; record.VPaymentByType = mainloc.VPaymentByType; record.VSeparateCheck = mainloc.VSeparateCheck; record.IsRemitAddressSameAsMain = mainloc.IsRemitAddressSameAsMain; record.VRemitAddressID = mainloc.VRemitAddressID; record.IsRemitContactSameAsMain = mainloc.IsRemitContactSameAsMain; record.VRemitContactID = mainloc.VRemitContactID; record.VPaymentInfoLocationID = record.LocationID; LocationAPPaymentInfo copyloc = new LocationAPPaymentInfo(); copyloc.BAccountID = record.BAccountID; copyloc.LocationID = record.LocationID; copyloc.VCashAccountID = record.VCashAccountID; copyloc.VPaymentMethodID = record.VPaymentMethodID; copyloc.VPaymentLeadTime = record.VPaymentLeadTime; copyloc.VPaymentByType = record.VPaymentByType; copyloc.VSeparateCheck = record.VSeparateCheck; copyloc.IsRemitAddressSameAsMain = record.IsRemitAddressSameAsMain; copyloc.VDefAddressID = record.VDefAddressID; copyloc.VRemitAddressID = record.VRemitAddressID; copyloc.IsRemitContactSameAsMain = record.IsRemitContactSameAsMain; copyloc.VRemitContactID = record.VRemitContactID; copyloc.VDefContactID = record.VDefContactID; if (copyloc.VDefAddressID != copyloc.VRemitAddressID) { Address copyaddr = FindAddress(copyloc.VRemitAddressID); copyaddr = PXCache <Address> .CreateCopy(copyaddr); copyaddr.AddressID = null; copyaddr = RemitAddress.Insert(copyaddr); copyloc.VRemitAddressID = copyaddr.AddressID; record.VRemitAddressID = copyaddr.AddressID; } if (copyloc.VDefContactID != copyloc.VRemitContactID) { Contact copycont = FindContact(copyloc.VRemitContactID); copycont = PXCache <Contact> .CreateCopy(copycont); copycont.ContactID = null; copycont.NoteID = null; copycont = RemitContact.Insert(copycont); copyloc.VRemitContactID = copycont.ContactID; record.VRemitContactID = copycont.ContactID; } foreach (VendorPaymentMethodDetail maindet in this.PaymentDetails.Select(mainloc.BAccountID, mainloc.LocationID, mainloc.VPaymentMethodID)) { VendorPaymentMethodDetail copydet = PXCache <VendorPaymentMethodDetail> .CreateCopy(maindet); copydet.LocationID = copyloc.LocationID; this.PaymentDetails.Insert(copydet); } BusinessAccount.Cache.Current = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); APPaymentInfoLocation.Insert(copyloc); } if (record.IsAPPaymentInfoSameAsMain == true) { foreach (VendorPaymentMethodDetail copydet in this.PaymentDetails.Select(record.BAccountID, record.LocationID, record.VPaymentMethodID)) { this.PaymentDetails.Delete(copydet); } BAccount baccount = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); if (baccount != null) { record.VPaymentInfoLocationID = baccount.DefLocationID; Location mainloc = PXSelect <CR.Location, Where <CR.Location.bAccountID, Equal <Required <CR.Location.bAccountID> >, And <CR.Location.locationID, Equal <Required <CR.Location.locationID> > > > > .Select(sender.Graph, baccount.BAccountID, baccount.DefLocationID); if (mainloc != null) { if (record.DefAddressID != record.VRemitAddressID && mainloc.VRemitAddressID != record.VRemitAddressID) { Address copyaddr = FindAddress(record.VRemitAddressID); RemitAddress.Delete(copyaddr); } if (record.DefContactID != record.VRemitContactID && mainloc.VRemitContactID != record.VRemitContactID) { Contact copycont = FindContact(record.VRemitContactID); RemitContact.Delete(copycont); } } } record.VCashAccountID = null; record.VPaymentMethodID = null; record.VPaymentLeadTime = 0; record.VSeparateCheck = false; record.VRemitAddressID = null; record.VRemitContactID = null; } }