I have a custom view that will list customer orders and carry out transactions in one view.
Standard POS has the customer orders in Find and Manage orders view (OrderSearchView) and the carry out transactions in Store transactions (ShowJournalView). On the customer details view there is an All Orders just above the Order History panel for the specific customer. The ideal would have been to use this all orders which in the backend also calls ShowJournalView. However there is no filters on this. Looking in HQ where it retrieves the data, I can see why. It uses 3 different selects and then combine it.
We have the the feature Unified return processing experience in POS turned on which means we should be able to return both store transactions and customer orders on .Return Transaction.
My custom view has to work similarly to the "All orders" but have filters. Everything works find. I added the return button. Looking in Pos.viewModels.js on how the return transaction is called, I see if it is a customer order it calls "SalesInvoicesView". I am calling it and it works the same as when one will do a return from the All orders or the Find and Manage Orders screen.
For a sales transaction I use the same logic that I could find in Pos.viewModels.js and that is that it passes in the sales order as a parameter and then calls the operation for Return Transaction. However the Return Operation is still calling SalesInvoiceView instead of directly the Returnable Products view. The only reason I can think of is that the parameter it receives is the sales order and maybe it wants the RetailTransactionTable instead? Because the Retun transaction operation calls the salesInvoiceView, it behaves the same as for a customer order in that it prompts for a reason code.
How can I change my code that it calls the returnable products view same as the return button on the Store transactions?
Below is the code on how to call the return transactions as I found it in Pos.ViewModels.js, but somehow return operation is calling SalesInvoiceview:
var options = {
salesOrder: salesOrder
};
return TMC.Commerce.Operations.OperationsManager.instance.runOperation(TMC.Commerce.Operations.RetailOperation.ReturnTransaction, options)
.map(function (result) {
if (result && !result.canceled) {
this._context.navigator.navigate("legacy-core", "CartView");
}
}).always(function () {
this.isPageModeBusy(false);
this._customViewControllerBaseState.isProcessing = false;
}).getPromise();
If I change the code to not pass in the sales order but only a receipt number, then it calls directly the Return transaction but it opens the dialog called "Search orders" which means it doesn't respect the receiptId I pass in as a parameter.
var options = {
receiptNumber: vReceipt
};
return TMC.Commerce.Operations.OperationsManager.instance.runOperation(TMC.Commerce.Operations.RetailOperation.ReturnTransaction, options)
.map(function (result) {
if (result && !result.canceled) {
this._context.navigator.navigate("legacy-core", "CartView");
}
}).always(function () {
this.isPageModeBusy(false);
this._customViewControllerBaseState.isProcessing = false;
}).getPromise();
If I navigate to ReturnTransactionView (found the name when looking at the developer tools), it also opened the dialog even when I pass in the salesOrder.
So, do I re-find the sales order using the transactionID, incase that includes information in the backend that I don't know about or how do I get it to open the return transaction the way it opens when using "All orders" on customer detail view > Order history for a carry out transaction?
Any help is much appreciated.