Plugin Directory

Changeset 3104457

Timestamp:
06/19/2024 10:05:22 AM (3 weeks ago)
Author:
bastho
Message:

Deploy stable branch - Merge branch 'master' into 'stable'

Location:
accounting-for-woocommerce/tags/stable
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • accounting-for-woocommerce/tags/stable/inc/export-refunds.php

    r2943758 r3104457  
    1 <?php if ( ! defined( 'ABSPATH' ) ) exit;
    2 
    3 /******ETAPE 3 : PREPARER L'EXPORT******/
     1<?php
     2if ( ! defined( 'ABSPATH' ) ) exit;
    43
    54function woocommerce_accounting_export_refunds_data() {
     
    7776        }
    7877        $order_args = apply_filters('woocommerce_accounting:export:get_orders_refunds_args', $order_args, $date_opt,  array( 'wc-completed' ), array($ts1, $ts2));
    79         $orders = get_posts($order_args);
     78        $orders = s($order_args);
    8079        do_action('woocommerce_accounting:export:launch', $orders);
    8180       
     
    338337                        $get_order = new WC_Order ( $order->ID );
    339338
    340                         /******************************************************************************/
    341                         /************************    Taxes for each order    **************************/
    342                         /******************************************************************************/
     339                        /**/
     340                        /**/
     341                        /**/
    343342
    344343                        $tax_applied_check = get_post_meta($order->ID,'_order_tax',true) + get_post_meta($order->ID,'_order_shipping_tax',true);
     
    377376                            $tax_line_amount = $order->income_tax;
    378377                        }
    379                         /******************************************************************************/
    380                         /**********     Add shipping method accounting account             ************/
    381                         /******************************************************************************/
     378                        /**/
     379                        /**/
     380                        /**/
    382381                        $order_shipping_methods = $get_order->get_shipping_methods( );
    383382                        foreach ($order_shipping_methods as $order_shipping_method){
     
    403402                            }
    404403                        }
    405                         /******************************************************************************/
    406                         /*************** Add products accounting codes and accounts *******************/
    407                         /******************************************************************************/
     404                        /**/
     405                        /**/
     406                        /**/
    408407                        $bef_tax = get_post_meta($order->ID,'_cart_discount',true);
    409408                        if ($prod_opt == "1" && $order->order_discount == 0) {
     
    436435                                    );
    437436                            }
    438                             /******************************************************************************/
    439                             /******************       Coupon amounts per product       ********************/
    440                             /******************************************************************************/
     437                            /**/
     438                            /**/
     439                            /**/
    441440                           
    442441                            //Coupons are considered as negative products
     
    452451                            }
    453452                        }
    454                         /******** Exceptionnal accounts ************/
     453                        /
    455454                        $exptcred_acc = get_option('woocommerce_accounting_generic_exptcred_accounting_account');
    456455                        $exptchar_acc = get_option('woocommerce_accounting_generic_exptchar_accounting_account');
  • accounting-for-woocommerce/tags/stable/inc/export.php

    r2943758 r3104457  
    1 <?php if ( ! defined( 'ABSPATH' ) ) exit;
     1<?php
     2if ( ! defined( 'ABSPATH' ) ) exit;
    23global $total_income;
    34global $total_outcome;
     
    3940    $coupon_col = sanitize_text_field($_POST['woocommerce_accounting_export_coupon_col']);
    4041    $coupon_opt = sanitize_text_field($_POST['woocommerce_accounting_export_coupon_opt']);
    41     $rounding_precision = sanitize_text_field($_POST['woocommerce_accounting_export_rounding_precision']);
     42    $rounding_precision = sanitize_text_field($_POST['woocommerce_accounting_export_rounding_precision']);
    4243
    4344    update_option( 'woocommerce_accounting_export_start_date',$ts1);
     
    6465    $order_status = get_option('woocommerce_accounting_status');
    6566
     67
     68
     69
     70
     71
     72
     73
     74
     75
    6676    $order_args = array(
    67         'posts_per_page' => -1,
    68         'post_type' => 'shop_order',
    69         'post_status' => $order_status,
     77        'limit' => -1,
     78        'status' => $order_status,
    7079        'orderby' => 'ID',
    7180        'order' => 'ASC',
    7281    );
    7382
    74     if ($date_opt == "1") {
    75         $order_args['meta_query'] = array(
    76             array(
    77                 'key' => '_completed_date',
    78                 'value' => array($ts1, $ts2),
    79                 'compare' => 'BETWEEN',
    80                 'type' => 'DATE',
    81             )
    82         );
     83    if(isset($date_options[$date_opt])){
     84        $order_args[$date_options[$date_opt]] = "{$ts1}...{$ts2}";
    8385    }
    84     elseif($date_opt == "0"){
    85         $order_args['date_query'] = array(
    86             array(
    87                 'before' => $ts2,
    88                 'after' => $ts1,
    89                 'inclusive' => true
    90             )
    91         );
    92     }
    93     elseif ($date_opt == "3") {
    94         $order_args['meta_query'] = array(
    95             array(
    96                 'key' => '_paid_date',
    97                 'value' => array($ts1, $ts2),
    98                 'compare' => 'BETWEEN',
    99                 'type' => 'DATE'
    100             )
    101         );
    102     }
     86
    10387    $order_args = apply_filters('woocommerce_accounting:export:get_orders_args', $order_args, $date_opt, $order_status, array($ts1, $ts2));
    104     $orders = get_posts($order_args);
     88    $orders = s($order_args);
    10589    do_action('woocommerce_accounting:export:launch', $orders);
    106 
    107 
    108     //Collecting datas
    109     if (!empty($orders)) {
     90    $compiledOrders = array();
     91
     92    if(!empty($orders)){
    11093        //Generic accounts
    11194        $csv_headers = get_option ('woocommerce_accounting_columns_headers');
     
    125108        $order_shipping_acc_list = get_option ('woocommerce_accounting_shipping_methods_accounting_account');
    126109        $pdfoptions = get_option('wpo_wcpdf_template_settings');
    127 
    128         foreach ($orders as $order) {
    129 
    130             if ($date_opt == "0") {
    131                 $order->piecedate =  get_post_field( 'post_date', $order->ID );
    132             }
    133             elseif ($date_opt == "1"){
    134                 $order->piecedate = get_post_meta($order->ID,'_completed_date',true);
    135             }
    136             elseif ($date_opt == "3"){
    137                 $order->piecedate = get_post_meta($order->ID,'_paid_date',true);
     110    }
     111
     112    foreach ($orders as $wcOrder)
     113    {
     114        $order = (object) array();
     115        $order->ID = $wcOrder->get_id();
     116        $order->status = $wcOrder->get_status();
     117        $order->date_created = $wcOrder->get_date_created();
     118        $order->date_completed = $wcOrder->get_date_completed();
     119        $order->date_paid = $wcOrder->get_date_paid();
     120
     121        if ($date_opt == "0") {
     122            $order->piecedate =  $order->date_created;
     123        }
     124        elseif ($date_opt == "1"){
     125            $order->piecedate = $order->date_completed;
     126        }
     127        elseif ($date_opt == "3"){
     128            $order->piecedate = $order->date_paid;
     129        }
     130        else {
     131            $invoice_date = $wcOrder->get_meta('_wcpdf_invoice_date_formatted', true);
     132            if (!empty($invoice_date)) {
     133                $order->piecedate = $invoice_date;
    138134            }
    139135            else {
    140                 $invoice_date = get_post_meta($order->ID,'_wcpdf_invoice_date_formatted',true);
    141                 if (!empty($invoice_date)) {
    142                     $order->piecedate = $invoice_date;
    143                 }
    144                 else {
    145                     $order->piecedate = get_post_field( 'post_date', $order->ID );
    146                 }
    147             }
    148             $order->original_date = $order->piecedate;
    149             // Test PDF Invoices and Packing slips activated
    150 
    151             if (class_exists('WPO_WCPDF')) {
    152 
    153                 $invoice_number_data = get_post_meta($order->ID,'_wcpdf_invoice_number_data');
    154                 $invoice_number = get_post_meta($order->ID,'_wcpdf_invoice_number',true);
    155                 $invoice_date = get_post_meta($order->ID,'_wcpdf_invoice_date',true);
    156 
    157                 //Invoice number presence test
    158                 if ( ( !empty ($invoice_number) ) && ( empty ($invoice_number_data) ) && $factnum_opt == 0 ){
    159                     //Creating invoices numbers
    160                     $prefix = $pdfoptions['invoice_number_formatting_prefix'];
    161                     $suffix = $pdfoptions['invoice_number_formatting_suffix'];
    162                     $padding = $pdfoptions['invoice_number_formatting_padding'];
    163 
    164                     $order_year = date_i18n( 'Y', strtotime( $order->piecedate ) );
    165                     $order_month = date_i18n( 'm', strtotime( $order->piecedate ) );
    166                     $order_day = date_i18n( 'd', strtotime( $order->piecedate ) );
    167                     $invoice_year = date_i18n( 'Y', $invoice_date );
    168                     $invoice_month = date_i18n( 'm', $invoice_date );
    169                     $invoice_day = date_i18n( 'd', $invoice_date );
    170 
    171                     $formats['prefix'] = isset($prefix)?$prefix:'';
    172                     $formats['suffix'] = isset($suffix)?$suffix:'';
    173                     $formats['padding'] = isset($padding)?$padding:'';
    174 
    175                     // Remplacement of invoices dates in invoices numbers
    176                     foreach ($formats as $key => $value) {
    177                         $value = str_replace('[order_year]', $order_year, $value);
    178                         $value = str_replace('[order_month]', $order_month, $value);
    179                         $value = str_replace('[order_day]', $order_day, $value);
    180                         $value = str_replace('[invoice_year]', $invoice_year, $value);
    181                         $value = str_replace('[invoice_month]', $invoice_month, $value);
    182                         $value = str_replace('[invoice_day]', $invoice_day, $value);
    183                         $formats[$key] = $value;
    184                     }
    185 
    186                     // Padding
    187                     if ( ctype_digit( (string)$formats['padding'] ) ) {
    188                         $invoice_number = sprintf('%0'.$formats['padding'].'d', $invoice_number);
    189                     }
    190                     $formatted_invoice_number = $formats['prefix'] . $invoice_number . $formats['suffix'] ;
    191 
    192                     //Invoice number OK
    193                     $order->number = $formatted_invoice_number;
    194                 }
    195                 else if ( ( !empty ($invoice_number) ) && $factnum_opt == 0 ){
    196                     $order->number = $invoice_number;
    197                 }
    198                 else {
    199                     $order->number = $order->ID;
    200                 }
    201 
    202                 //Invoice number not OK (order number)
    203 
     136                $order->piecedate = $wcOrder->get_date_created();
     137            }
     138        }
     139        $order->original_date = $order->piecedate;
     140
     141        $meta_order_tax = (float) $wcOrder->get_total_tax();
     142        $meta_order_shipping_tax = (float) intval($wcOrder->get_shipping_tax());
     143
     144        $order->outcome = round($wcOrder->get_total(), $rounding_precision);
     145        $order->income_tax = round($meta_order_tax > $small_number ?  $meta_order_tax : 0, $rounding_precision) + round($meta_order_shipping_tax > $small_number ?  $meta_order_shipping_tax : 0, $rounding_precision);
     146        $order->income_fdpht = round($wcOrder->get_total_shipping(), $rounding_precision);
     147        $order->income_prodht = ( ($order->outcome) - ( ($order->income_tax) + ($order->income_fdpht) ) );
     148        //WC pre 2.3 bug on coupons correcting to match legal statements
     149
     150        $order->order_discount = (int) $wcOrder->get_total_discount();
     151
     152        $order->gatewayid = $wcOrder->get_payment_method();
     153
     154        if (isset($wcOrder->bypass))
     155        {
     156            $order->bypass = $wcOrder->bypass;
     157        }
     158
     159        $order->number = $order->ID;
     160       
     161        //Customers exports options
     162        $order->account_cust = '';
     163        if ($cust_opt == "0") {
     164            $order->account_cust = $gen_account_cust;
     165        }
     166
     167        // Get the country only in label if prod by country
     168        if ($prod_opt == "2") {
     169            $country_label = get_post_meta($order->ID,'_shipping_country',true);
     170        }
     171        else {
     172            $country_label = "";
     173        }
     174        //Payment gateway indication in label
     175        if ($pay_opt == "1") {
     176            $pay_meth = substr(get_post_meta($order->ID,'_payment_method',true),0,1) . substr(get_post_meta($order->ID,'_payment_method',true), 3, 1) . substr(get_post_meta($order->ID,'_payment_method',true),-1) ;
     177            $order->lib = remove_accents (strtoupper($pay_meth) . ' ' .  get_option ('woocommerce_accounting_lib_prefix') . ' ' . strtoupper(get_post_meta($order->ID,'_billing_company',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_last_name',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_first_name',true)) . ' ' . $country_label);
     178            $order->lib = trim($order->lib);
     179        }
     180        elseif ($pay_opt == "2") {
     181            $order_pay_meth = get_post_meta($order->ID,'_payment_method',true);
     182            if (!empty (get_option('woocommerce_accounting_gateways_libs')[$order_pay_meth]['lib'])) {
     183                $listed_pay_lib = get_option('woocommerce_accounting_gateways_libs')[$order_pay_meth]['lib'];
     184                $pay_meth = $listed_pay_lib;
    204185            }
    205186            else {
    206                 $order->number = $order->ID;
    207             }
    208 
    209             //Customers exports options
    210             $order->account_cust = '';
    211             if ($cust_opt =="0") {
    212                   $order->account_cust = $gen_account_cust;
    213             }
    214             elseif ($cust_opt =="1"){
    215                 $order->gatewayid = get_post_meta($order->ID,'_payment_method',true);
    216                 if (!empty($order->gatewayid)) {
    217                     $order->gatewayid = get_post_meta($order->ID,'_payment_method',true);
    218                     $order_country_acc = get_option('woocommerce_accounting_gateways_libs');
    219                     $order->account_cust = (is_array($order_country_acc) && isset($order_country_acc[$order->gatewayid])) ? $order_country_acc[$order->gatewayid]['acc'] : '';
    220                 }
    221             }
    222 
    223 
    224             // Get the country only in label if prod by country
    225             if ($prod_opt == "2") {
    226                 $country_label = get_post_meta($order->ID,'_shipping_country',true);
    227             }
    228             else {
    229                 $country_label = "";
    230             }
    231             //Payment gateway indication in label
    232             if ($pay_opt == "1") {
    233187                $pay_meth = substr(get_post_meta($order->ID,'_payment_method',true),0,1) . substr(get_post_meta($order->ID,'_payment_method',true), 3, 1) . substr(get_post_meta($order->ID,'_payment_method',true),-1) ;
    234                 $order->lib = remove_accents (strtoupper($pay_meth) . ' ' .  get_option ('woocommerce_accounting_lib_prefix') . ' ' . strtoupper(get_post_meta($order->ID,'_billing_company',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_last_name',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_first_name',true)) . ' ' . $country_label);
    235                 $order->lib = trim($order->lib);
    236             }
    237             elseif ($pay_opt == "2") {
    238                 $order_pay_meth = get_post_meta($order->ID,'_payment_method',true);
    239                 if (!empty (get_option('woocommerce_accounting_gateways_libs')[$order_pay_meth]['lib'])) {
    240                     $listed_pay_lib = get_option('woocommerce_accounting_gateways_libs')[$order_pay_meth]['lib'];
    241                     $pay_meth = $listed_pay_lib;
    242                 }
    243                 else {
    244                     $pay_meth = substr(get_post_meta($order->ID,'_payment_method',true),0,1) . substr(get_post_meta($order->ID,'_payment_method',true), 3, 1) . substr(get_post_meta($order->ID,'_payment_method',true),-1) ;
    245                 };
    246                 $order->lib = remove_accents (strtoupper($pay_meth) . ' ' .  get_option ('woocommerce_accounting_lib_prefix') . ' ' . strtoupper(get_post_meta($order->ID,'_billing_company',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_last_name',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_first_name',true)) . ' ' . $country_label);
    247                 $order->lib = trim($order->lib);
    248             }
    249             else {
    250                 $order->lib = remove_accents (get_option ('woocommerce_accounting_lib_prefix') . ' ' . strtoupper(get_post_meta($order->ID,'_billing_company',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_last_name',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_first_name',true)) . ' ' . $country_label);
    251                 $order->lib = trim($order->lib);
    252             }
    253 
    254             if ( $factnum_opt == 1 ){
    255 
    256                 if  ( (!empty ($invoice_number) ) && ( empty ($invoice_number_data) ) ) {
    257                     //Creating invoices numbers
    258                     $prefix = $pdfoptions['invoice_number_formatting_prefix'];
    259                     $suffix = $pdfoptions['invoice_number_formatting_suffix'];
    260                     $padding = $pdfoptions['invoice_number_formatting_padding'];
    261 
    262                     $order_year = date_i18n( 'Y', strtotime( $order->piecedate ) );
    263                     $order_month = date_i18n( 'm', strtotime( $order->piecedate ) );
    264                     $order_day = date_i18n( 'd', strtotime( $order->piecedate ) );
    265                     $invoice_year = date_i18n( 'Y', strtotime( $invoice_date ) );
    266                     $invoice_month = date_i18n( 'm', strtotime( $invoice_date ) );
    267                     $invoice_day = date_i18n( 'd', strtotime( $invoice_date ) );
    268 
    269 
    270                     $formats['prefix'] = isset($prefix)?$prefix:'';
    271                     $formats['suffix'] = isset($suffix)?$suffix:'';
    272                     $formats['padding'] = isset($padding)?$padding:'';
    273 
    274                     // Invoices dates replacements in invoices
    275                     foreach ($formats as $key => $value) {
    276                         $value = str_replace('[order_year]', $order_year, $value);
    277                         $value = str_replace('[order_month]', $order_month, $value);
    278                         $value = str_replace('[order_day]', $order_day, $value);
    279                         $value = str_replace('[invoice_year]', $invoice_year, $value);
    280                         $value = str_replace('[invoice_month]', $invoice_month, $value);
    281                         $value = str_replace('[invoice_day]', $invoice_day, $value);
    282                         $formats[$key] = $value;
    283                     }
    284 
    285                     // Padding
    286                     if ( ctype_digit( (string)$formats['padding'] ) && $formats['padding'] > 3 ) {
    287                         $invoice_number = sprintf('%0'.$formats['padding'].'d', $invoice_number);
    288                     }
    289                     $formatted_invoice_number = $formats['prefix'] . $invoice_number . $formats['suffix'] ;
    290                 }
    291                 elseif ( !empty ($invoice_number)  ) {
    292                     $formatted_invoice_number = $invoice_number;
    293                 }
    294 
    295                 if (isset($formatted_invoice_number)){
    296                     $order->lib = $formatted_invoice_number . ' ' . $order->lib;
    297                 }
    298 
    299             }
    300 
    301 
    302             //Date Format
    303             $order->piecedate = woocommerce_accounting_date_format($order->piecedate, $date_format_opt);
    304             $order->date_format_opt = $date_format_opt;
    305 
    306             $meta_order_tax = (float) get_post_meta($order->ID, '_order_tax', true, 0);
    307             $meta_order_shipping_tax = (float) get_post_meta($order->ID, '_order_shipping_tax', true, 0);
    308 
    309             $order->outcome = round(get_post_meta($order->ID,'_order_total',true), $rounding_precision);
    310             $order->income_tax = round($meta_order_tax > $small_number ?  $meta_order_tax : 0, $rounding_precision) + round($meta_order_shipping_tax > $small_number ?  $meta_order_shipping_tax : 0, $rounding_precision);
    311             $order->income_fdpht = round(get_post_meta($order->ID, '_order_shipping',true), $rounding_precision);
    312             $order->income_prodht = ( ($order->outcome) - ( ($order->income_tax) + ($order->income_fdpht) ) );
    313             //WC pre 2.3 bug on coupons correcting to match legal statements
    314 
    315             $order->order_discount = (int) get_post_meta($order->ID, '_order_discount',true);
    316 
    317             if ($order->order_discount > 0) {
    318                 $order->order_ex_discount = $order->order_discount + $order->outcome;
    319 
    320                 //Calculating
    321                 $order->prodht_exdisc = $order->order_ex_discount - $order->income_tax - $order->income_fdpht ;
    322                 //Shipment
    323                 $quotient_fdp = $order->income_fdpht / $order->order_ex_discount;
    324                 //Products
    325                 $quotient_prod = $order->prodht_exdisc / $order->order_ex_discount;
    326                 //Taxes
    327                 $quotient_tax = $order->income_tax / $order->order_ex_discount;
    328                 //Recalculate the right amounts
    329                 //Products
    330                 $order->income_prodht = $order->outcome * $quotient_prod ;
    331                 //Shipment
    332                 $order->income_fdpht = $order->outcome * $quotient_fdp ;
    333                 //Taxes
    334                 $order->income_tax = $order->outcome * $quotient_tax;
    335             }
    336 
    337             do_action_ref_array('woocommerce_accounting:export:order_values', array(&$order));
    338         } // End foreach
    339 
     188            };
     189            $order->lib = remove_accents (strtoupper($pay_meth) . ' ' .  get_option ('woocommerce_accounting_lib_prefix') . ' ' . strtoupper(get_post_meta($order->ID,'_billing_company',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_last_name',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_first_name',true)) . ' ' . $country_label);
     190            $order->lib = trim($order->lib);
     191        }
     192        else {
     193            $order->lib = remove_accents (get_option ('woocommerce_accounting_lib_prefix') . ' ' . strtoupper(get_post_meta($order->ID,'_billing_company',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_last_name',true)) . ' ' . ucfirst(get_post_meta($order->ID,'_billing_first_name',true)) . ' ' . $country_label);
     194            $order->lib = trim($order->lib);
     195        }
     196
     197        if ( $factnum_opt == 1 ){
     198
     199            if  ( (!empty ($invoice_number) ) && ( empty ($invoice_number_data) ) ) {
     200                //Creating invoices numbers
     201                $prefix = $pdfoptions['invoice_number_formatting_prefix'];
     202                $suffix = $pdfoptions['invoice_number_formatting_suffix'];
     203                $padding = $pdfoptions['invoice_number_formatting_padding'];
     204
     205                $order_year = date_i18n( 'Y', strtotime( $order->piecedate ) );
     206                $order_month = date_i18n( 'm', strtotime( $order->piecedate ) );
     207                $order_day = date_i18n( 'd', strtotime( $order->piecedate ) );
     208                $invoice_year = date_i18n( 'Y', strtotime( $invoice_date ) );
     209                $invoice_month = date_i18n( 'm', strtotime( $invoice_date ) );
     210                $invoice_day = date_i18n( 'd', strtotime( $invoice_date ) );
     211
     212
     213                $formats['prefix'] = isset($prefix)?$prefix:'';
     214                $formats['suffix'] = isset($suffix)?$suffix:'';
     215                $formats['padding'] = isset($padding)?$padding:'';
     216
     217                // Invoices dates replacements in invoices
     218                foreach ($formats as $key => $value) {
     219                    $value = str_replace('[order_year]', $order_year, $value);
     220                    $value = str_replace('[order_month]', $order_month, $value);
     221                    $value = str_replace('[order_day]', $order_day, $value);
     222                    $value = str_replace('[invoice_year]', $invoice_year, $value);
     223                    $value = str_replace('[invoice_month]', $invoice_month, $value);
     224                    $value = str_replace('[invoice_day]', $invoice_day, $value);
     225                    $formats[$key] = $value;
     226                }
     227
     228                // Padding
     229                if ( ctype_digit( (string)$formats['padding'] ) && $formats['padding'] > 3 ) {
     230                    $invoice_number = sprintf('%0'.$formats['padding'].'d', $invoice_number);
     231                }
     232                $formatted_invoice_number = $formats['prefix'] . $invoice_number . $formats['suffix'] ;
     233            }
     234            elseif ( !empty ($invoice_number)  ) {
     235                $formatted_invoice_number = $invoice_number;
     236            }
     237
     238            if (isset($formatted_invoice_number)){
     239                $order->lib = $formatted_invoice_number . ' ' . $order->lib;
     240            }
     241        }
     242
     243        //Date Format
     244        $order->piecedate = woocommerce_accounting_date_format($order->piecedate, $date_format_opt);
     245        $order->date_format_opt = $date_format_opt;
     246
     247        if ($order->order_discount > 0) {
     248            $order->order_ex_discount = $order->order_discount + $order->outcome;
     249
     250            //Calculating
     251            $order->prodht_exdisc = $order->order_ex_discount - $order->income_tax - $order->income_fdpht ;
     252            //Shipment
     253            $quotient_fdp = $order->income_fdpht / $order->order_ex_discount;
     254            //Products
     255            $quotient_prod = $order->prodht_exdisc / $order->order_ex_discount;
     256            //Taxes
     257            $quotient_tax = $order->income_tax / $order->order_ex_discount;
     258            //Recalculate the right amounts
     259            //Products
     260            $order->income_prodht = $order->outcome * $quotient_prod ;
     261            //Shipment
     262            $order->income_fdpht = $order->outcome * $quotient_fdp ;
     263            //Taxes
     264            $order->income_tax = $order->outcome * $quotient_tax;
     265        }
     266
     267
     268        $order = apply_filters('woocommerce_accounting:export:order', $order, $wcOrder);
     269        do_action_ref_array('woocommerce_accounting:export:order_values', array(&$order));
     270
     271        $compiledOrders[] = $order;
     272    }
     273
     274    //Collecting datas
     275    if (!empty($orders)) {
    340276        $output = fopen("php://output",'w') or die ("Can't open php://output");
    341277        //CSV Headers
     
    394330        do_action_ref_array('woocommerce_accounting:export:after_headline', array(&$output, $col_map, $separator));
    395331
    396         foreach($orders as $order) {
     332        foreach($rders as $order) {
    397333            $total_income = 0;
    398334            $total_outcome = 0;
     
    413349                $book_code = $original_book_code;
    414350            }
    415             /******************************************************************************/
    416             /************************ Ajout des taxes spécifiques **************************/
    417             /******************************************************************************/
     351            /**/
     352            /**/
     353            /**/
    418354
    419355            $meta_order_tax = (float) get_post_meta($order->ID,'_order_tax',true, 0);
     
    455391                $tax_line_amount = $order->income_tax;
    456392            }
    457 
    458             /******************************************************************************/
    459             /********** Ajout des comptes comptables des méthodes d'expédition ************/
    460             /******************************************************************************/
     393           
     394            /**/
     395            /**/
     396            /**/
    461397
    462398            $order_shipping_methods = $get_order->get_shipping_methods( );
     
    486422                }
    487423            }
    488 
    489             /******************************************************************************/
    490             /*************** Ajout des comptes comptables par produits. *******************/
    491             /******************************************************************************/
     424            /*-----------------------------------------------------------------------------*/
     425            /*--------------- Ajout des comptes comptables par produits -------------------*/
     426            /*-----------------------------------------------------------------------------*/
    492427            $bef_tax = get_post_meta($order->ID,'_cart_discount',true);
    493428            if ($prod_opt == "1" && $order->order_discount == 0) {
     
    522457                }
    523458
    524                 /******************************************************************************/
    525                 /****************** Calcul des bons montants si code promo ********************/
    526                 /******************************************************************************/
    527 
     459                /*-----------------------------------------------------------------------------*/
     460                /*------------------ alcul des bons montants si code promo --------------------*/
     461                /*-----------------------------------------------------------------------------*/
    528462                //On choisit de faire apparaitre les codes promos comme des produits négatifs
    529463                //Appliqué avant taxe (réduction et Code Promo) on raisonne en HT
     
    541475            }
    542476
    543             /******** add exceptionnal income or outcome accounts ************/
     477            /
    544478            $exptcred_acc = get_option('woocommerce_accounting_generic_exptcred_accounting_account');
    545479            $exptchar_acc = get_option('woocommerce_accounting_generic_exptchar_accounting_account');
     
    844778        }
    845779
    846         do_action_ref_array('woocommerce_accounting:export:before_close', array(&$output, $orders, $separator));
     780        do_action_ref_array('woocommerce_accounting:export:before_close', array(&$output, $rders, $separator));
    847781        fclose($output) or die("Can't close php://output");
    848782        exit;
  • accounting-for-woocommerce/tags/stable/inc/settings.php

    r2943758 r3104457  
    1717/**
    1818 * Add help tab in settings
     19
    1920 * @return void
    2021 */
     
    3738/**
    3839 * Get default columns
    39  * @see `woocommerce_accounting_columns` filter
     40 *
     41 * @see `woocommerce_accounting_columns`filter
     42 *
    4043 * @return array
    4144 */
     
    5962/**
    6063 * Get default column mapping
     64
    6165 * @see `woocommerce_accounting_default_col_mapping` filter
     66
    6267 * @return [type] [description]
    6368 */
     
    6873/**
    6974 * Parse column order settings and clean it up.
    70  * @param  array $color_order
     75 *
     76 * @param array $color_order
     77 *
    7178 * @return array
    7279 */
     
    8794 * Add Accounting tab to the settings page.
    8895 *
    89  * @uses `woocommerce_settings_tabs_array` filter
    9096 * @param array $setting_tabs The setting tabs array
     97
     98
     99
    91100 * @return array $setting_tabs The setting tabs array
    92101 */
     
    98107/**
    99108 * Returns an array of associated sections/settings
    100  * @see `woocommerce_accounting_section_settings` filter
     109 *
     110 * @see woocommerce_accounting_section_settings` filter
     111 *
    101112 * @return array of sections / settings
    102113 */
     
    180191/**
    181192 * Displays settings form
    182  * @see `woocommerce_accounting_setting_template` filter
     193 *
     194 * @see woocommerce_accounting_setting_template filter
     195 *
    183196 * @return void
    184197 */
     
    197210/**
    198211 * Gets current setting(s)
    199  * @param  string $section
     212 *
     213 * @param string $section
     214 *
    200215 * @return mixed string or array
    201216 */
     
    216231/**
    217232 * Register hooks
     233
    218234 * @return void
    219235 */
     
    227243/**
    228244 * Register settings
     245
    229246 * @return void
    230247 */
     
    239256/**
    240257 * Recursive sanitization for an array
     258
    241259 * @param array|string $array
     260
    242261 * @return mixed array|string
    243262 */
  • accounting-for-woocommerce/tags/stable/inc/utils.php

    r2943758 r3104457  
    1313/**
    1414 * Format number for export
     15
    1516 * @var $number float
     17
    1618 * @return string
    1719 */
     
    3133/**
    3234 * Unformat number for export
     35
    3336 * @var $number float
     37
    3438 * @return float
    3539 */
  • accounting-for-woocommerce/tags/stable/readme.txt

    r2943758 r3104457  
    22
    33Contributors: bastho, leroysabrina, enzomangiante, agencenous 
    4 Tags: woocommerce, accounting, bookkeeping, vat, export, orders, money, bank 
     4Tags: woocommerce, accounting, bookkeeping, vat, export
    55Requires at least: 5.3 
    66Requires PHP: 7.4 
    7 Tested up to: 6.2 
    8 Stable tag: 1.6.2 
     7Tested up to: 6. 
     8Stable tag: 1.6. 
    99License: GPLv2 
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6767At this time, exports have been tested on Cogilog and GnuCash.
    6868## Changelog
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
    6981
    7082### 1.6.2
  • accounting-for-woocommerce/tags/stable/views/export-basic.php

    r2943758 r3104457  
    244244    </table>
    245245    </details>
     246
    246247    <?php echo apply_filters('woocommerce_accounting:export_form:pro_features', '<p>'.sprintf(__('More options available with the <a href="%s" target="_blank">pro addon</a>.', 'accounting-for-woocommerce'), 'https://apps.avecnous.eu/produit/woocommerce-accounting/?mtm_campaign=wp-plugin&mtm_kwd=accounting-for-woocommerce').'</p>'); ?>
    247248    <?php do_action('woocommerce_accounting:export_form:before_submit'); ?>
  • accounting-for-woocommerce/tags/stable/views/settings-accounting-general.php

    r2943758 r3104457  
    195195<ul name="woocommerce_accounting_colorder_col" id="woocommerce_accounting_colorder_col"/>
    196196<?php foreach ($maps as $key => $map): ?>
    197     <li id="<?php esc_attr_e($key); ?>">
     197    <li id="<?php e($key); ?>">
    198198        <span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
    199199        <input type="text" name="woocommerce_accounting_colorder[<?php echo esc_attr($key); ?>]" value="<?php echo esc_attr($map); ?>" class="woocommerce_accounting_colorder">
     
    233233    }
    234234</style>
     235
    235236<?php echo apply_filters('woocommerce_accounting:export_form:pro_features', '<p>'.sprintf(__('More options available with the <a href="%s" target="_blank">pro addon</a>.', 'accounting-for-woocommerce'), 'https://apps.avecnous.eu/produit/woocommerce-accounting/?mtm_campaign=wp-plugin&mtm_kwd=accounting-for-woocommerce').'</p>'); ?>
  • accounting-for-woocommerce/tags/stable/woocommerce-accounting.php

    r2943758 r3104457  
    66Author: N.O.U.S. Open Useful and Simple
    77Author URI: https://apps.avecnous.eu/?mtm_campaign=wp-plugin&mtm_kwd=accounting-for-woocommerce&mtm_medium=dashboard&mtm_source=author
    8 Version: 1.6.2
     8Version: 1.6.
    99*/
    1010if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
     
    5555/**
    5656 * Create the admin pages links
     57
    5758 * @return void
    5859 */
     
    6465/**
    6566 * Enqueue scripts and style
     67
    6668 * @return [type] [description]
    6769 */
     
    7577/**
    7678 * Displays export page
     79
    7780 * @return void
    7881 */
     
    8790/**
    8891 * Displays refund export page
     92
    8993 * @return void
    9094 */
     
    100104 * Called at plugin install.
    101105 * Create default options
     106
    102107 * @return void
    103108 */
     
    144149
    145150/**
    146  *  Settings link on the plugins page
     151 * Settings link on the plugins page
     152 *
     153 * @param array $plugin_links
    147154 */
    148155function woocommerce_accounting_plugin_settings_link( $plugin_links ) {
     
    156163/**
    157164 * Add settings link in the plugins list
     165
     166
     167
     168
     169
     170
    158171 * @see `woocommerce_accounting:export_form:pro_features` filter
    159  * @param  array $plugin_meta
    160  * @param  string $plugin_file
    161  * @param  array $plugin_data
    162  * @param  string $status
     172 *
    163173 * @return array
    164174 */
     
    175185/**
    176186 * [woocommerce_accounting_date_format description]
    177  * @param  string $date
    178  * @param  integer $format
     187 *
     188 * @param string $date
     189 * @param integer $format
     190 *
    179191 * @return string
    180192 */
Note: See TracChangeset for help on using the changeset viewer.