Real-Time Item Category-Based Budget Calculation in Header of the GoodEarth Website

Requirement

To improve the accuracy and visibility of budget details on the GoodEarth website, this task involves two primary objectives:

  1. Real-Time Data Update: Implement backend functionality to enable real-time updates for item group balances. This ensures users see current, accurate budget information as it changes.

Solution Overview

The solution consists of the following components:

  1. Backend Functionality:
  • Implement logic for real-time retrieval and updates of item group balances.
  • Use SuiteScript to fetch and pass budget details to the frontend, leveraging saved searches and logging error messages for any missing information.
  1. Frontend Integration :
  • Modify the Header.MiniCart.View.Site.js file to display the remaining budget for each item category.
  • Update header_mini_cart.tpl template to render budget data dynamically.
  • There are two custom records in the NetSuite account for handling the Category and Budget associated with each customers

GED Category:Category Custom Record

Purpose: This record stores a list of items assigned to each category, along with the customers who have access to them.

  • The parent customer selects the CLUB NAME (PARENT CUSTOMER) field to assign sub-customers to the category record automatically. This identifies the customer who requires the specific category.
  • The Items Tab in the GED Item Category record allows item selection for each category.
  • Customer Record Integration: The client can view or update the assigned categories from the customer record.

GED Budget:Budget Custom Record

  • Purpose: This record tracks the budget’s name, cycle, amount, remaining balance, and associated customer.
  • Customer Record Integration: Budget details are accessible within the customer record for straightforward management.

Steps to Implement Solution

1. Real-Time Balance Integration

  • Data Retrieval and Error Handling:
  • Retrieve the logged-in user’s budget and item categories using a saved search on custom records.

var user = nlapiGetUser();

var customrecord_jj_ged_item_categroySearch = nlapiSearchRecord("customrecord_jj_ged_item_categroy", null,

[

["custrecord12.custrecord_jj_ged_budget_customer", "anyof", user]

],

[

new nlobjSearchColumn("name"),

new nlobjSearchColumn("scriptid"),

new nlobjSearchColumn("custrecord12", "CUSTRECORD12", null),

new nlobjSearchColumn("custrecord_jj_ged_budget_customer", "CUSTRECORD12", null),

new nlobjSearchColumn("custrecord_jj_ged_budget_amount", "CUSTRECORD12", null),

new nlobjSearchColumn("custrecord_jj_ged_budget_balance", "CUSTRECORD12", null),

new nlobjSearchColumn("internalid", "CUSTRECORD12", null),

new nlobjSearchColumn("name", "CUSTRECORD12", null)

]

);

  • Pass the results to the frontend via the ProfileModel.
  • Implement error handling to log missing category names or budget details.
  • Backend Script Integration:
  • Use a SuiteScript search (customrecord_jj_ged_item_categroySearch) to fetch budget amount and balance for each category assigned to the user.
  • Filter the results by customer ID and budget owner, joining with the necessary custom records.
  • Profile Model Update:
  • Assign all retrieved budget details to the DelegatePurchasing.Profile.Model.js file for real-time access by the frontend.

2. Frontend and UI Integration

  • Header Updates:
  • Modify Header.MiniCart.View.Site.js to dynamically calculate and display budget balances for items in the cart.
  • Displayed the real-time budget detail based on the category and the items in the cart that belong to the category
  • Deployment
  • The files updated for implementing the customization are added below:

DelegatePurchasing.Profile.Model.js

Header.MiniCart.View.Site.js

header_mini_cart.tpl

Leave a comment

Your email address will not be published. Required fields are marked *