Good day,
I have a custom field to indicate if a voided payment is type non-sufficient fund, if it is, when I press release in the voided payment, I have to create a debit memo and redirect from the payment and applications screen to the invoice and memos screen.
The problem is that if I try to redirect the screen, the voided payment does not release and does not save either, because the RedirectException interrups the process.
Do you have any idea how can I make the transition from one screen to another having the voided payment released?
invMemo.Actions.PressSave();
throw new PXRedirectRequiredException(invMemo, true, "Invoice");
}
return Base.release.Press(adapter);
public virtual IEnumerable Release(PXAdapter adapter)
{
ARPayment row = Base.Document.Current;
ARRegisterExt rowExt = PXCache<ARRegister>.GetExtension<ARRegisterExt>(row);
var invMemo = PXGraph.CreateInstance<ARInvoiceEntry>();
//validating if voided payment should be Non-Sufficient fund.
if (rowExt.UsrNSF == true && Base.Document.Ask("Non-Sufficient Funds is checked, do you really want to release voided payment?",
MessageButtons.YesNo) != WebDialogResult.Yes)
{
return adapter.Get();
}
else
{
//If document type is a voided payment and NSF is checked create the Debit Memo.
if (row.DocType == ARDocType.VoidPayment && rowExt.UsrNSF == true)
{
var arPreferences = PXGraph.CreateInstance<ARSetupMaint>();
ARInvoice invoiceMemo = new ARInvoice();
ARTran tran = new ARTran();
ARSetup setup = PXSelect<ARSetup>.Select(Base);
invoiceMemo.DocType = ARDocType.DebitMemo;
invoiceMemo.CustomerID = row.CustomerID;
invoiceMemo.DocDate = row.DocDate;
invoiceMemo = invMemo.Document.Insert(invoiceMemo);
if (setup != null)
{
ARSetupExt setupExt = setup.GetExtension<ARSetupExt>();
if (setupExt != null)
{
string inventoryCD = setupExt.UsrNstk;
InventoryItem item = PXSelect<InventoryItem, Where<InventoryItem.inventoryCD, Equal<Required<InventoryItem.inventoryCD>>>>.Select(Base, inventoryCD);
InventoryItemCurySettings itemCury = PXSelect<InventoryItemCurySettings, Where<InventoryItemCurySettings.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, item.InventoryID);
if (item != null && itemCury != null)
{
tran.InventoryID = item.InventoryID;
tran.Qty = 1;
tran.CuryUnitPrice = itemCury.BasePrice;
tran = invMemo.Transactions.Insert(tran);
}
}
}
invMemo.Actions.PressSave();
throw new PXRedirectRequiredException(invMemo, true, "Invoice");
}
return Base.release.Press(adapter);
}
}