In website recent invoices list was showing client want to show recent all transactions there.
For that created an extension and updated the model to change the filter.
suitescript file: JJ.OverviewHome.OverviewHome.Model.js:
define('JJ.OverviewHome.OverviewHome.Model', ['underscore', 'Invoice.Model', 'Utils'], function(_, InvoiceModel, Utils) {
'use strict';
_.extend(InvoiceModel, {
setExtraListFilters: function() {
const status = this.data;
if (status) {
var value = null;
switch (status.status) {
case 'open':
value = 'CustInvc:A';
break;
case 'paid':
value = 'CustInvc:B';
break;
}
if (value) {
this.filters.status_operator = 'and';
this.filters.status = ['status', 'anyof', value];
}
}
if (!status.status) {
try {
var self = this;
//changing filter to get all transaction list in myaccount overview
this.filters.types_operator = 'and';
this.filters.types = ["type", "anyof", "CustCred", "CustInvc", "ItemShip", "CustPymt", "Deposit", "DepAppl", "CashSale"];
} catch (e) {
console.error("this e", e);
}
}
}
});
});
javascript : JJ.OverviewHome.OverviewHome.js:
define('JJ.OverviewHome.OverviewHome', ['Overview.Home.Standalone.View', 'Configuration', 'Handlebars', 'Backbone.CollectionView', 'RecordViews.View', 'underscore', 'Utils', 'Backbone'], function(OverviewHomeStandaloneView, Configuration, Handlebars, BackboneCollectionView, RecordViewsView, _, Utils, Backbone) {
'use strict';
return {
mountToApp: function mountToApp(container) {
var layout = container.getComponent('Layout');
if (layout) {
//To show recent 3 transaction list in myaccount overview page.
_.extend(OverviewHomeStandaloneView.prototype, {
childViews: _.extend(OverviewHomeStandaloneView.prototype.childViews, {
'Invoices.Results': function() {
try {
const self = this;
let selectedColumns = [];
if (!Configuration.get().transactionListColumns.enableInvoice) {
selectedColumns.push({
label: 'Date:',
type: 'date',
name: 'date',
id: 'trandate'
});
selectedColumns.push({
label: 'Amount:',
type: 'currency',
name: 'amount',
id: 'amount_formatted'
});
selectedColumns.push({
label: 'Status:',
type: 'status',
name: 'name',
id: 'status'
});
} else {
selectedColumns = Configuration.get().transactionListColumns.invoiceOpen;
}
const records_collection = new Backbone.Collection(this.collection.map(function(invoice) {
const recordtype = invoice.get('recordtype');
var type;
if (recordtype === 'creditmemo') {
type = Utils.translate('Credit Memo');
} else if (recordtype === 'customerpayment') {
type = Utils.translate('Payment');
} else if (recordtype === 'customerdeposit') {
type = Utils.translate('Deposit');
} else if (recordtype === 'depositapplication') {
type = Utils.translate('Deposit Application');
} else if (recordtype === 'invoice') {
type = Utils.translate('Invoice');
} else if (recordtype === 'cashsale') {
type = Utils.translate('Cash Receipt');
}
invoice.status.name = invoice.get('status').internalid === 'open' ? new Handlebars.SafeString(Utils.translate('<span class="invoice-pending">Pending</span>')) : new Handlebars.SafeString(Utils.translate('<span class="invoice-paid">$(0)</span>', invoice.get('status').internalid));
return new Backbone.Model({
touchpoint: 'customercenter',
title: new Handlebars.SafeString(Utils.translate('$(0) #<span class="tranid">$(1)</span>', type, invoice.get('tranid'))),
detailsURL: `transactionhistory/${invoice.get('recordtype')}/${invoice.get('internalid')}`,
id: invoice.get('internalid'),
internalid: invoice.get('internalid'),
status: invoice.get('status'),
columns: self._buildColumns(selectedColumns, invoice)
});
}));
return new BackboneCollectionView({
childView: RecordViewsView,
collection: records_collection,
viewsPerRow: 1,
childViewOptions: {
referrer: ''
}
});
} catch (e) {
console.log("overview error", e)
}
}
})
});
}
}
};
});