saleor-dashboard/src/components/Money/index.ts
2019-06-19 16:40:52 +02:00

17 lines
462 B
TypeScript

import Money from "./Money";
export { default } from "./Money";
export * from "./Money";
export function addMoney(init: Money, ...args: Money[]): Money {
return {
amount: args.reduce((acc, curr) => acc + curr.amount, init.amount),
currency: init.currency
};
}
export function subtractMoney(init: Money, ...args: Money[]): Money {
return {
amount: args.reduce((acc, curr) => acc - curr.amount, init.amount),
currency: init.currency
};
}