Plugin Directory

Changeset 2414415


Ignore:
Timestamp:
11/07/2020 10:43:39 AM (5 years ago)
Author:
jank404
Message:

v1.1.12

Location:
apollo/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • apollo/trunk/apollo.php

    r2402661 r2414415  
    44 * Plugin URI:        https://wordpress.org/plugins/apollo
    55 * Description:       Manually or automatically generate invoices and send PDFs as attachments for WooCommerce orders.
    6  * Version:           1.1.11
     6 * Version:           1.1.12
    77 * Author:            Studio404
    88 * Text Domain:       apollo
    99 * Domain Path:       /languages
    10  * WC tested up to:   4.1.1
     10 * WC tested up to:   4.6.2
    1111 * WC requires at least: 3.0
    1212 */
     
    1414defined( 'ABSPATH' ) or exit;
    1515
    16 define( 'APOLLO_VERSION', '1.1.11' );
     16define( 'APOLLO_VERSION', '1.1.12' );
    1717
    1818function apollo_load_plugin() {
  • apollo/trunk/includes/admin/invoice.php

    r2397152 r2414415  
    3838      $premise = $output['apollo_premise-id'];
    3939      $device = $output['apollo_device-id'];
     40
     41      $unitID = $output['apollo_unit-id'] ?? '';
    4042
    4143      if (!$order || !$output || !$token || !$organization_id) {
     
    9496
    9597        $sku = $productData->get_sku();
    96         // error_log( print_r($sku, TRUE) );
    9798
    9899        // add SKU code if item has one
     
    108109        // if numbers don't match, we assume item was discounted (since there is no way of telling otherwise... atleast for now?)
    109110        if (floatval($product['total']) < floatval($product['subtotal'])) {
    110           $product_data['discount'] = round((1 - (floatval($product['total']) / floatval($product['subtotal']))) * 100);
     111          $product_data['discount'] = (1 - (floatval($product['total']) / floatval($product['subtotal']))) * 100;
    111112          $product_data['price'] = floatval($product['subtotal']) / $product['quantity'];
    112113        }
     
    131132
    132133        if($tax_amount > 0) {
    133           $taxes = $item_data->get_taxes();
     134          $taxes = $item_shipping->get_taxes();
    134135          $tax_rate_id = key($taxes['subtotal']) ?? false;
    135136          $tax_rate_percentage = $tax_items_rates[$tax_rate_id] ?? false;
     
    157158        $tax_amount = floatval($fee['total_tax']);
    158159
    159         $tax_percent = ($tax_amount / $without_tax) * 100;
     160        $tax_percent = 0;
     161
     162        if($tax_amount > 0) {
     163          $taxes = $item_fee->get_taxes();
     164          $tax_rate_id = key($taxes['subtotal']) ?? false;
     165          $tax_rate_percentage = $tax_items_rates[$tax_rate_id] ?? false;
     166 
     167          $tax_percent = $tax_rate_percentage ?? ($tax_amount / $without_tax) * 100;
     168        }
    160169
    161170        $unit = 'fee';
     
    197206        "expectedTotalWithTax" => $order->get_total()
    198207      );
     208
     209      if($unitID != '') {
     210          $order_data['unitId'] = $unitID;
     211      }
     212
    199213      // if fiscalization is enabled and we making invoice, add the fiscalization data
    200214      if ($fiscalization && $type === 'invoice') {
     
    405419      return Spaceinvoices\Organizations::GetById($organization_id);
    406420    }
     421
     422    public static function getUnits() {
     423      $output = get_option('apollo_general_settings');
     424      $token = $output['apollo_token'];
     425      $organization_id = $output['apollo_organization-id'];
     426
     427      Spaceinvoices\Spaceinvoices::setAccessToken($token);
     428
     429      $units = ["" => "Brez"];
     430
     431      $apolloUnits = Spaceinvoices\Organizations::getUnits($organization_id);
     432
     433      foreach($apolloUnits as $apolloUnit) {
     434        $units[$apolloUnit->id] = $apolloUnit->name;
     435      }
     436
     437      return $units;
     438    }
    407439  }
    408440}
  • apollo/trunk/includes/admin/settings/general.php

    r2357549 r2414415  
    5858            $premises_data['premises'] = array();
    5959            $premises_data['devices'] = array();
     60            $units = Apollo_invoice::getUnits();
    6061
    6162            $output = get_option('apollo_general_settings');
    62       $token = $output['apollo_token'];
     63            $token = $output['apollo_token'];
    6364            $organization_id = $output['apollo_organization-id'];
    6465
     
    9899            // these are inputis inside sections
    99100            $settings = array(
    100         array(
    101                     'id'       => 'apollo-token', // filed id
    102                     'name'     => $this->prefix . 'token', // name attribute
    103                     'title'    => __( 'Apollo token', 'apollo-invoices' ), // text that shows left from input
    104                     'callback' => array( $this, 'input_callback' ), // callback to main-settings.php, input type depends on callback
    105                     'page'     => $this->settings_key,
    106                     'section'  => 'token', // one of the sections we defined on top
    107                     'type'     => 'text', // input type
    108                     'desc'     => '', // text that shows below the input
    109                     'default'  => '', // default value
    110         ),
    111         array(
     101                array(
     102                            'id'       => 'apollo-token', // filed id
     103                            'name'     => $this->prefix . 'token', // name attribute
     104                            'title'    => __( 'Apollo token', 'apollo-invoices' ), // text that shows left from input
     105                            'callback' => array( $this, 'input_callback' ), // callback to main-settings.php, input type depends on callback
     106                            'page'     => $this->settings_key,
     107                            'section'  => 'token', // one of the sections we defined on top
     108                            'type'     => 'text', // input type
     109                            'desc'     => '', // text that shows below the input
     110                            'default'  => '', // default value
     111                ),
     112                array(
    112113                    'id'       => 'apollo-organization-id',
    113114                    'name'     => $this->prefix . 'organization-id',
     
    119120                    'desc'     => '',
    120121                    'default'  => '',
     122                ),
     123                array(
     124                    'id'       => 'apollo-unit-id',
     125                    'name'     => $this->prefix . 'unit-id',
     126                    'title'    => __( 'Unit', 'apollo-invoices' ),
     127                    'callback' => array( $this, 'select_callback' ),
     128                    'page'     => $this->settings_key,
     129                    'section'  => 'token',
     130                    'type'     => 'select',
     131                    'desc'     => '<div class="apollo-notes">' . __( 'Edit your units on the Apollo webpage.', 'apollo-invoices' ) . '</div>',
     132                    'options'  => !empty($units) ? $units : array(),
     133                    'default'  => '',
     134                    'class'    => !$valid_org ? 'hidden' : '',
    121135                ),
    122136                array(
  • apollo/trunk/readme.txt

    r2397152 r2414415  
    8585
    8686== Changelog ==
     87= 1.1.12 - November 7, 2020 =
     88
     89- Fixed: Cupon price calculating
     90- Added: Organization units setting
     91
    8792= 1.1.11 - October 10, 2020 =
    8893
  • apollo/trunk/vendor/spaceinvoices/vendor/space-invoices/space-invoices-php/lib/Organizations.php

    r2073222 r2414415  
    3636  }
    3737
     38   /**
     39   * @param string $organizationId  ID of Organization
     40   *
     41   * @return object Returns list of units
     42  */
     43  public static function getUnits($organizationId) {
     44    return parent::_GET("/".static::path."/".$organizationId."/units")->body;
     45  }
     46
    3847}
    3948?>
Note: See TracChangeset for help on using the changeset viewer.