public virtual void ReleaseAdjustment() { if (Adjustments.Any()) { INDocumentRelease.ReleaseDoc(Adjustments, false); } }
public virtual void ReleaseAdjustment() { if (je.adjustment.Current != null) { List <INRegister> adjList = new List <INRegister>(); adjList.Add(je.adjustment.Current); INDocumentRelease.ReleaseDoc(adjList, false); } }
public virtual IEnumerable Release(PXAdapter adapter) { PXCache cache = issue.Cache; List <INRegister> list = new List <INRegister>(); foreach (INRegister indoc in adapter.Get <INRegister>()) { if (indoc.Hold == false && indoc.Released == false) { cache.Update(indoc); list.Add(indoc); } } if (list.Count == 0) { throw new PXException(Messages.Document_Status_Invalid); } Save.Press(); PXLongOperation.StartOperation(this, delegate() { INDocumentRelease.ReleaseDoc(list, false); }); return(list); }
public virtual void ReleaseLCTrans(IEnumerable <LandedCostTran> aTranSet, DocumentList <INRegister> aINCreated, DocumentList <APInvoice> aAPCreated) { Dictionary <int, APInvoiceEntry> apGraphs = new Dictionary <int, APInvoiceEntry>(); Dictionary <int, INAdjustmentEntry> inGraphs = new Dictionary <int, INAdjustmentEntry>(); Dictionary <int, int> combinations = new Dictionary <int, int>(); List <APRegister> forReleaseAP = new List <APRegister>(); List <INRegister> forReleaseIN = new List <INRegister>(); DocumentList <APInvoice> apDocuments = new DocumentList <APInvoice>(this); POSetup poSetupR = this.poSetup.Select(); bool autoReleaseIN = poSetupR.AutoReleaseLCIN.Value; bool autoReleaseAP = poSetupR.AutoReleaseAP.Value; bool noApplicableItems = false; bool noApplicableTransfers = false; foreach (LandedCostTran iTran in aTranSet) { LandedCostCode lcCode = PXSelect <LandedCostCode, Where <LandedCostCode.landedCostCodeID, Equal <Required <LandedCostCode.landedCostCodeID> > > > .Select(this, iTran.LandedCostCodeID); if ((string.IsNullOrEmpty(iTran.APDocType) || string.IsNullOrEmpty(iTran.APRefNbr)) && iTran.PostponeAP == false) { APInvoiceEntry apGraph = null; foreach (KeyValuePair <int, APInvoiceEntry> iGraph in apGraphs) { APInvoice apDoc = iGraph.Value.Document.Current; string terms = String.IsNullOrEmpty(iTran.TermsID) ? lcCode.TermsID : iTran.TermsID; if (apDoc.VendorID == iTran.VendorID && apDoc.VendorLocationID == iTran.VendorLocationID && apDoc.InvoiceNbr == iTran.InvoiceNbr && apDoc.CuryID == iTran.CuryID && apDoc.DocDate == iTran.InvoiceDate && apDoc.TermsID == terms && (apDoc.DocType == AP.APDocType.Invoice && iTran.CuryLCAmount > Decimal.Zero)) { combinations.Add(iTran.LCTranID.Value, iGraph.Key); apGraph = iGraph.Value; } } if (apGraph == null) { apGraph = PXGraph.CreateInstance <APInvoiceEntry>(); if (autoReleaseAP) { apGraph.APSetup.Current.RequireControlTotal = false; apGraph.APSetup.Current.RequireControlTaxTotal = false; apGraph.APSetup.Current.HoldEntry = false; } apGraphs[iTran.LCTranID.Value] = apGraph; } apGraph.InvoiceLandedCost(iTran, null, false); apDocuments.Add(apGraph.Document.Current); } if (lcCode.AllocationMethod != LandedCostAllocationMethod.None) { List <POReceiptLine> receiptLines = new List <POReceiptLine>(); List <LandedCostTranSplit> lcTranSplits = new List <LandedCostTranSplit>(); GetReceiptLinesToAllocate(receiptLines, lcTranSplits, iTran); var lch = new LandedCostHelper(this, false); List <LandedCostHelper.POReceiptLineAdjustment> result = lch.AllocateLCOverRCTLines(receiptLines, lcCode, iTran, lcTranSplits); if (result.Count > 0) { if (result.Count == 1 && !result[0].Item1.InventoryID.HasValue) { noApplicableTransfers = !lch.HasApplicableTransfers; noApplicableItems = true; //Skip Cost adjustment creation; } else { INAdjustmentEntry inGraph = PXGraph.CreateInstance <INAdjustmentEntry>(); if (autoReleaseIN) { inGraph.insetup.Current.RequireControlTotal = false; inGraph.insetup.Current.HoldEntry = false; } CreateCostAjustment(inGraph, lcCode, iTran, result); inGraphs[iTran.LCTranID.Value] = inGraph; } } } } using (PXConnectionScope cs = new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { foreach (LandedCostTran iTran in aTranSet) { bool needUpdate = false; LandedCostTran tran = this.landedCostTrans.Select(iTran.LCTranID); if (apGraphs.ContainsKey(tran.LCTranID.Value)) { APInvoiceEntry apGraph = apGraphs[iTran.LCTranID.Value]; apGraph.Save.Press(); tran.APDocType = apGraph.Document.Current.DocType; tran.APRefNbr = apGraph.Document.Current.RefNbr; if (!tran.APCuryInfoID.HasValue) { tran.APCuryInfoID = apGraph.Document.Current.CuryInfoID; } tran.Processed = true; if (apGraph.Document.Current.Hold != true) { forReleaseAP.Add(apGraph.Document.Current); } if (aAPCreated != null) { aAPCreated.Add(apGraph.Document.Current); } needUpdate = true; } else if (combinations.ContainsKey(tran.LCTranID.Value)) { //Its already saved at this point APInvoiceEntry apGraph = apGraphs[combinations[tran.LCTranID.Value]]; tran.APDocType = apGraph.Document.Current.DocType; tran.APRefNbr = apGraph.Document.Current.RefNbr; if (!tran.APCuryInfoID.HasValue) { tran.APCuryInfoID = apGraph.Document.Current.CuryInfoID; } tran.Processed = true; needUpdate = true; } if (inGraphs.ContainsKey(tran.LCTranID.Value)) { INAdjustmentEntry inGraph = inGraphs[iTran.LCTranID.Value]; inGraph.Save.Press(); tran.INDocType = inGraph.adjustment.Current.DocType; tran.INRefNbr = inGraph.adjustment.Current.RefNbr; tran.Processed = true; forReleaseIN.Add(inGraph.adjustment.Current); if (aINCreated != null) { aINCreated.Add(inGraph.adjustment.Current); } needUpdate = true; } if (!needUpdate && tran.PostponeAP == true) { LandedCostCode lcCode = PXSelect <LandedCostCode, Where <LandedCostCode.landedCostCodeID, Equal <Required <LandedCostCode.landedCostCodeID> > > > .Select(this, iTran.LandedCostCodeID); if (lcCode.AllocationMethod == LandedCostAllocationMethod.None) { tran.Processed = true; needUpdate = true; //This combination needs no processing here but must be updated } } if (needUpdate) { LandedCostTran copy = (LandedCostTran)this.landedCostTrans.Cache.CreateCopy(tran); tran = this.landedCostTrans.Update(copy); } } this.Actions.PressSave(); ts.Complete(); } } if (noApplicableTransfers == true) { throw new NoApplicableSourceException(Messages.LandedCostCannotBeDistributed); } if (noApplicableItems == true) { throw new NoApplicableSourceException(Messages.LandedCostAmountRemainderCannotBeDistributedMultyLines); } if (autoReleaseAP) { if (forReleaseAP.Count > 0) { APDocumentRelease.ReleaseDoc(forReleaseAP, true); } } if (autoReleaseIN) { if (forReleaseIN.Count > 0) { INDocumentRelease.ReleaseDoc(forReleaseIN, false); } } }