當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript NumberFormatter.formatMoney方法代碼示例

本文整理匯總了TypeScript中utils/numberFormatter.NumberFormatter.formatMoney方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript NumberFormatter.formatMoney方法的具體用法?TypeScript NumberFormatter.formatMoney怎麽用?TypeScript NumberFormatter.formatMoney使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utils/numberFormatter.NumberFormatter的用法示例。


在下文中一共展示了NumberFormatter.formatMoney方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: prepareDefendantOffer

export function prepareDefendantOffer (claim: Claim, draft: DraftClaimantResponse): Offer {
  const response: FullAdmissionResponse | PartialAdmissionResponse = claim.response as FullAdmissionResponse | PartialAdmissionResponse

  const amount = NumberFormatter.formatMoney(AmountHelper.calculateTotalAmount(claim, draft))
  if (response.paymentIntention.paymentDate) {
    const completionDate: Moment = response.paymentIntention.paymentDate
    const content: string = `${response.defendant.name} will pay ${amount}, no later than ${MomentFormatter.formatLongDate(completionDate)}`
    return new Offer(content, completionDate, response.paymentIntention)
  } else if (response.paymentIntention.repaymentPlan) {
    const paymentPlan: PaymentPlan = PaymentPlanHelper.createPaymentPlanFromClaim(claim, draft)
    const instalmentAmount: string = NumberFormatter.formatMoney(paymentPlan.instalmentAmount)
    const paymentSchedule: string = PaymentScheduleTypeViewFilter.render(response.paymentIntention.repaymentPlan.paymentSchedule).toLowerCase()
    const firstPaymentDate: string = MomentFormatter.formatLongDate(paymentPlan.startDate)
    const completionDate: Moment = paymentPlan.calculateLastPaymentDate()
    const content: string = `${response.defendant.name} will repay ${amount} in instalments of ${instalmentAmount} ${paymentSchedule}. The first instalment will be paid by ${firstPaymentDate}.`
    return new Offer(content, completionDate, response.paymentIntention)
  }
  throw new Error('Invalid paymentIntention')
}
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:19,代碼來源:settlementHelper.ts

示例2: renderView

    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<HowMuchOwed> = req.body
      const claim: Claim = res.locals.claim
      const user: User = res.locals.user

      if (form.model.amount > claim.totalAmountTillToday) {
        let totalAmount: string = NumberFormatter.formatMoney(claim.totalAmountTillToday)
        let error = new ValidationError()
        error.property = 'amount'
        error.constraints = { amount: 'Enter a valid amount between £1 and ' + totalAmount }
        form.errors.push(new FormValidationError(error))
      }

      if (form.hasErrors()) {
        await renderView(form, res, next)
      } else {
        const draft: Draft<ResponseDraft> = res.locals.responseDraft

        draft.document.howMuchOwed = form.model
        await new DraftService().save(draft, user.bearerToken)

        res.redirect(Paths.timelinePage.evaluateUri({ externalId: claim.externalId }))
      }
    })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:24,代碼來源:how-much-owed.ts

示例3: it

 it('format numeric value to money', () => {
   expect(NumberFormatter.formatMoney(10.01)).to.eq('£10.01')
 })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:3,代碼來源:numberFormatter.ts

示例4:

    ...baseDefenceData,
    amount: 30
  },
  ...respondedAt
}

