Requirement: When markup item is adding in NetSuite while creating SO, the markup item is also showing in the website. Since the markup item is not ordered by customer it should be removed from website.
Solution: Need to extend the views,”OrderHistory.Details.View” and “Invoice.Details.View”. Adding code below.
const { filter } = require("underscore");
define(
'JJ.MarkUpItem.MarkUp'
, [
'OrderHistory.Details.View', "underscore", "Invoice.Details.View",
'Backbone.CollectionView', 'Transaction.Line.Views.Cell.Navigable.View',"Utils"
]
, function (
OrderHistoryDetailsView, _, InvoiceDetailsView,
BackboneCollectionView, TransactionLineViewsCellNavigableView,Utils
) {
'use strict';
return {
mountToApp: function mountToApp(container) {
// using the 'Layout' component we add a new child view inside the 'Header' existing view
// (there will be a DOM element with the HTML attribute data-view="Header.Logo")
// more documentation of the Extensibility API in
// https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/index.html
/** @type {LayoutComponent} */
var layout = container.getComponent('Layout');
_.extend(OrderHistoryDetailsView.prototype, {
getNonShippableLines: function () {
var currentlines = this.model.get('lines').where({ linegroup: 'nonshippable' });
var exceptmarkup = _.filter(currentlines, function (model) {
return model.get("type") != "Markup";
})
return exceptmarkup
}
});
_.extend(InvoiceDetailsView.prototype, {
childViews: _.extend(InvoiceDetailsView.prototype.childViews, {
'Items.Collection': function () {
var remvariable = _.filter(this.model.attributes.lines.models, function (model) {
console.log("model invoice", model)
return model.get("type") != "Markup";
})
console.log("remvariable", remvariable)
return new BackboneCollectionView({
collection: remvariable
, childView: TransactionLineViewsCellNavigableView
, viewsPerRow: 1
, childViewOptions: {
navigable: true
, detail1Title: _('Qty:').translate()
, detail1: 'quantity'
, detail2Title: _('Unit price:').translate()
, detail2: 'rate_formatted'
, detail3Title: _('Amount:').translate()
, detail3: 'total_formatted'
}
});
}
}),
getContext: _.wrap(InvoiceDetailsView.prototype.getContext, function (fn) {
var original = fn.apply(this, _.toArray(arguments).slice(1));
console.log("this of context",this)
var stripesubtotal=((this.model.attributes.summary.subtotal)*0.0025).toFixed(2);
var reducedsubtotal=this.model.attributes.summary.subtotal-stripesubtotal; this.model.attributes.summary.subtotal=parseFloat(this.model.attributes.summary.subtotal-stripesubtotal)-parseFloat(reducedsubtotal);
this.model.attributes.summary.subtotal_formatted= Utils.formatCurrency(reducedsubtotal);
return original;
})
});
}
};
});