How to use the entities/Currency.centsToString function in entities

To help you get started, we’ve selected a few entities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ayastreb / money-tracker / src / entities / Account.ts View on Github external
(acc: BalanceAsInputStringT, code: string) => {
        acc[code] = Currency.centsToString(account.balance[code], code, false);
        return acc;
      },
      {}
github ayastreb / money-tracker / src / entities / Transaction.ts View on Github external
export function stateToForm(state: TransactionStateT): TransactionFormT {
  return {
    ...state,
    amount: Currency.centsToString(
      state.amount * (state.kind === Expense ? -1 : 1),
      state.currency,
      false
    ),
    linkedAmount:
      state.kind === Transfer && state.linkedAmount && state.linkedCurrency
        ? Currency.centsToString(
            state.linkedAmount,
            state.linkedCurrency,
            false
          )
        : undefined,
    note: state.note || '',
    tags: {
      [Expense]: [],
      [Income]: [],
github ayastreb / money-tracker / src / entities / Transaction.ts View on Github external
export function stateToForm(state: TransactionStateT): TransactionFormT {
  return {
    ...state,
    amount: Currency.centsToString(
      state.amount * (state.kind === Expense ? -1 : 1),
      state.currency,
      false
    ),
    linkedAmount:
      state.kind === Transfer && state.linkedAmount && state.linkedCurrency
        ? Currency.centsToString(
            state.linkedAmount,
            state.linkedCurrency,
            false
          )
        : undefined,
    note: state.note || '',
    tags: {
      [Expense]: [],
      [Income]: [],
      [state.kind]: state.tags || []
    },
    date: format(toLocalTimestamp(state.date), 'YYYY-MM-DD')
  };
}