const testData = [
  {
    status: 'Full defence - defendant paid what he believe',
    claim: fullDefenceClaim,
    claimOverride: {
      response: { ...defenceWithAmountClaimedAlreadyPaidData }
    },
    claimantAssertions: [
      'The defendant’s response',
      fullDefenceClaim.claim.defendants[0].name + ` says they paid you ${NumberFormatter.formatMoney(defenceWithAmountClaimedAlreadyPaidData.paymentDeclaration.paidAmount)} on `,
      'You can accept or reject this response.',
      'View and respond'
    ],
    defendantAssertions: [
      'Your response to the claim',
      'We’ve emailed ' + fullDefenceClaim.claim.claimants[0].name + ' telling them when and how you said you paid the claim.',
      'Download your response'
    ]
  },
  {

    status: 'Full defence - defendant paid what he believe - claimant rejected defendant response',
    claim: fullDefenceClaim,
    claimOverride: {
      response: { ...defenceWithAmountClaimedAlreadyPaidData },
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:31,代碼來源:full-defence.ts

示例5: buildRespondToClaimSection


//.........這裏部分代碼省略.........
            )
          )
        }

        if (draft.isResponseFullyAdmittedWithInstalments()) {
          tasks.push(
            new TaskListItem(
              'Your repayment plan',
              FullAdmissionPaths.paymentPlanPage.evaluateUri({ externalId: externalId }),
              YourRepaymentPlanTask.isCompleted(draft.fullAdmission.paymentIntention.paymentPlan)
            )
          )
        }
      }

      const partiallyAdmitted = draft.isResponsePartiallyAdmitted()
      const partiallyAdmittedAndPaid = draft.isResponsePartiallyAdmittedAndAlreadyPaid()

      if (partiallyAdmitted) {

        if (partiallyAdmittedAndPaid) {
          tasks.push(
            new TaskListItem(
              'How much have you paid?',
              PartAdmissionPaths.howMuchHaveYouPaidPage.evaluateUri({ externalId: externalId }),
              ValidationUtils.isValid(draft.partialAdmission.howMuchHaveYouPaid)
            )
          )
          if (draft.partialAdmission.paymentIntention !== undefined) {
            draft.partialAdmission.paymentIntention = undefined
          }
          if (draft.statementOfMeans !== undefined) {
            draft.statementOfMeans = undefined
          }
        } else {
          tasks.push(
            new TaskListItem(
              'How much money do you admit you owe?',
              PartAdmissionPaths.howMuchDoYouOwePage.evaluateUri({ externalId: externalId }),
              HowMuchDoYouOweTask.isCompleted(draft)
            )
          )
        }

        tasks.push(
          new TaskListItem(
            'Why do you disagree with the amount claimed?',
            PartAdmissionPaths.whyDoYouDisagreePage.evaluateUri({ externalId: externalId }),
            ValidationUtils.isValid(draft.partialAdmission.whyDoYouDisagree)
          )
        )

        const howMuchDoYouOweTask = HowMuchDoYouOweTask.isCompleted(draft)

        if (howMuchDoYouOweTask) {
          tasks.push(
            new TaskListItem(
              `When will you pay the ${NumberFormatter.formatMoney(draft.partialAdmission.howMuchDoYouOwe.amount)}?`,
              PartAdmissionPaths.paymentOptionPage.evaluateUri({ externalId: externalId }),
              WhenWillYouPayTask.isCompleted(draft)
            )
          )
        }

        if (StatementOfMeansFeature.isApplicableFor(claim, draft)) {
          tasks.push(
            new TaskListItem(
              'Share your financial details',
              StatementOfMeansPaths.introPage.evaluateUri({ externalId: externalId }),
              StatementOfMeansTask.isCompleted(draft)
            )
          )
        } else if (draft.defendantDetails.partyDetails.isBusiness() &&
            !draft.isImmediatePaymentOptionSelected(draft.fullAdmission) &&
            !draft.isImmediatePaymentOptionSelected(draft.partialAdmission)
          ) {
          tasks.push(
            new TaskListItem(
              'Share your financial details',
              Paths.sendCompanyFinancialDetailsPage.evaluateUri({ externalId: externalId }),
              ViewSendCompanyFinancialDetailsTask.isCompleted(draft)
            )
          )
        }

        if (howMuchDoYouOweTask && WhenWillYouPayTask.isCompleted(draft)
          && draft.partialAdmission.paymentIntention.paymentOption.isOfType(PaymentType.INSTALMENTS)) {
          tasks.push(
            new TaskListItem(
              'Your repayment plan',
              PartAdmissionPaths.paymentPlanPage.evaluateUri({ externalId: externalId }),
              YourRepaymentPlanTask.isCompleted(draft.partialAdmission.paymentIntention.paymentPlan)
            )
          )
        }
      }
    }

    return new TaskList('Respond to claim', tasks)
  }
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:101,代碼來源:taskListBuilder.ts

示例6:

task => task.name === `Settle the claim for ${NumberFormatter.formatMoney(amount)}?`
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:1,代碼來源:taskListBuilder.ts

示例7: buildStatesPaidHowYouWantToRespondSection

  static buildStatesPaidHowYouWantToRespondSection (draft: DraftClaimantResponse, claim: Claim, mediationDraft: MediationDraft): TaskList {
    const tasks: TaskListItem[] = []
    const response: FullDefenceResponse | PartialAdmissionResponse = claim.response as FullDefenceResponse | PartialAdmissionResponse
    const externalId: string = claim.externalId

    if (response.responseType === ResponseType.FULL_DEFENCE) {
      tasks.push(
        new TaskListItem('Accept or reject their response',
          Paths.settleClaimPage.evaluateUri({ externalId: externalId }),
          ClaimSettledTask.isCompleted(draft)
        ))
    } else {
      if (StatesPaidHelper.isAlreadyPaidLessThanAmount(claim)) {
        tasks.push(
          new TaskListItem(`Have you been paid the ${ NumberFormatter.formatMoney(response.amount) }?`,
            Paths.partPaymentReceivedPage.evaluateUri({ externalId: externalId }),
            PartPaymentReceivedTask.isCompleted(draft)
          ))

        if (draft.partPaymentReceived && draft.partPaymentReceived.received.option === YesNoOption.YES) {
          tasks.push(
            new TaskListItem(`Settle the claim for ${ NumberFormatter.formatMoney(response.amount) }?`,
              Paths.settleClaimPage.evaluateUri({ externalId: externalId }),
              ClaimSettledTask.isCompleted(draft)
            ))
        }
      } else {
        tasks.push(
          new TaskListItem(`Have you been paid the full ${ NumberFormatter.formatMoney(claim.totalAmountTillDateOfIssue) }?`,
            Paths.settleClaimPage.evaluateUri({ externalId: externalId }),
            ClaimSettledTask.isCompleted(draft)
          ))
      }
    }

    if (claim.response.freeMediation === YesNoOption.YES) {
      if ((draft.accepted && draft.accepted.accepted.option === YesNoOption.NO) ||
        (draft.partPaymentReceived && draft.partPaymentReceived.received.option === YesNoOption.NO)) {
        if (FeatureToggles.isEnabled('mediation')) {
          const path = MediationPaths.freeMediationPage.evaluateUri({ externalId: claim.externalId })
          tasks.push(
            new TaskListItem(
              'Free telephone mediation',
              path,
              FreeMediationTask.isCompleted(draft, mediationDraft)
            ))
        } else {
          const path = Paths.freeMediationPage.evaluateUri({ externalId: claim.externalId })
          tasks.push(
            new TaskListItem(
              'Consider free mediation',
              path,
              FreeMediationTask.isCompleted(draft, mediationDraft)
            ))
        }
      }
    }

    return new TaskList('Your response', tasks)

  }
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:61,代碼來源:taskListBuilder.ts

