当前位置: 首页>>代码示例>>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;未经允许,请勿转载。