Residual Prediction Plugin

Plugin options interface

interface PluginOptions {
  token?: string
  selector?: string
  onComplete?: (data: DAT2.Response.GetVehicleEvaluation['VXS']) => void
  onCompleteBackend?: (data: DAT2.Response.GetVehicleEvaluation['VXS']) => void
  onUpdate?: (data: DAT2.Response.GetVehicleEvaluation['VXS']) => void
  credentials?: {
    customerNumber: string
    user: string
    password: string
  }
  additionalDataForBackendRequest?: {
    evaluationDate: DAT2.Request.GetVehicleTargetDateEvaluationHistory['evaluationDate']
  }
  requestData: {
    datECode: string // 15 digits
    container: string // [country flag; 2 digits]+[number of container; 3 digits]
    mileage: number // numeric
    constructionTime: number // [4 digits; numeric]
    registrationDate: string
    restriction: string // 'APPRAISAL'
    save: string // TRUE, FALSE
    vatType?: 'R' | 'D' // R = Rule taxing, D = Difference taxing
    equipment: {
      equipmentPosition?: Array<{
        datEquipmentId?: number // numeric
      }>
    }
  }
  settings?: {
    country?: string
  }
  includeVat?: 'true' | 'false' //Showing or not showing VAT
  priceType?: 'SalesPrice' | 'PurchasePrice' //Purchase or sales price

  curveType?: 'Minimum' | 'DAT' | 'Maximum' //Curvature type; 3 values for selection: minimal, according to DAT or maximum

  decreaseType?: 'RV' | 'Table1' | 'Table2' | 'Table3' | 'Table4' | 'DT' //Devaluation type

  mileageType?: 'Total' | 'Year' //Details of the mileage details to be used; possible values:  Year - value mileagePerYear is applied (DEFAULT).  Total - - value mileageTotal is applied.

  valueType?: 'Monetary' | 'Percentage' | 'Mileage' //Type of value return:

  //Residual value prediction element, 0 - n repetitions possible
  forecastItems?: {
    forecastItem?: Array<{
      ageInMonth?: string
      mileagePerYear?: string
    }>
  }
}

Plugin example with UI

<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- load plugin styles -->
    <link
      href="https://plugins.wedat.eu/residual-prediction/plugin.css"
      rel="stylesheet"
    />
  </head>
  <body>
    <!-- element to which plugin will be rendered -->
    <div class="plugin"></div>

    <!-- load plugin JS synchronously -->
    <script src="https://plugins.wedat.eu/residual-prediction/plugin.js"></script>

    <!-- init plugin options in your JS file or inline JS like this -->
    <script>
      window.RESIDUAL_PREDICTION_API.init({
          selector: '.plugin',
          onComplete: values => {
              console.log(values);
          },
          onCompleteBackend: values => {
              console.log(values);
          },
          onUpdate: values => {
              console.log(values);
          },
          requestData: {
              datECode: '010601840970001',
              container: 'DE002',
              mileage: 40000,
              constructionTime: 5980,
              registrationDate: '2020-11-24',
              restriction: 'APPRAISAL',
              save: 'TRUE',
              equipment: {
                  equipmentPosition: [
                      {
                          datEquipmentId: 24085
                      },
                      {
                          datEquipmentId: 68703
                      },
                      {
                          datEquipmentId: 47518
                      }
                  ]
              },
              forecastItems: {
                  forecastItem: [
                      {
                          ageInMonth: '12',
                          mileagePerYear: '40000'
                      },
                      {
                          ageInMonth: '24',
                          mileagePerYear: '40000'
                      },

                      {
                          ageInMonth: '12',
                          mileagePerYear: '50000'
                      },
                      {
                          ageInMonth: '25',
                          mileagePerYear: '50000'
                      }
                  ]
              }
          }
      );
    </script>
  </body>
</html>

Plugin example without UI

<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- no need to load styles -->
  </head>
  <body>
    <!-- load plugin JS synchronously -->
    <script src="https://plugins.wedat.eu/residual-prediction/plugin.js"></script>

    <!-- init plugin options in your JS file or inline JS like this -->
    <script>
      window.RESIDUAL_PREDICTION_API.init({
        <!-- selector prop is not provided -->
        <!-- credentials or token are required -->
        credentials: {
          customerNumber: 'customerNumber',
          user: 'user',
          password: 'password'
        },
        onComplete: (values) => {
          // make what your want :)
          console.log(values)
        },
        onCompleteBackend: (values) => {
          // make what your want :)
          console.log(values)
        },
        requestData: {
          datECode: '010601840970001',
          container: 'DE002',
          mileage: 40000,
          constructionTime: 5980,
          registrationDate: '2020-11-24',
          restriction: 'APPRAISAL',
          save: 'TRUE',
          equipment: {
            equipmentPosition: [
              {
                datEquipmentId: 24085
              },
              {
                datEquipmentId: 68703
              },
              {
                datEquipmentId: 47518
              }
            ]
          },
          forecastItems: {
            forecastItem: [
              {
                ageInMonth: '12',
                mileagePerYear: '40000'
              },
              {
                ageInMonth: '24',
                mileagePerYear: '40000'
              },

              {
                ageInMonth: '12',
                mileagePerYear: '50000'
              },
              {
                ageInMonth: '25',
                mileagePerYear: '50000'
              }
            ]
          }
        }
      })
    </script>
  </body>
</html>