示例8: buildHowYouWantToRespondSection

  static buildHowYouWantToRespondSection (draft: DraftClaimantResponse, claim: Claim, mediationDraft: MediationDraft): TaskList {

    if (StatesPaidHelper.isResponseAlreadyPaid(claim)) {
      return this.buildStatesPaidHowYouWantToRespondSection(draft, claim, mediationDraft)
    }

    const externalId: string = claim.externalId
    const tasks: TaskListItem[] = []

    if (claim.response.responseType === ResponseType.FULL_DEFENCE
      && claim.response.freeMediation === YesNoOption.NO) {
      tasks.push(
        new TaskListItem(
          'Accept or reject their response',
          Paths.notImplementedYetPage.evaluateUri({ externalId: externalId }),
          false
        )
      )
    }

    if (claim.response.responseType === ResponseType.PART_ADMISSION
      && claim.response.paymentIntention !== undefined) {
      tasks.push(
        new TaskListItem(
          'Accept or reject the ' + NumberFormatter.formatMoney(claim.response.amount),
          Paths.settleAdmittedPage.evaluateUri({ externalId: externalId }),
          SettleAdmittedTask.isCompleted(draft.settleAdmitted)
        )
      )

      if (draft.settleAdmitted
        && draft.settleAdmitted.admitted.option === YesNoOption.YES
        && claim.response.paymentIntention.paymentOption !== PaymentOption.IMMEDIATELY) {
        tasks.push(
          new TaskListItem(
            'Accept or reject their repayment plan',
            Paths.acceptPaymentMethodPage.evaluateUri({ externalId: externalId }),
            AcceptPaymentMethodTask.isCompleted(draft.acceptPaymentMethod)
          )
        )
      }

      this.buildProposeAlternateRepaymentPlanTask(draft, tasks, externalId)

      if (!claim.claimData.defendant.isBusiness() || (draft.acceptPaymentMethod && draft.acceptPaymentMethod.accept.option === YesNoOption.YES)) {
        this.buildFormaliseRepaymentPlan(draft, tasks, externalId)
      }

      this.buildSignSettlementAgreement(draft, tasks, externalId)
      this.buildRequestCountyCourtJudgment(draft, tasks, externalId)

      if (claim.response.freeMediation === YesNoOption.YES
        && draft.settleAdmitted
        && draft.settleAdmitted.admitted.option === YesNoOption.NO) {
        if (FeatureToggles.isEnabled('mediation')) {
          const path = MediationPaths.freeMediationPage.evaluateUri({ externalId: claim.externalId })
          tasks.push(
            new TaskListItem(
              'Free telephone mediation',
              path,
              FreeMediationTask.isCompleted(draft, mediationDraft)
            ))
        } else {
          const path = Paths.freeMediationPage.evaluateUri({ externalId: claim.externalId })
          tasks.push(
            new TaskListItem(
              'Consider free mediation',
              path,
              FreeMediationTask.isCompleted(draft, mediationDraft)
            ))
        }
      }
    }

    if (claim.response.responseType === ResponseType.FULL_ADMISSION
      && claim.response.paymentIntention.paymentOption !== PaymentOption.IMMEDIATELY
    ) {
      tasks.push(
        new TaskListItem(
          'Accept or reject their repayment plan',
          Paths.acceptPaymentMethodPage.evaluateUri({ externalId: externalId }),
          AcceptPaymentMethodTask.isCompleted(draft.acceptPaymentMethod)
        )
      )
      this.buildProposeAlternateRepaymentPlanTask(draft, tasks, externalId)

      if (!claim.claimData.defendant.isBusiness() || (draft.acceptPaymentMethod && draft.acceptPaymentMethod.accept.option === YesNoOption.YES)) {
        this.buildFormaliseRepaymentPlan(draft, tasks, externalId)
      }

      this.buildSignSettlementAgreement(draft, tasks, externalId)
      this.buildRequestCountyCourtJudgment(draft, tasks, externalId)
    }

    return new TaskList('How do you want to respond?', tasks)
  }
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:96,代碼來源:taskListBuilder.ts


注:本文中的utils/numberFormatter.NumberFormatter.formatMoney方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。