ministryofjustice/Claim-for-Crown-Court-Defence

View on GitHub
app/views/external_users/claims/transfer_fee/_fields.html.haml

Summary

Maintainability
Test Coverage
#transfer-fee
  = f.fields_for :transfer_fee do |tf|
    .fx-fee-group.transfer-fee-group.js-block.fx-do-init{ data: { 'type': 'transferFees', autovat: @claim.apply_vat? ? 'true' : 'false' } }

      = tf.govuk_text_field :fee_type_id,
        class: 'js-fee-type',
        form_group: { class: 'js-fee-calculator-effector' },
        label: { hidden: true },
        type: 'hidden',
        value: @claim.transfer_fee.fee_type.id

      - if @claim.can_have_ppe?

        - if @claim.transfer_detail.days_claimable?
          = f.govuk_number_field :actual_trial_length,
            class: 'js-fee-calculator-days',
            form_group: { class: 'js-fee-calculator-effector' },
            label: { text: t('.actual_trial_length') },
            min: 0,
            width: 'one-quarter'

        = tf.govuk_number_field :quantity,
          class: 'quantity fee-quantity js-fee-calculator-ppe',
          form_group: { class: 'js-fee-calculator-effector' },
          label: { text: t('.quantity') },
          min: 0,
          value: number_with_precision(tf.object.quantity, precision: 0),
          width: 'one-quarter'

      = tf.govuk_number_field :amount,
        class: 'total fee-amount',
        form_group: { class: 'calculated-grad-fee js-graduated-price-effectee' },
        label: { text: t('.amount') },
        min: 0,
        prefix_text: '£',
        value: number_with_precision(tf.object.amount, precision: 2),
        width: 'one-quarter'

      = tf.govuk_text_field :price_calculated,
        form_group: { class: 'js-fee-calculator-success' },
        label: { hidden: true },
        type: 'hidden',
        value: tf.object.price_calculated?

      .fee-calc-help-wrapper.hidden
        = govuk_detail t('.help_how_we_calculate_amount_title') do
          = t('.help_how_we_calculate_amount_body')