Plugin Directory

Changeset 3042613


Ignore:
Timestamp:
02/28/2024 01:46:13 PM (2 years ago)
Author:
primersoftware
Message:

Update

Location:
primer-mydata
Files:
2154 added
10 edited

Legend:

Unmodified
Added
Removed
  • primer-mydata/trunk/README.txt

    r3034761 r3042613  
    55Tested up to: 6.4.3
    66Requires PHP: 7.4
    7 Stable tag: 4.1.4
     7Stable tag: 4.1.5
    88License: GPLv2
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7474== Changelog ==
    7575
     76= 4.1.5 - 2024-02-28 =
     77* Fixed a bug with tax percentage taken from order
    7678= 4.1.4 - 2024-02-12 =
    7779* Minor Bug Fixes
  • primer-mydata/trunk/admin/class-primer-admin.php

    r3022529 r3042613  
    588588        }
    589589
    590         if ( email_exists( sanitize_email($_POST['billing_email']) ) && ! is_user_logged_in() ) {
     590        /*if ( email_exists( sanitize_email($_POST['billing_email']) ) && ! is_user_logged_in() ) {
    591591            wc_add_notice( __('User already exists with the specified email, please log in or choose another email', 'primer'), 'error' );
    592         }
     592        } */
    593593    }
    594594
  • primer-mydata/trunk/admin/includes/my_data_json.php

    r3034761 r3042613  
    466466            $invoice_data['invoice'][0]['invoiceSummary']['totalOtherTaxesAmount'] = 0;
    467467            $invoice_data['invoice'][0]['invoiceSummary']['totalGrossValue'] = "0.02";
     468            $invoice_data['templateId'] = '1';
     469            return ($invoice_data);
    468470        } elseif ($general_settings['accept_zero_value_orders'] != 'on' && $zero_total_value == 0) {
    469471            $receipt_log_value .= __('AADE does not accept zero value orders please enable "Accept zero total value orders" option in general settings if you want to issue this order.', 'primer');
     
    495497                $subtotal_order_payment = $item_data->get_total();
    496498                $product_tax_class = $item_data->get_tax_class();
    497                 $taxes = WC_Tax::get_rates_for_tax_class($product_tax_class);
    498                 $tax_arr = json_decode(json_encode($taxes), true);
    499                 foreach ($tax_arr as $tax) {
    500                     if (!empty($tax['tax_rate_country']) && $tax['postcode_count'] != 0 && $tax['city_count'] != 0 && !empty($tax['tax_rate_state'])) {
    501                         if ($tax['tax_rate_country'] == $order_country && (in_array($order->get_billing_postcode(), $tax['postcode']) || in_array($order->get_shipping_postcode(), $tax['postcode'])) && (in_array(strtoupper($order->get_billing_city()), $tax['city']) || in_array(strtoupper($order->get_shipping_city()), $tax['city'])) && ($order->get_billing_state() == $tax['tax_rate_state'] || $order->get_shipping_state() == $tax['tax_rate_state'])) {
    502                             $inside_tax_rate = $tax['tax_rate'];
    503                             break;
    504                         }
    505                     } elseif (!empty($tax['tax_rate_country']) && $tax['postcode_count'] != 0 && $tax['city_count'] != 0) {
    506                         if ($tax['tax_rate_country'] == $order_country && (in_array($order->get_billing_postcode(), $tax['postcode']) || in_array($order->get_shipping_postcode(), $tax['postcode'])) && (in_array(strtoupper($order->get_billing_city()), $tax['city']) || in_array(strtoupper($order->get_shipping_city()), $tax['city']))) {
    507                             $inside_tax_rate = $tax['tax_rate'];
    508                             break;
    509                         }
    510                     } elseif (!empty($tax['tax_rate_country']) && $tax['postcode_count'] != 0) {
    511                         if ($tax['tax_rate_country'] == $order_country && (in_array($order->get_billing_postcode(), $tax['postcode']) || in_array($order->get_shipping_postcode(), $tax['postcode']))) {
    512                             $inside_tax_rate = $tax['tax_rate'];
    513                             break;
    514                         }
    515                     } elseif (!empty($tax['tax_rate_country'])) {
    516                         if ($tax['tax_rate_country'] == $order_country) {
    517                             $inside_tax_rate = $tax['tax_rate'];
    518                             break;
    519                         }
    520                     } elseif (empty($tax['tax_rate_country']) && $tax['postcode_count'] == 0 && $tax['city_count'] == 0 && empty($tax['tax_rate_state'])) {
    521                         if ($item_data->get_total_tax() != 0) {
    522                             $inside_tax_rate = $tax['tax_rate'];
    523                             break;
    524                         } else {
    525                             $inside_tax_rate = 0;
    526                         }
    527                     }
    528                 }
    529                 if (is_int($inside_tax_rate) || is_float($inside_tax_rate)) {
    530                     $inside_tax_rate = round($inside_tax_rate);
     499                $inside_tax_rate = "";
     500                $taxes = $item_data->get_taxes();
     501                foreach ($taxes['total'] as $tax_rate_id => $tax_amount) {
     502                    if ($tax_amount > 0) {
     503                        $tax_rate = WC_Tax::_get_tax_rate($tax_rate_id);
     504                        $inside_tax_rate = $tax_rate['tax_rate'];
     505                        break;
     506                    }
    531507                }
    532508                $outside_vat = '';
     
    690666            //implementation of shipping in json
    691667            if ($shipping_total > 0) {
     668                $shipping_tax_rate = '';
    692669                foreach ($order->get_items('tax') as $item_id => $item_tax) {
    693670                    $tax_data = $item_tax->get_data();
     
    697674                        }
    698675                    }
    699 
    700                     // Update $shipping_tax_rate only if the current tax rate is higher than the previous one
    701 
    702676                    $shipping_tax_rate = $tax_data['rate_percent'];
    703 
    704677                }
    705678                $vatCategory_shipping = '';
     
    755728                        }
    756729                    }
    757 
    758 
    759 
    760730                    if ($licenses['productKind'] == 'goods') {
    761731                        $invoice_data['invoice'][0]['invoiceDetails'][$item_count]['quantity'] = 1;
     
    791761                                $invoice_data['invoice'][0]['invoiceDetails'][$item_count]['vatExemptionCategory'] = 4;
    792762                            }
    793                         } //elseif ($country_out_of_eu == true ) {
    794                             //$invoice_data['invoice'][0]['invoiceDetails'][$item_count]['vatExemptionCategory'] = 4;
    795                         //}
     763                        }
    796764                    }
    797765                    if ($shipping_tax == 0 && in_array(16, $primer_license_data['wpModules']) && $order_vat_exemption_category == '') {
     
    806774                                $invoice_data['invoice'][0]['invoiceDetails'][$item_count]['vatExemptionCategory'] = 4;
    807775                            }
    808                         } //elseif ($country_out_of_eu == true ) {
    809                             //$invoice_data['invoice'][0]['invoiceDetails'][$item_count]['vatExemptionCategory'] = 4;
    810                         //}
     776                        }
    811777                    }
    812778                } else {
     
    837803                            $invoice_data['invoice'][0]['invoiceDetails'][$item_count]['vatExemptionCategory'] = 4;
    838804                        }
    839                     } //elseif ($country_out_of_eu == true ) {
    840                         //$invoice_data['invoice'][0]['invoiceDetails'][$item_count]['vatExemptionCategory'] = 4;
    841                    // }
     805                    }
    842806                    $total_sub_shipping = $subtotal;
    843807                    $subtotal = $subtotal + $shipping_total;
     
    853817                if (in_array(14, $primer_license_data['wpModules'])) {
    854818                    foreach ($order->get_items('fee') as $item_id => $item_fee) {
    855                         // The fee total amount
    856819                        $fee_total = $item_fee->get_total();
    857                         // The fee total tax amount
    858820                        $fee_total_tax = $item_fee->get_total_tax();
    859821                        $fee_net_value = $fee_total;
    860                         $fee_tax_rate = round($item_fee->get_total_tax() / $item_fee->get_total(), 2) * 100;
     822                        $taxes = $item_fee->get_taxes();
     823                        foreach ($taxes['total'] as $tax_rate_id => $tax_amount) {
     824                            if ($tax_amount > 0) {
     825                                $tax_rate = WC_Tax::_get_tax_rate($tax_rate_id);
     826                                $fee_tax_rate = $tax_rate['tax_rate'];
     827                                break;
     828                            }
     829                        }
    861830                        switch ($fee_tax_rate) {
    862831                            case "24":
     
    901870                            update_post_meta($receipt_log_id, 'receipt_log_error', $receipt_log_value);
    902871                        }
    903                         //$breaker = true;
    904872                        return "break"; //EDW EINAI TO TELEYTAIO BREAK
    905873                    }
     
    16481616                        }
    16491617                        $email_logs = '';
    1650                         if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes') {
     1618                        if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes' && $user_order_email != '' && $user_order_email != null) {
    16511619                            $mailResult = false;
    16521620                            if ($primer_smtp_type == 'wordpress_default') {
  • primer-mydata/trunk/admin/includes/primer-admin-options.php

    r3025280 r3042613  
    39233923                                            }
    39243924                                            $email_logs = '';
    3925                                             if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes') {
     3925                                            if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes' && $user_order_email != '' && $user_order_email != null) {
    39263926                                                $mailResult = false;
    39273927                                                $primer_smtp = PrimerSMTP::get_instance();
  • primer-mydata/trunk/admin/includes/primer-admin-receipt-table.php

    r3008952 r3042613  
    328328            $formatted_max_receipt_date = date('m/d/Y', $max_receipt_date);
    329329            ?>
     330            <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
     331            <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap-select.min.js"></script>
     332            <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/selectWoo.min.js"></script>
    330333            <script>
    331334                jQuery(document).ready(function ($) {
  • primer-mydata/trunk/admin/includes/primer-admin-table.php

    r3025280 r3042613  
    10391039                                    }
    10401040                                    $email_logs = '';
    1041                                     if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes') {
     1041                                    if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes' && $user_order_email != '' && $user_order_email != null) {
    10421042                                        $mailResult = false;
    10431043                                        $primer_smtp = PrimerSMTP::get_instance();
  • primer-mydata/trunk/includes/class-primer-cron.php

    r3025280 r3042613  
    11911191                                    }
    11921192                                    $email_logs = '';
    1193                                     if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes') {
     1193                                    if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes' && $user_order_email != '' && $user_order_email != null) {
    11941194                                        $primer_smtp = PrimerSMTP::get_instance();
    11951195                                        if (!empty($primer_smtp_options['email_from_name'])) {
     
    17431743                                        }
    17441744                                        $email_logs = '';
    1745                                         if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes') {
     1745                                        if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes' && $user_order_email != '' && $user_order_email != null) {
    17461746                                            $primer_smtp = PrimerSMTP::get_instance();
    17471747                                            if (!empty($primer_smtp_options['email_from_name'])) {
     
    17741774                                            }
    17751775                                            update_post_meta($post_id, 'exist_error_log', 'exist_log');
    1776                                         } else { // if (!empty($primer_automatically_send_file) && $primer_automatically_send_file === 'yes')
     1776                                        } else {
    17771777                                            if (!$primer_smtp->credentials_configured()) {
    17781778                                                $email_logs .= __('Configure your SMTP credentials', 'primer') . "\n";
  • primer-mydata/trunk/includes/class-primer.php

    r2985238 r3042613  
    195195        $this->loader->add_filter('woocommerce_checkout_fields', $plugin_admin, 'primer_remove_woocommerce_shipping_fields');
    196196        $this->loader->add_filter( 'default_checkout_shipping_country', $plugin_admin, 'primer_set_shipping_country' );
    197         $this->loader->add_action('woocommerce_checkout_process', $plugin_admin, 'primer_checkout_field_process');
    198197        $this->loader->add_filter('woocommerce_my_account_my_orders_actions', $plugin_admin, 'add_my_account_my_orders_custom_action', 10, 2 );
    199198        $this->loader->add_action('manage_shop_order_posts_custom_column', $plugin_admin, 'primer_icon_to_order_notes_column', 15, 1);
     
    215214            $this->loader->add_action( 'woocommerce_thankyou', $plugin_admin,'primer_checkout_save_user_meta' );
    216215            $this->loader->add_action( 'woocommerce_thankyou', $plugin_admin,'primer_checkout_create_user' );
     216            $this->loader->add_action('woocommerce_checkout_process', $plugin_admin, 'primer_checkout_field_process');
    217217            $this->loader->add_action( 'woocommerce_new_order', $plugin_admin, 'primer_checkout_save_user_meta', 10, 1 );
    218218            $this->loader->add_action( 'woocommerce_new_order', $plugin_admin, 'primer_checkout_create_user', 10, 1 );
     
    220220            remove_action( 'woocommerce_thankyou', array($plugin_admin, 'primer_checkout_save_user_meta') );
    221221            remove_action( 'woocommerce_new_order', array($plugin_admin, 'primer_checkout_save_user_meta') );
     222            remove_action('woocommerce_checkout_process',  array($plugin_admin, 'primer_checkout_field_process'));
    222223            remove_action( 'woocommerce_thankyou', array($plugin_admin, 'primer_checkout_create_user') );
    223224            remove_action( 'woocommerce_new_order', array($plugin_admin, 'primer_checkout_create_user') );
  • primer-mydata/trunk/includes/template-tags/primer-tags-display-modules.php

    r3034761 r3042613  
    410410        $issuer_product .= '<td><span class="item_unit_price">'.$regular_price.'</span></td>';
    411411        $product_tax_class = $item->get_tax_class();
    412 
    413         $taxes = WC_Tax::get_rates_for_tax_class( $product_tax_class );
    414 
    415         $tax_arr = json_decode(json_encode($taxes), true);
    416             foreach ( $tax_arr as $tax ) {
    417                 if(!empty($tax['tax_rate_country']) && $tax['postcode_count'] != 0 && $tax['city_count'] !=0 && !empty($tax['tax_rate_state'])){
    418                     if($tax['tax_rate_country'] == $order_country && (in_array($order->get_billing_postcode(),$tax['postcode']) || in_array($order->get_shipping_postcode(),$tax['postcode'])) && (in_array(strtoupper($order->get_billing_city()),$tax['city']) || in_array(strtoupper($order->get_shipping_city()),$tax['city'])) && ($order->get_billing_state() == $tax['tax_rate_state'] || $order->get_shipping_state() == $tax['tax_rate_state'])){
    419                         $inside_tax_rate = $tax['tax_rate'];
    420                         break;
    421                     }else{
    422                         continue;
    423                     }
    424                 }elseif(!empty($tax['tax_rate_country']) && $tax['postcode_count'] != 0 && $tax['city_count'] !=0){
    425                     if($tax['tax_rate_country'] == $order_country && (in_array($order->get_billing_postcode(),$tax['postcode']) || in_array($order->get_shipping_postcode(),$tax['postcode'])) && (in_array(strtoupper($order->get_billing_city()),$tax['city']) || in_array(strtoupper($order->get_shipping_city()),$tax['city']))){
    426                         $inside_tax_rate = $tax['tax_rate'];
    427                         break;
    428                     }else{
    429                         continue;
    430                     }
    431                 }elseif(!empty($tax['tax_rate_country']) && $tax['postcode_count'] != 0){
    432                     if($tax['tax_rate_country'] == $order_country && (in_array($order->get_billing_postcode(),$tax['postcode']) || in_array($order->get_shipping_postcode(),$tax['postcode']))){
    433                         $inside_tax_rate = $tax['tax_rate'];
    434                         break;
    435                     }else{
    436                         continue;
    437                     }
    438                 }elseif(!empty($tax['tax_rate_country'])){
    439                     if($tax['tax_rate_country'] == $order_country){
    440                         $inside_tax_rate = $tax['tax_rate'];
    441                         break;
    442                     }else{
    443                         continue;
    444                     }
    445                 }elseif(empty($tax['tax_rate_country']) &&  $tax['postcode_count'] == 0 && $tax['city_count'] ==0 && empty($tax['tax_rate_state'])){
    446                     if($item->get_total_tax() !=0){
    447                         $inside_tax_rate = $tax['tax_rate'];
    448                         break;
    449                     }else{
    450                         $inside_tax_rate = 0;
    451                     }
    452                 }
    453             }
     412        $inside_tax_rate = "";
     413        $taxes = $item->get_taxes();
     414        foreach ($taxes['total'] as $tax_rate_id => $tax_amount) {
     415            if ($tax_amount > 0) {
     416                $tax_rate = WC_Tax::_get_tax_rate($tax_rate_id);
     417                $inside_tax_rate = $tax_rate['tax_rate'];
     418                break;
     419            }
     420        }
    454421            if(is_int($inside_tax_rate) || is_float($inside_tax_rate)){
    455422                $inside_tax_rate = round($inside_tax_rate);
     
    13901357    $left_customer_info .= '</tr>';
    13911358
     1359    if ($find_invoice_in_slug == 'invoice') {
     1360        $profession = get_post_meta($order_id, '_billing_store', true);
     1361        $vat_number = get_post_meta($order_id, '_billing_vat', true);
     1362        $doy = get_post_meta($order_id, '_billing_doy', true);
     1363        $doy_value = primer_return_doy_args()[$doy];
     1364        if (empty($doy_value)) {
     1365            $doy_value = $doy;
     1366        }
     1367    } else {
     1368        $profession = '';
     1369        $vat_number = '';
     1370        $doy = '';
     1371        $doy_value = '';
     1372    }
     1373
     1374    $left_customer_info .= '<tr>';
     1375    if ($order_customer_country == 'GR') {
     1376        $left_customer_info .= '<td class="skin bold"><span> ΑΦΜ</span></td>';
     1377    } else {
     1378        $left_customer_info .= '<td class="skin bold"><span> VAT NUMBER</span></td>';
     1379    }
     1380    $left_customer_info .= '<td class="info_value"><span>: </span><span class="counterparty_vat">'.$vat_number.'</span></td>';
     1381    $left_customer_info .= '</tr>';
     1382
    13921383    $left_customer_info .= '<tr>';
    13931384    if ($order_customer_country == 'GR') {
     
    14051396    }
    14061397
    1407     if ($find_invoice_in_slug == 'invoice') {
    1408         $profession = get_post_meta($order_id, '_billing_store', true);
    1409         $vat_number = get_post_meta($order_id, '_billing_vat', true);
    1410         $doy = get_post_meta($order_id, '_billing_doy', true);
    1411         $doy_value = primer_return_doy_args()[$doy];
    1412         if (empty($doy_value)) {
    1413             $doy_value = $doy;
    1414         }
    1415     } else {
    1416         $profession = '';
    1417         $vat_number = '';
    1418         $doy = '';
    1419         $doy_value = '';
    1420     }
    1421 
    14221398    $left_customer_info .= '<tr>';
    14231399    if ($order_customer_country == 'GR') {
     
    14271403    }
    14281404    $left_customer_info .= '<td class="info_value"><span>: </span><span class="counterparty_activity">'.$profession.'</span></td>';
    1429     $left_customer_info .= '</tr>';
    1430 
    1431     $left_customer_info .= '<tr>';
    1432     if ($order_customer_country == 'GR') {
    1433         $left_customer_info .= '<td class="skin bold"><span> ΑΦΜ</span></td>';
    1434     } else {
    1435         $left_customer_info .= '<td class="skin bold"><span> VAT NUMBER</span></td>';
    1436     }
    1437     $left_customer_info .= '<td class="info_value"><span>: </span><span class="counterparty_vat">'.$vat_number.'</span></td>';
    14381405    $left_customer_info .= '</tr>';
    14391406
  • primer-mydata/trunk/primer.php

    r3034761 r3042613  
    1818 * Plugin URI:        primer.gr/plugin/
    1919 * Description:      Issue receipts and invoices with woocommerce.
    20  * Version:           4.1.4
     20 * Version:           4.1.5
    2121 * Author:            Primer Software
    2222 * Author URI:        primer.gr
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'PRIMER_VERSION', '4.1.4');
     38define( 'PRIMER_VERSION', '4.1.5');
    3939define( 'PRIMER_NAME', 'Primer MyData' );
    4040
Note: See TracChangeset for help on using the changeset viewer.