@vtex/estimate-calculator
Advanced tools
> Small library to calculate and compare SLAs' shippingEstimate
Weekly downloads
Readme
Small library to calculate and compare SLAs' shippingEstimate
$ npm install @vtex/estimate-calculator
const estimateCalculator = require('@vtex/estimate-calculator')
estimateCalculator.getFastestSla([
{ id: 1, shippingEstimate: '50bd' },
{ id: 2, shippingEstimate: '15bd' },
{ id: 3, shippingEstimate: '100bd' },
])
// { id: 2, shippingEstimate: '15bd' }
Returns only the shippingEstimate quantity
Type: String
shippingEstimate of a given SLA
Returns only the shippingEstimate unit
Type: String
shippingEstimate of a given SLA
Returns shippingEstimate converted to seconds
Type: String
shippingEstimate of a given SLA
Returns the SLA that will take the most time (i.e: worst-case scenario in a shippingEstimate context)
Type: Array
List of SLAS
Returns the SLA that will be fastest one (i.e: best-case scenario in a shippingEstimate context)
Type: Array
List of SLAS
Returns the chepeast SLA
Type: Array
List of SLAS
Returns the chepeast SLA for all items
Type: Object
Object that contains all the logistics information of an order
Returns the fastest SLA for all items
Type: Array
Array that contains all the logistics information of each item of the order
Format of the Array:
[
// {
// itemIndex: 0,
// selectedSla: '',
// selectedDeliveryChannel: '',
// addressId: '62e1db5500824a66bcef708d09388a8e',
// slas: [
// {
// id: 'Normal',
// deliveryChannel: 'delivery',
// name: 'Normal',
// deliveryIds: [Object],
// shippingEstimate: '16bd',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 334,
// listPrice: 334,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// {
// id: 'Expressa',
// deliveryChannel: 'delivery',
// name: 'Expressa',
// deliveryIds: [Object],
// shippingEstimate: '1bd',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 6666,
// listPrice: 6666,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// ],
// shipsTo: ['BRA'],
// itemId: '100006784',
// deliveryChannels: [{ id: 'delivery' }, { id: 'pickup-in-point' }],
// },
// {
// itemIndex: 1,
// selectedSla: '',
// selectedDeliveryChannel: '',
// addressId: '62e1db5500824a66bcef708d09388a8e',
// slas: [
// {
// id: 'Normal',
// deliveryChannel: 'delivery',
// name: 'Normal',
// deliveryIds: [
// {
// courierId: '1',
// warehouseId: '1afe1cf',
// dockId: '1b91c3b',
// courierName: 'Courrier e-commerce',
// quantity: 1,
// },
// ],
// shippingEstimate: '16bd',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 333,
// listPrice: 333,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// {
// id: 'Expressa',
// deliveryChannel: 'delivery',
// name: 'Expressa',
// deliveryIds: [Object],
// shippingEstimate: '1bd',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 6667,
// listPrice: 6667,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// ],
// shipsTo: ['BRA'],
// itemId: '100006786',
// deliveryChannels: [{ id: 'delivery' }, { id: 'pickup-in-point' }],
// },
// {
// itemIndex: 2,
// selectedSla: '',
// selectedDeliveryChannel: '',
// addressId: '62e1db5500824a66bcef708d09388a8e',
// slas: [
// {
// id: 'Normal',
// deliveryChannel: 'delivery',
// name: 'Normal',
// deliveryIds: [Object],
// shippingEstimate: '16bd',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 333,
// listPrice: 333,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// {
// id: 'Expressa',
// deliveryChannel: 'delivery',
// name: 'Expressa',
// deliveryIds: [Object],
// shippingEstimate: '1bd',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 6667,
// listPrice: 6667,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// ],
// shipsTo: ['BRA'],
// itemId: '100006785',
// deliveryChannels: [{ id: 'delivery' }, { id: 'pickup-in-point' }],
// },
// ]
estimateCalculator.getShippingEstimateQuantity('10m')
// 10
estimateCalculator.getShippingEstimateUnit('10m')
// m
estimateCalculator.getShippingEstimateQuantityInSeconds('10m')
// 600
estimateCalculator.getLatestSla([
{ id: 1, shippingEstimate: '50h' },
{ id: 2, shippingEstimate: '15h' },
{ id: 3, shippingEstimate: '100h' },
])
// { id: 3, shippingEstimate: '100h' }
estimateCalculator.getFastestSla([
{ id: 1, shippingEstimate: '50h' },
{ id: 2, shippingEstimate: '15h' },
{ id: 3, shippingEstimate: '100h' },
])
// { id: 2, shippingEstimate: '15h' }
estimateCalculator.getCheapestSla([
{ id: 1, price: 50 },
{ id: 2, price: 15 },
{ id: 3, price: 100 },
])
// { id: 2, price: 15 }
estimateCalculator.selectCheapestSlaForAllItems(logistiscsInfo)
// [
// {
// selectedSla: '',
// selectedDeliveryChannel: '',
// itemIndex: 0,
// addressId: '62e1db5500824a66bcef708d09388a8e',
// slas: [
// {
// id: 'Normal',
// deliveryChannel: 'delivery',
// name: 'Normal',
// deliveryIds: [[Object]],
// shippingEstimate: '16bd',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 334,
// listPrice: 334,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// {
// id: 'Expressa',
// deliveryChannel: 'delivery',
// name: 'Expressa',
// deliveryIds: [[Object]],
// shippingEstimate: '2d',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 6666,
// listPrice: 6666,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// ],
// shipsTo: ['BRA'],
// itemId: '100006784',
// deliveryChannels: [[Object], [Object]],
// },
// {
// selectedSla: '',
// selectedDeliveryChannel: '',
// itemIndex: 1,
// addressId: '62e1db5500824a66bcef708d09388a8e',
// slas: [
// {
// id: 'Normal',
// deliveryChannel: 'delivery',
// name: 'Normal',
// deliveryIds: [[Object]],
// shippingEstimate: '16bd',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 333,
// listPrice: 333,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// {
// id: 'Expressa',
// deliveryChannel: 'delivery',
// name: 'Expressa',
// deliveryIds: [[Object]],
// shippingEstimate: '2d',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 6667,
// listPrice: 6667,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// ],
// shipsTo: ['BRA'],
// itemId: '100006786',
// deliveryChannels: [{ id: 'delivery' }, { id: 'pickup-in-point' }],
// },
// {
// selectedSla: '',
// selectedDeliveryChannel: '',
// itemIndex: 2,
// addressId: '62e1db5500824a66bcef708d09388a8e',
// slas: [
// {
// id: 'Normal',
// deliveryChannel: 'delivery',
// name: 'Normal',
// deliveryIds: [[Object]],
// shippingEstimate: '16bd',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 333,
// listPrice: 333,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// {
// id: 'Expressa',
// deliveryChannel: 'delivery',
// name: 'Expressa',
// deliveryIds: [[Object]],
// shippingEstimate: '2d',
// shippingEstimateDate: null,
// lockTTL: null,
// availableDeliveryWindows: [],
// deliveryWindow: null,
// price: 6667,
// listPrice: 6667,
// tax: 0,
// pickupStoreInfo: {
// isPickupStore: false,
// friendlyName: null,
// address: null,
// additionalInfo: null,
// dockId: null,
// },
// },
// ],
// shipsTo: ['BRA'],
// itemId: '100006785',
// deliveryChannels: [{ id: 'delivery' }, { id: 'pickup-in-point' }],
// },
// ]
estimateShipping.selectFastestSlaForAllItems(logisticsInfo)
FAQs
> Small library to calculate and compare SLAs' shippingEstimate
The npm package @vtex/estimate-calculator receives a total of 598 weekly downloads. As such, @vtex/estimate-calculator popularity was classified as not popular.
We found that @vtex/estimate-calculator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 27 open source maintainers collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.