Step 1: Custom Fields with Dropdowns for Discount Method
NetSuite allows you to create custom fields that can be used for flexible user input. These fields will control the business logic you implement via scripting.
Custom Fields:
- Discount Calculation Method (Dropdown):
- Add a dropdown field to the Purchase Order and Invoice records, which will allow users to select between the two discount calculation methods:
- Discount Before Tax
- Discount After Tax
- This field will be a transaction-level field, allowing the user to select the discount method when creating or editing a Purchase Order or Invoice.
- Implementation Consideration:
- This dropdown will be added to the Main Header of the transaction, so it applies to the entire transaction.
- Users should select this option when they are creating or editing the PO/Invoice.
Step 2: Use NetSuite’s Standard Discounts (Inline Editing & Discount Fields)
NetSuite provides standard fields for applying item-level discounts on both the PO and Invoice. These fields are called Item Discount or Line Level Discount and are typically calculated before tax by default.
Handling Discount Before Tax (Standard Method):
- NetSuite Default Flow: When the user applies a discount at the line level, NetSuite automatically deducts this from the item amount before calculating the tax.
Handling Discount After Tax (Custom Implementation):
- For applying discounts after tax, we will need to implement custom logic using SuiteScript, as this is not supported natively.
- Note: This might need further technical analysis.
Step 3: SuiteScript Customization for Business Logic [Further technical analysis required]
We’ll use User Event Script or Before Submit User Event to control how the discount and tax are applied based on the user’s selection of the discount method in the dropdown.
Script Logic for Discount Calculation:
- User Event Script: Write a User Event Script that listens for changes when the user submits or edits a Purchase Order or Invoice.
- Before Submit: This script will check the value of the Discount Calculation Method dropdown (the custom field) and apply the correct discount logic.
For Discount Before Tax (Standard Flow):
- Step 1: Apply the discount on the item price.
- Step 2: Recalculate the tax based on the discounted price.
- Example:
- Item price = ₹1000
- Discount = ₹200 (Before Tax)
- Net Price = ₹800
- Tax = ₹144 (18% of ₹800)
- Total = ₹944
For Discount After Tax (Custom Flow):
- Step 1: Calculate tax on the original price (before discount).
- Step 2: Apply the discount on the total amount (item + tax).
- Example:
- Item price = ₹1000
- Tax = ₹180 (18% of ₹1000)
- Subtotal = ₹1180
- Discount = ₹200 (After Tax)
- Total = ₹980
Important Considerations:
- The discount and tax amounts must be handled correctly using scripting to avoid any inconsistencies.
- Ensure that the correct fields on the PO/Invoice are updated with the recalculated totals.
Step 4: Handling Tax Calculation
NetSuite provides robust tax handling features, but your custom script will need to consider the different calculation logic based on the discount method selected.
- For Discount Before Tax:
- Ensure that the discount is applied before tax calculation, meaning that the tax will be calculated on the discounted item price.
- For Discount After Tax:
- The tax should be calculated on the original item price (before discount) and then the discount applied to the total amount (item price + tax).
To achieve this, NetSuite’s native tax engine can be used for automatic tax calculation once the script modifies the amounts according to the discount method.
Step 5: Testing the Solution
Testing is crucial when dealing with financial calculations, and this custom implementation will need extensive validation.
Test Scenarios:
- Discount Before Tax:
- Apply a discount before tax and verify that the tax is calculated on the discounted item price.
- Check that the total matches the expected value (item + tax – discount).
- Discount After Tax:
- Apply a discount after tax and verify that the tax is calculated on the full item price, and then the discount is applied to the final total.
- Ensure that the correct total is displayed after applying the discount and tax.
- Edge Cases:
- Apply discounts to items with multiple tax rates.
- Test for large transactions with many line items.
- Verify how the solution handles returns or credit memos (if applicable).