@stll/money 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -110,6 +110,12 @@ export type ProrateHourlyCentsInput = {
110
110
  hourlyRateCents: CentsAmount;
111
111
  };
112
112
  export declare const prorateHourlyCents: ({ billedMinutes, hourlyRateCents }: ProrateHourlyCentsInput) => CentsAmount;
113
+ type TimeEntryAmountInput = {
114
+ billedMinutes: number;
115
+ rateAtEntry: CentsAmount;
116
+ noCharge: boolean;
117
+ };
118
+ export declare const timeEntryAmount: (entry: TimeEntryAmountInput) => CentsAmount;
113
119
  export type ApplyMarkupCentsInput = {
114
120
  amountCents: CentsAmount;
115
121
  markupPercent: number;
package/dist/index.js CHANGED
@@ -212,6 +212,10 @@ const prorateHourlyCents = ({ billedMinutes, hourlyRateCents }) => {
212
212
  const product = BigInt(billedMinutes) * BigInt(hourlyRateCents);
213
213
  return cents(Number((product + 30n) / 60n));
214
214
  };
215
+ const timeEntryAmount = (entry) => entry.noCharge ? cents(0) : prorateHourlyCents({
216
+ billedMinutes: entry.billedMinutes,
217
+ hourlyRateCents: entry.rateAtEntry
218
+ });
215
219
  const applyMarkupCents = ({ amountCents, markupPercent }) => {
216
220
  assertNonNegativeInteger("amountCents", amountCents);
217
221
  assertNonNegativeInteger("markupPercent", markupPercent);
@@ -277,4 +281,4 @@ var MoneyTotals = class {
277
281
  }
278
282
  };
279
283
  //#endregion
280
- export { MoneyTotals, addCents, applyMarkupCents, cents, currencyCents, currencyMinorUnitDigits, formatMoneyCents, prorateHourlyCents, toMajorUnits, toMinorUnits, tryToMinorUnits, unsafeCents };
284
+ export { MoneyTotals, addCents, applyMarkupCents, cents, currencyCents, currencyMinorUnitDigits, formatMoneyCents, prorateHourlyCents, timeEntryAmount, toMajorUnits, toMinorUnits, tryToMinorUnits, unsafeCents };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/money",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "Branded minor-unit monetary amounts and currency-safe billing arithmetic.",
5
5
  "keywords": [
6
6
  "billing",