hails's notebooks

  • Untitled - /hails/amic-calc
    Last edited 10 months ago
    // calculating the agBasePrice const amicAmount = 1; const amicFactor = 1; const amicPrice = 1.1; const agAmount = 40; const amicQuantity = amicAmount / amicFactor; const agBasePrice = (amicQuantity * amicPrice) * agAmount / amicQuantity;  // this should be recaclucated if the agrantisAmount changes via connect/disconnect from article! // calculating amicPrice for line using agBasePrice: // const amicPrice2 = (agBasePrice / amicFactor * amicAmount / agAmount) * amicFactor / amicAmount; // happens in agrantis const agQuantity = 1; const agLineTotal = agQuantity * agBasePrice; // calculate amicPrice for line using agQuantity, agAmount and agLineTotal // const amicLinePrice = ((agLineTotal / (agAmount * agQuantity)) / amicFactor * amicAmount / agAmount) * amicFactor / amicAmount; const amicLinePrice = ((agLineTotal / (agAmount * agQuantity))); const amicLineQuantity = (agAmount * agQuantity) / amicQuantity; const amicTotalLineQuantity = amicLineQuantity * amicQuantity; console.dir({ agBasePrice, agAmount, agQuantity, agLineTotal, amicQuantity, amicLinePrice, amicLineQuantity, amicTotalLineQuantity }) // console.log('amicLinePrice', amicLinePrice) // console.log('amicLineQuantity', amicLineQuantity) // console.log('amicTotalLineQuantity', amicTotalLineQuantity)
  • Untitled - /hails/promise101
    Last edited 5 years ago
    const print = () => Promise.resolve() .then(() => console.log('First pass')) .then(() => console.log('Second pass')) .then(() => console.log('Third pass')) const contents = Array.from(Array(5).keys()) const arrayP = contents.map(print) Promise.all(arrayP)