saleor-dashboard/src/components/Money/index.ts

18 lines
473 B
TypeScript
Raw Normal View History

2019-10-30 14:34:24 +00:00
import { IMoney } from "./Money";
2019-06-19 14:40:52 +00:00
export { default } from "./Money";
export * from "./Money";
2019-10-30 14:34:24 +00:00
export function addMoney(init: IMoney, ...args: IMoney[]): IMoney {
2019-06-19 14:40:52 +00:00
return {
amount: args.reduce((acc, curr) => acc + curr.amount, init.amount),
currency: init.currency
};
}
2019-10-30 14:34:24 +00:00
export function subtractMoney(init: IMoney, ...args: IMoney[]): IMoney {
2019-06-19 14:40:52 +00:00
return {
amount: args.reduce((acc, curr) => acc - curr.amount, init.amount),
currency: init.currency
};
}