Plugin Directory

Changeset 2603772


Ignore:
Timestamp:
09/23/2021 03:37:23 PM (5 years ago)
Author:
triggerfishab
Message:

Tagging version 2.0.0

Location:
triggerfish-bytbil-accesspaket
Files:
3 deleted
4 edited
12 copied

Legend:

Unmodified
Added
Removed
  • triggerfish-bytbil-accesspaket/tags/2.0.0/readme.txt

    r2603621 r2603772  
    55Tested up to: 5.3.2
    66Requires PHP: 7.3
    7 Stable tag: 1.9.9
     7Stable tag: 2.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • triggerfish-bytbil-accesspaket/tags/2.0.0/templates/single-page-parts/finance-data.php

    r2543635 r2603772  
    2222        $dealer['emailAddressesInterest'];
    2323}
     24
     25function calculateMonthlyFrom($response, $currentPrice)
     26{
     27    if (empty($response) || empty($response)) {
     28        return;
     29    }
     30
     31    if (empty($response['Rate']) || empty($response['MaxMonths']) || empty($response['MinUpfrontInPercent'])) {
     32        return;
     33    }
     34
     35    $rate = floatval($response['Rate']);
     36    $maxMonths = intval($response['MaxMonths']);
     37    $minUpfrontInPercent = floatval($response['MinUpfrontInPercent']);
     38    $periodRate = ($rate / 12) * 0.01;
     39    $totalRate = pow(1 + $periodRate, $maxMonths);
     40    $restValue = 0;
     41    $loanAmount = $currentPrice - ($currentPrice * $minUpfrontInPercent) / 100;
     42    $monthCost = -(-$loanAmount * $totalRate + $restValue) / (($totalRate - 1) / $periodRate);
     43    return ceil($monthCost);
     44}
     45
     46$payment_per_month = calculateMonthlyFrom($response, $currentPrice);
    2447?>
     48
     49
    2550
    2651<div id="tfap-price-container" class="tfap-primary-bg tfap-center-text" data-car-price="<?php echo $currentPrice; ?>" data-car-model-year="<?php echo $modelYear; ?>" data-repayment-months="<?php echo $response['DefaultMonthsSalvageValue']; ?>" data-car-cash="<?php echo $cash_min_value; ?>">
     
    3358    <?php endif; ?>
    3459
    35     <?php if ($response !== false && !$data['leasing']) : ?>
    36         <?php $payment_per_month = ($currentPrice - $cash_min_value) / ($response['MaxMonths']); ?>
     60    <?php if ($response !== false && !$data['leasing'] && !empty($payment_per_month)) : ?>
    3761        <p class="tfap-h5 tfap-mt1 tfap-color-white tfap-print-color-black">
    3862            <?php
  • triggerfish-bytbil-accesspaket/tags/2.0.0/triggerfish-bytbil-accesspaket.php

    r2603621 r2603772  
    66 * Author URI: https://www.triggerfish.se
    77 * Text Domain: access-package-integration
    8  * Version: 1.9.9
     8 * Version: 2.0.0
    99 * Description: Plugin för att visa bilar till salu.
    1010 */
     
    1616}
    1717
    18 define('TFAP_PLUGIN_VERSION', 1.9);
     18define('TFAP_PLUGIN_VERSION', 2.0);
    1919
    2020define('TFAP_PLUGIN_DIR', __DIR__);
  • triggerfish-bytbil-accesspaket/trunk/readme.txt

    r2603621 r2603772  
    55Tested up to: 5.3.2
    66Requires PHP: 7.3
    7 Stable tag: 1.9.9
     7Stable tag: 2.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • triggerfish-bytbil-accesspaket/trunk/templates/single-page-parts/finance-data.php

    r2543635 r2603772  
    2222        $dealer['emailAddressesInterest'];
    2323}
     24
     25function calculateMonthlyFrom($response, $currentPrice)
     26{
     27    if (empty($response) || empty($response)) {
     28        return;
     29    }
     30
     31    if (empty($response['Rate']) || empty($response['MaxMonths']) || empty($response['MinUpfrontInPercent'])) {
     32        return;
     33    }
     34
     35    $rate = floatval($response['Rate']);
     36    $maxMonths = intval($response['MaxMonths']);
     37    $minUpfrontInPercent = floatval($response['MinUpfrontInPercent']);
     38    $periodRate = ($rate / 12) * 0.01;
     39    $totalRate = pow(1 + $periodRate, $maxMonths);
     40    $restValue = 0;
     41    $loanAmount = $currentPrice - ($currentPrice * $minUpfrontInPercent) / 100;
     42    $monthCost = -(-$loanAmount * $totalRate + $restValue) / (($totalRate - 1) / $periodRate);
     43    return ceil($monthCost);
     44}
     45
     46$payment_per_month = calculateMonthlyFrom($response, $currentPrice);
    2447?>
     48
     49
    2550
    2651<div id="tfap-price-container" class="tfap-primary-bg tfap-center-text" data-car-price="<?php echo $currentPrice; ?>" data-car-model-year="<?php echo $modelYear; ?>" data-repayment-months="<?php echo $response['DefaultMonthsSalvageValue']; ?>" data-car-cash="<?php echo $cash_min_value; ?>">
     
    3358    <?php endif; ?>
    3459
    35     <?php if ($response !== false && !$data['leasing']) : ?>
    36         <?php $payment_per_month = ($currentPrice - $cash_min_value) / ($response['MaxMonths']); ?>
     60    <?php if ($response !== false && !$data['leasing'] && !empty($payment_per_month)) : ?>
    3761        <p class="tfap-h5 tfap-mt1 tfap-color-white tfap-print-color-black">
    3862            <?php
  • triggerfish-bytbil-accesspaket/trunk/triggerfish-bytbil-accesspaket.php

    r2603621 r2603772  
    66 * Author URI: https://www.triggerfish.se
    77 * Text Domain: access-package-integration
    8  * Version: 1.9.9
     8 * Version: 2.0.0
    99 * Description: Plugin för att visa bilar till salu.
    1010 */
     
    1616}
    1717
    18 define('TFAP_PLUGIN_VERSION', 1.9);
     18define('TFAP_PLUGIN_VERSION', 2.0);
    1919
    2020define('TFAP_PLUGIN_DIR', __DIR__);
Note: See TracChangeset for help on using the changeset viewer.