Plugin Directory

Changeset 1904660


Ignore:
Timestamp:
07/05/2018 05:22:20 PM (8 years ago)
Author:
bseddon
Message:

Added support for fees which are used by the EDD 'pro' discount plugin to implement discounts.

Location:
vat-moss/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • vat-moss/trunk/includes/class-integrations.php

    r1691761 r1904660  
    483483
    484484        // $fetched = wp_remote_get("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml");
     485        global $wp_version;
    485486        $fetched = wp_remote_get( "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml", array( 'user-agent' => 'WordPress-' . $wp_version . '; ' . home_url() . ';' ) );
    486487
  • vat-moss/trunk/includes/integrations/class-edd.php

    r1512910 r1904660  
    172172
    173173                    $vat_payment = array();
     174
     175                    // error_log( print_r( $item, true ) );
    174176
    175177                    /*
     
    186188                        "subtotal"      => 7.5
    187189                        "tax"           => 0.6
    188                         "fees"          => {}
     190                        "fees"          => {
     191                            [amount] => -8.85
     192                            [label] => 15% Bundle Discount - StereoDelta
     193                            [no_tax] => 1
     194                            [type] => fee
     195                            [download_id] => 74
     196                            [price_id] =>
     197                        }
    189198                        "price"         => 6.6
    190199                        "vat_rate"      => 0.1
     
    205214                     */
    206215
     216                    $totalfees = array_reduce( $item['fees'], function( $carry, $fee )
     217                    {
     218                        $carry += $fee['amount'];
     219                        return $carry;
     220                    }, 0 );
     221
     222                    // error_log( "Total fees: {$item['price']} - {$item['tax']} + $totalfees" );
     223
    207224                    $vat_payment['id']              = $payment_id;
    208225                    $vat_payment['item_id']         = $item['id'];
     
    211228                    $vat_payment['date']            = $date;
    212229                    $vat_payment['submission_id']   = $submission_id;
    213                     $vat_payment['net']             = round( apply_filters( 'moss_get_net_transaction_amount', $item['price'] - $item['tax'], $payment_id), 2);
     230                    $vat_payment['net']             = round( apply_filters( 'moss_get_net_transaction_amount', $item['price'] - $item['tax'] + $totalfees, $payment_id), 2);
    214231                    $vat_payment['tax']             = round( $item['tax'], 2 );                 
    215232                    $vat_payment['vat_rate']        = round( isset( $item['vat_rate'] ) ?  $item['vat_rate'] : $payment_rate, 3 );
     
    368385                    "subtotal"      => 7.5
    369386                    "tax"           => 0.6
    370                     "fees"          => {}
     387                    "fees"          => {
     388                        [amount] => -8.85
     389                        [label] => 15% Bundle Discount - StereoDelta
     390                        [no_tax] => 1
     391                        [type] => fee
     392                        [download_id] => 74
     393                        [price_id] =>
     394                    }
    371395                    "price"         => 6.6
    372396                    "vat_rate"      => 0.1
     
    388412                 */
    389413
     414                $totalfees = array_reduce( $item['fees'], function( $carry, $fee )
     415                {
     416                    $carry += $fee['amount'];
     417                    return $carry;
     418                }, 0 );
     419
     420                // error_log( "Total fees: {$item['price']} - {$item['tax']} + $totalfees" );
     421
    390422                $vat_payment['id']              = $payment_id;
    391423                $vat_payment['item_id']         = $item['id'];
     
    394426                $vat_payment['date']            = $date;
    395427                $vat_payment['submission_id']   = $submission_id;
    396                 $vat_payment['net']             = round( apply_filters( 'moss_get_net_transaction_amount', $item['price'] - $item['tax'], $payment_id), 2);
     428                $vat_payment['net']             = round( apply_filters( 'moss_get_net_transaction_amount', $item['price'] - $item['tax'] + $totalfees, $payment_id), 2);
    397429                $vat_payment['tax']             = round( $item['tax'], 2 );                 
    398430                $vat_payment['vat_rate']        = round( isset( $item['vat_rate'] ) ?  $item['vat_rate'] : $payment_rate, 3 );
  • vat-moss/trunk/includes/submissions.php

    r1513665 r1904660  
    4343        : 'en_GB'
    4444      );
     45// On some Linux distrubutions the locale can be > 255 characters which is no allowed and raised a warning
     46// Instead, look for the LC_ALL value but if not found pass an array of the values.
     47if ( strlen( $locale ) > 255 )
     48{
     49    $locale = explode(";", $locale );
     50    $loc = array();
     51    foreach( $locale as $bit )
     52    {
     53       $value = explode("=",$bit);
     54       $loc[ $value[0] ] = $value[1];
     55    }
     56    $locale = isset( $loc['LC_ALL'] )
     57        ? $loc['LC_ALL']
     58        : $loc;
     59}
    4560setlocale( LC_ALL, $locale );
    4661
  • vat-moss/trunk/readme.txt

    r1761163 r1904660  
    66Requires at least: 3.9.2
    77Tested up to: 4.9
    8 Stable Tag: 1.0.25
     8Stable Tag: 1.0.27
    99License: GNU Version 2 or Any Later Version
    1010
     
    181181
    182182Fixed a problem that prevented the plugin accessing Euro exchange from the ECB web site.
     183
     184= 1.0.26 =
     185
     186Updated submissions.php to allow for locale strings > 255 which the setlocale function does not allow.
     187
     188= 1.0.27
     189
     190Added support for EDD fees which are used by the EDD 'pro' discount plugin to implement discounts.
    183191
    184192== Upgrade Notice ==
  • vat-moss/trunk/vat-moss.php

    r1691761 r1904660  
    55Plugin URI: http://www.wproute.com/downloads/vat-moss/
    66Description: Management and submission of VAT sales to EU consumers.
    7 Version: 1.0.25
    8 Tested up to: 4.7.3
     7Version: 1.0.27
     8Tested up to: 4.9.6
    99Author: Lyquidity Solutions
    1010Author URI: http://www.wproute.com/
     
    431431
    432432        if ( ! defined( 'VAT_MOSS_VERSION' ) )
    433             define( 'VAT_MOSS_VERSION',                         '1.0.25' );
     433            define( 'VAT_MOSS_VERSION',                         '1.0.27' );
    434434
    435435        if ( ! defined( 'VAT_MOSS_WORDPRESS_COMPATIBILITY' ) )
    436             define( 'VAT_MOSS_WORDPRESS_COMPATIBILITY',         '4.7.3' );
     436            define( 'VAT_MOSS_WORDPRESS_COMPATIBILITY',         '4.9.6' );
    437437
    438438        if ( ! defined( 'VAT_MOSS_STORE_API_URL' ) )
     
    524524        require_once VAT_MOSS_INCLUDES_DIR . 'class-settings.php';
    525525        require_once VAT_MOSS_INCLUDES_DIR . 'class-integrations.php';
    526         require_once VAT_MOSS_INCLUDES_DIR . 'settings.php';
    527526        require_once VAT_MOSS_INCLUDES_DIR . 'vatidvalidator.php';
    528527        require_once(VAT_MOSS_INCLUDES_DIR . 'class-html-elements.php');
Note: See TracChangeset for help on using the changeset viewer.