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

18 lines
462 B
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
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
};
}