protected IEnumerable updateMaterial(PXAdapter adapter) { var data = Bom.Select(); data.Where(x => ((AMBomMatl)x).BOMID == "210293").ToList() .ForEach(x => { var row = x.GetItem <AMBomMatl>(); Bom.SetValueExt <AMBomMatl.qtyReq>(row, (decimal?)0.006666); Bom.Update(row); }); this.Actions.PressSave(); return(adapter.Get()); }
public void Persist(PersistDelegate baseMethod) { baseMethod(); APRegister doc = Base.APDocument.Current; APRegisterExt docExt = PXCache <APRegister> .GetExtension <APRegisterExt>(doc); // Check for document and released flag if (TWNGUIValidation.ActivateTWGUI(Base) == true && doc != null && doc.Released == true && doc.DocType.IsIn(APDocType.Invoice, APDocType.DebitAdj)) { //if (Base.APTaxTran_TranType_RefNbr.Current == null) //{ // throw new PXException(TWMessages.NoInvTaxDtls); //} foreach (TWNManualGUIAPBill row in SelectFrom <TWNManualGUIAPBill> .Where <TWNManualGUIAPBill.docType.IsEqual <@P.AsString> .And <TWNManualGUIAPBill.refNbr.IsEqual <@P.AsString> > > .View.Select(Base, doc.DocType, doc.RefNbr)) { // Avoid standard logic calling this method twice and inserting duplicate records into TWNGUITrans. if (CountExistedRec(Base, row.GUINbr, row.VATInCode, doc.RefNbr) >= 1) { return; } if (Tax.PK.Find(Base, row.TaxID).GetExtension <TaxExt>().UsrTWNGUI != true) { continue; } Vendor vendor = Vendor.PK.Find(Base, row.VendorID); using (PXTransactionScope ts = new PXTransactionScope()) { TWNReleaseProcess rp = PXGraph.CreateInstance <TWNReleaseProcess>(); TWNGUITrans tWNGUITrans = rp.InitAndCheckOnAP(row.GUINbr, row.VATInCode); rp.CreateGUITrans(new STWNGUITran() { VATCode = row.VATInCode, GUINbr = row.GUINbr, GUIStatus = TWNGUIStatus.Used, BranchID = Base.APTran_TranType_RefNbr.Current.BranchID, GUIDirection = TWNGUIDirection.Receipt, GUIDate = row.GUIDate, GUITitle = vendor?.AcctName, TaxZoneID = row.TaxZoneID, TaxCategoryID = row.TaxCategoryID, TaxID = row.TaxID, TaxNbr = row.TaxNbr, OurTaxNbr = row.OurTaxNbr, NetAmount = row.NetAmt, TaxAmount = row.TaxAmt, AcctCD = vendor?.AcctCD, AcctName = vendor?.AcctName, DeductionCode = row.Deduction, Remark = row.Remark, BatchNbr = doc.BatchNbr, OrderNbr = doc.RefNbr }); if (tWNGUITrans != null) { if (tWNGUITrans.NetAmtRemain < row.NetAmt) { throw new PXException(TWMessages.RemainAmt); } ViewGUITrans.SetValueExt <TWNGUITrans.netAmtRemain>(tWNGUITrans, (tWNGUITrans.NetAmtRemain -= row.NetAmt)); ViewGUITrans.SetValueExt <TWNGUITrans.taxAmtRemain>(tWNGUITrans, (tWNGUITrans.TaxAmtRemain -= row.TaxAmt)); tWNGUITrans = ViewGUITrans.Update(tWNGUITrans); } // Manually Saving as base code will not call base graph persis. ViewGUITrans.Cache.Persist(PXDBOperation.Insert); ViewGUITrans.Cache.Persist(PXDBOperation.Update); ts.Complete(Base); } } } // Triggering after save events. ViewGUITrans.Cache.Persisted(false); }