Package Exports
- js-product-pricing-calculator
- js-product-pricing-calculator/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-product-pricing-calculator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
jeevika-shah-price-lib
NPM module to calculate pricing /**
- Calculates the final pricing for a given product, considering gold, diamond, labour, miscellaneous costs,
- tax, and payment gateway fees.
- @param product - The product for which the price is being calculated.
- @param CentralPricing - The central pricing information containing gold and diamond prices.
- @param productSize - The selected size variant of the product.
- @returns An object containing the product ID and the computed final price. */
Example usage:
import { calculatePricing, Product, CentralPricing, ProductSize } from 'jeevika-shah-price-lib';
const product: Product = {
_id: 'prod123',
name: 'Gold Ring',
isDeleted: false,
description: '18K gold ring with diamonds',
category: 'Rings',
images: [],
sizes: [
{ displayName: '6', weightOfMetal: 1.2, _id: 'size6' },
{ displayName: '7', weightOfMetal: 1.3, _id: 'size7' }
],
karatOfGold: 18,
weightOfGold: 2,
karatOfDiamond: 0.5,
costOfDiamond: 1000,
costOfLabour: 500,
miscellaneousCost: 100,
isCentralisedDiamond: true,
isNaturalDiamond: true,
isLabDiamond: false,
isActive: true,
isLandingPageProduct: false,
createdAt: '2024-06-01T00:00:00Z',
updatedAt: '2024-06-01T00:00:00Z',
__v: 0
};
const centralPricing: CentralPricing = {
goldPricePerGram: 6000,
naturalDiamondPricePerCarat: 50000,
labDiamondPricePerCarat: 20000
};
const productSize: ProductSize = product.sizes[0];
const result = calculatePricing(product, centralPricing, productSize);
console.log(result);
// Output: { productId: 'prod123', finalPrice: <calculated_value> }