change(…)

required permissions:

  • trackers: “update”
  • transactions: “create”
  • tariffs: “read”

params:

  • tracker_id – int. id of tracker
  • tariff_id – int. new tariff id
  • repay – boolean. repay remainder of current tariff payment?
  • charge – boolean. charge payment for new tariff? (for monthly and everyday tariffs)

return:

{ "success": true }

errors:

  • 201 – Not found in database
  • 219 – Not allowed for clones of the device
  • 221 (Device limit exceeded) – when new tariff device limit is less then count of user’s trackers.
  • 237 – Invalid tariff (if there are no tariff with tracker.tariff_id and belongs to dealer)
  • 238 – Changing tariff is not allowed
  • 239 – New tariff doesn’t exist
  • 250 – Not allowed for deleted devices
  • 252 (Device already corrupted) – when tracker’s source is corrupted

Conditions of the change

The current dealer can change tracker tariff from t1 to t2, if:

  1. Tracker:

    1. is not removed
    2. belongs to the dealer’s user
    3. is not a clone
  2. t1.tariff_id != t2.tariff_id, i.e. it is impossible to change for the same tariff
  3. t1.dealer_id = t2.dealer_id = dealer.effectiveDealerId, i.e. both tariffs belong to the current dealer
  4. t2.device = tracker, i.e. only tracker tariffs are available
  5. depending on t2.doc_type
    • doc_type=0 (for all) – without conditions
    • doc_type=1 (for the physical persons) – user.face=1 (physical person)
    • doc_type=2 (for legal entities) – user.face=2 (legal entity) or user.face=3 (SP)
    • doc_type=3 (paas) – without conditions
  6. t2.device_limit >= count of trackers in user’s cabinet.

Repayment

Repayment is carried out if the following conditions are met:
1. the “repay” flag is set (repay)
2. current tariff – monthly: t1.type = monthly
3. tariff – paid: tariff.price > 0
4. that the current tariff didn’t end (tariff_end != 1)
5. the tariff expiration date is defined: tariff_end_date != 0 (for monthly tariffs it has to be carried out always)
6. the free period expired: created_date + free_period <= current date,
where free_period obtained from the hardcodes table or from default_model_settings
7. there is still at least one paid day on a tariff: reminder > 0
The rest of days on a tariff: remainder = the number of whole days before the end of the current tariff.

amount to be repaid = ceil(tariff.price * remainder / amt),
where amt – the number of days in the current month, а ceil – the operation of taking the integer part

Change

  • tariff_id = next_tariff = new tariff id
  • tariff_change = current date
  • if tariff is active (tariff_end = false) then
    • tariff_end = false
    • last_charged_date = current date
    • if new tariff is monthly and the flag “to charge” is not set (charge) then
      • tariff_end_date = the first day of the next month from the current date
    • else
      • tariff_end_date = tomorrow date
  • else (tariff is not active: tariff_end = true)
    • last_charged_date = yesterday date
    • if new tariff is monthly then
      • if the flag “to charge” is set (charge) then
        • tariff_end_date = current date
        • tariff_end = true
      • else
        • tariff_end_date = the first day of the next month from the current date
        • tariff_end = false
    • if the new tariff is everyday then
      • if the flag “to charge” is set(charge) then
        • tariff_end_date = current date
        • tariff_end = true
      • else
        • tariff_end_date = tomorrow date
        • tariff_end = false
    • if the new tariff is activeday then
      • tariff_end_date = 0
      • tariff_end = false

All dates according to UTC time.

If you have more questions please contact our support team

Contáctenos

USA: +1 858 815 9045

Mexico: +52 334 1642158

UK: +44 808 1641499

Germany: +49 1573 5988250

Russia: +7 495 223 0427

Log in

Login

[clean-login]

CLOSE
Register

[clean-login-register]

CLOSE
Loading...