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


TypeScript calculateMonthIncrement.calculateMonthIncrement函數代碼示例

本文整理匯總了TypeScript中common/calculate-month-increment/calculateMonthIncrement.calculateMonthIncrement函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript calculateMonthIncrement函數的具體用法?TypeScript calculateMonthIncrement怎麽用?TypeScript calculateMonthIncrement使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: monthIncrementFilter

export function monthIncrementFilter (value: moment.Moment | string): moment.Moment {
  try {
    if (!value || !(typeof value === 'string' || value instanceof moment)) {
      throw new Error('Input should be moment or string, cannot be empty')
    }

    let date: moment.Moment
    if (typeof value === 'string') {
      if (value === 'now') {
        date = moment()
      } else {
        date = moment(value)
      }
    } else {
      date = value
    }
    if (!date.isValid()) {
      throw new Error('Invalid date')
    }
    return calculateMonthIncrement(date)
  } catch (err) {
    logger.error(err)
    throw err
  }
}
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:25,代碼來源:dateFilter.ts

示例2: it

  it('should return the correct earliest date where defendant pays by instalment in 50 days but claimant chooses pay by instalment in 5 days - partial admissions', () => {
    const claim = prepareClaim(partialAdmissionWithPaymentByInstalmentsDataPaymentDateAfterMonth)
    const claimantPaymentDate: moment.Moment = MomentFactory.currentDate().add(5, 'days')
    const monthIncrement = calculateMonthIncrement(moment().startOf('day'))
    const paymentDate = getEarliestPaymentDateForPaymentPlan(claim, claimantPaymentDate)

    expect(paymentDate.toString()).to.equal(monthIncrement.toString())
  })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:8,代碼來源:paydateHelper.ts

示例3: calculateLastPaymentDate

  calculateLastPaymentDate (): moment.Moment {
    let lastPaymentDate = this.startDate.clone()

    switch (this.frequency) {
      case (Frequency.WEEKLY):
        lastPaymentDate.add(this.numberOfInstalments - 1, 'weeks')
        break
      case (Frequency.TWO_WEEKLY):
        lastPaymentDate.add((this.numberOfInstalments - 1) * 2, 'weeks')
        break
      case (Frequency.MONTHLY):
        lastPaymentDate = calculateMonthIncrement(lastPaymentDate, this.numberOfInstalments - 1)
        break
    }
    return lastPaymentDate
  }
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:16,代碼來源:paymentPlan.ts

示例4: getEarliestPaymentDateForPaymentPlan

export function getEarliestPaymentDateForPaymentPlan (claim: Claim, claimantPaymentDate: moment.Moment): moment.Moment {
  const monthIncrementDate: moment.Moment = calculateMonthIncrement(moment().startOf('day'))
  const response: FullAdmissionResponse | PartialAdmissionResponse = claim.response as FullAdmissionResponse | PartialAdmissionResponse
  if (!response) {
    return monthIncrementDate
  }
  const defendantPaymentOption: PaymentOption = response.paymentIntention.paymentOption
  const earliestPermittedDate: moment.Moment = claimantPaymentDate < monthIncrementDate ? monthIncrementDate : claimantPaymentDate

  if (defendantPaymentOption === PaymentOption.IMMEDIATELY || defendantPaymentOption === PaymentOption.BY_SPECIFIED_DATE) {
    return earliestPermittedDate
  }

  const defendantPaymentDate: moment.Moment = response.paymentIntention.repaymentPlan.firstPaymentDate

  return defendantPaymentDate < earliestPermittedDate ? defendantPaymentDate : earliestPermittedDate
}
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:17,代碼來源:paydateHelper.ts

示例5: getRepaymentPlanForm

export function getRepaymentPlanForm (claim: Claim, draft: DraftWrapper<DraftCCJ>): RepaymentPlanForm {
  if (draft.document.paymentOption.option === PaymentType.INSTALMENTS) {
    if ((claim.settlement && (claim.settlementReachedAt || claim.settlement.isOfferRejectedByDefendant())) || claim.hasDefendantNotSignedSettlementAgreementInTime()) {
      const coreRepaymentPlan: CoreRepaymentPlan = claim.settlement.getLastOffer().paymentIntention.repaymentPlan
      const firstPaymentDate: Moment = calculateMonthIncrement(MomentFactory.currentDate(), 1)
      const paymentSchedule: PaymentSchedule = PaymentSchedule.of(coreRepaymentPlan.paymentSchedule)
      const alreadyPaid: number = (draft.document.paidAmount.amount || 0)
      const remainingAmount: number = claim.totalAmountTillToday - alreadyPaid
      const repaymentPlanForm: RepaymentPlanForm = new RepaymentPlanForm(
        remainingAmount,
        coreRepaymentPlan.instalmentAmount,
        new LocalDate(firstPaymentDate.year(), firstPaymentDate.month() + 1, firstPaymentDate.date()),
        paymentSchedule)
      return repaymentPlanForm
    }
  }
  return draft.document.repaymentPlan
}
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:18,代碼來源:ccjModelConverter.ts

示例6: it

 it('should calculate a month where the start date is 31st leading to next month with 30 days',() => {
   const startDate: moment.Moment = MomentFactory.parse('2018-08-31')
   const calculateMonthDate: moment.Moment = calculateMonthIncrement(startDate)
   expect(calculateMonthDate.toString()).to.equal(MomentFactory.parse('2018-10-01').toString())
 })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:5,代碼來源:calculate-month-increment.ts

示例7: createPaymentPlanFromDefendantFinancialStatement

  static createPaymentPlanFromDefendantFinancialStatement (claim: Claim, draft: DraftClaimantResponse): PaymentPlan {
    const response = claim.response as FullAdmissionResponse | PartialAdmissionResponse
    const frequency: Frequency = response.paymentIntention.paymentOption === PaymentOption.INSTALMENTS ?
      Frequency.of(response.paymentIntention.repaymentPlan.paymentSchedule) : Frequency.WEEKLY

    if (claim.claimData.defendant.isBusiness()) {
      return undefined
    }

    if (response === undefined) {
      throw new Error('Claim does not have response attached')
    }
    if (response.statementOfMeans === undefined) {
      throw new Error(`Claim response does not have financial statement attached`)
    }

    const instalmentAmount: number = Math.min(draft.courtDetermination.disposableIncome / frequency.monthlyRatio, claim.totalAmountTillToday)
    if (instalmentAmount < 1) {
      return PaymentPlanHelper.createPaymentPlanFromStartDate(MomentFactory.maxDate())
    }

    return PaymentPlanHelper.createPaymentPlanFromInstallment(AdmissionHelper.getAdmittedAmount(claim), instalmentAmount, frequency, calculateMonthIncrement(MomentFactory.currentDate()))
  }
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:23,代碼來源:paymentPlanHelper.ts

示例8: createPaymentPlanFromClaimAdmission

  private static createPaymentPlanFromClaimAdmission (response: FullAdmissionResponse | PartialAdmissionResponse,
                                                      totalAmount: number,
                                                      draft: DraftClaimantResponse): PaymentPlan {
    const paymentIntention: PI = response.paymentIntention
    if (!paymentIntention) {
      return undefined
    }

    if (paymentIntention.repaymentPlan) {
      return PaymentPlanHelper.createPaymentPlanFromInstallment(
        totalAmount,
        paymentIntention.repaymentPlan.instalmentAmount,
        Frequency.of(paymentIntention.repaymentPlan.paymentSchedule),
        paymentIntention.repaymentPlan.firstPaymentDate
      )
    }

    if (draft.courtDetermination.disposableIncome <= 0) {
      return PaymentPlanHelper.createPaymentPlanFromStartDate(MomentFactory.maxDate())
    }

    if (paymentIntention.paymentOption === PaymentOption.BY_SPECIFIED_DATE) {
      const instalmentAmount: number = draft.courtDetermination.disposableIncome / Frequency.WEEKLY.monthlyRatio
      return PaymentPlanHelper.createPaymentPlanFromInstallment(totalAmount, instalmentAmount, Frequency.WEEKLY, calculateMonthIncrement(MomentFactory.currentDate()))
    }
  }
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:26,代碼來源:paymentPlanHelper.ts


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