Plugin Directory

Changeset 2393793


Ignore:
Timestamp:
10/05/2020 05:50:23 PM (5 years ago)
Author:
perseosoftware
Message:

Actualizacion porcentajes impuestos

Location:
perseo-software
Files:
13 added
3 edited

Legend:

Unmodified
Added
Removed
  • perseo-software/trunk/PluginPerseo.php

    r2391793 r2393793  
    44Plugin URI: http://perseo.ec/
    55Description: Este Plugins integra el Sistema Contable Perseo Web y PC con la tienda Woocommerce
    6 Version: 10.0
     6Version: 11.0
    77Author: Pegasus Soft S.A. - Ecuador
    88Author URI: https://perseo.ec
     
    472472   
    473473    $perseo_html = "<select  class='{$args['class']}'  data-custom='{$args['perseo_datopersonalizado']}' name='pluginperseo_parametros[{$args['label_for']}]' >
     474    <option value='NO' ".$perseo_refr2." >NO</option>
    474475    <option value='SI' ".$perseo_refr1." >SI</option>
    475     <option value='NO' ".$perseo_refr2." >NO</option>
     476   
    476477    </select >";
    477478    echo $perseo_html;
     
    487488   
    488489    $perseo_html = "<select  class='{$args['class']}'  data-custom='{$args['perseo_datopersonalizado']}' name='pluginperseo_parametros[{$args['label_for']}]' >
     490    <option value='NO' ".$perseo_refr2." >NO</option>
    489491    <option value='SI' ".$perseo_refr1." >SI</option>
    490     <option value='NO' ".$perseo_refr2." >NO</option>
     492   
    491493    </select >";
    492494    echo $perseo_html;
     
    503505   
    504506    $perseo_html = "<select  class='{$args['class']}'  data-custom='{$args['perseo_datopersonalizado']}' name='pluginperseo_parametros[{$args['label_for']}]' >
     507    <option value='NO' ".$perseo_refr2." >NO</option>
    505508    <option value='SI' ".$perseo_refr1." >SI</option>
    506     <option value='NO' ".$perseo_refr2." >NO</option>
     509   
    507510    </select >";
    508511    echo $perseo_html;
     
    518521   
    519522    $perseo_html = "<select  class='{$args['class']}'  data-custom='{$args['perseo_datopersonalizado']}' name='pluginperseo_parametros[{$args['label_for']}]' >
     523    <option value='NO' ".$perseo_refr2." >NO</option>
    520524    <option value='SI' ".$perseo_refr1." >SI</option>
    521     <option value='NO' ".$perseo_refr2." >NO</option>
     525   
    522526    </select >";
    523527    echo $perseo_html;
     
    534538   
    535539    $perseo_html = "<select  class='{$args['class']}'  data-custom='{$args['perseo_datopersonalizado']}' name='pluginperseo_parametros[{$args['label_for']}]' >
     540    <option value='NO' ".$perseo_refr2." >NO</option>
    536541    <option value='SI' ".$perseo_refr1." >SI</option>
    537     <option value='NO' ".$perseo_refr2." >NO</option>
     542   
    538543    </select >";
    539544    echo $perseo_html;
     
    550555   
    551556    $perseo_html = "<select  class='{$args['class']}'  data-custom='{$args['perseo_datopersonalizado']}' name='pluginperseo_parametros[{$args['label_for']}]' >
     557    <option value='NO' ".$perseo_refr2." >NO</option>
    552558    <option value='SI' ".$perseo_refr1." >SI</option>
    553     <option value='NO' ".$perseo_refr2." >NO</option>
     559   
    554560    </select >";
    555561    echo $perseo_html;
     
    588594   
    589595    $perseo_html = "<select  class='{$args['class']}'  data-custom='{$args['perseo_datopersonalizado']}' name='pluginperseo_parametros[{$args['label_for']}]' >
     596    <option value='NO' ".$perseo_refr2." >NO</option>
    590597    <option value='SI' ".$perseo_refr1." >SI</option>
    591     <option value='NO' ".$perseo_refr2." >NO</option>
     598   
    592599    </select >";
    593600    echo $perseo_html;
  • perseo-software/trunk/README.md

    r2391793 r2393793  
    4949
    5050== Changelog ==
     51
     52= 11.0 =
     53* Actualizacion .
     54
    5155= 10.0 =
    5256* Actualizacion .
  • perseo-software/trunk/includes/PluginPerseo_cron.php

    r2393033 r2393793  
    468468
    469469    public function fperseo_producto(){
    470        
     470        //echo 'Memoria usada: ' . round(memory_get_usage() / 1024,1) . ' KB de ' . round(memory_get_usage(1) / 1024,1) . ' KB';
    471471
    472472        global $wpdb;       
     
    519519                    {
    520520                        ///variables actualizacion
    521                         //$ConsultaProductoUpd="";
    522                         //$ConsultaProductofecha="";
    523                         //$ConsultaProductoUpd=$wpdb->get_var("SELECT meta.post_id FROM {$table_prefix}posts posts, {$table_prefix}postmeta meta where posts.ID=meta.post_id  and meta.meta_value='".$producto['productosid']."'");
    524                         $ConsultaProductoUpd=$wpdb->get_var("SELECT post_id FROM {$table_prefix}postmeta where meta_key = 'PERSEOID' and meta_value =".$producto['productosid']);
     521                         $ConsultaProductoUpd=$wpdb->get_var("SELECT post_id FROM {$table_prefix}postmeta where meta_key = 'PERSEOID' and meta_value =".$producto['productosid']);
    525522                       
    526                         //echo "<br>";
    527                         //var_dump($ConsultaProductoUpd);
    528                         //echo "<br>";
    529 
     523                       
    530524                        if(empty($ConsultaProductoUpd)){
    531525                           // echo "PRODUCTO NUEVO";   
     
    564558                                                    )
    565559                                    );
    566                                     //////////////////////////////////////////
     560                                    ///////////////////////////////////////////////////////
    567561                                    //Consultamos id ultimo
    568562                                    $sqlProdID= "SELECT MAX(ID) FROM {$table_prefix}posts  ";
    569563                                    $resProdPerseo = $wpdb->get_var($sqlProdID); 
    570564                                    $idPost=$resProdPerseo;
    571                                     //echo $idPost;
    572                                     //echo '<br>';
     565                                    ///////////////////////////////////////////////////////
    573566                                    ///actualizamos
    574567                                    $wpdb->update($table_prefix.'posts',array( 'guid'=> home_url().'/?post_type=product&#038;p='.$idPost.''), array('ID' => $idPost));
     
    581574                                                ///saber si tiene IVA 12 % o 0%
    582575                                                if ($producto['porcentajeiva']=='12'){                                                   
    583                                                 $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_tax_status', 'meta_value'=> 'taxable') );
     576                                                    $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_tax_status', 'meta_value'=> 'taxable') );
    584577                                                } else {                                                   
    585                                                 $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_tax_status', 'meta_value'=> 'none') );
     578                                                    $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_tax_status', 'meta_value'=> 'none') );
    586579                                                };
    587580                                               
     
    633626                                    $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_purchase_note', 'meta_value'=> '') ); //nose
    634627                                   
    635                                     ///////////////////////////////////////////////////
     628                                    //////////////////////////////////////////////////////////
    636629                                    //insertamos Nuevo producto TERCERA TABLA plugin_term_relationships
    637630                                    //verificamos q cargo si categoria o linea wp_term_relationships categoriasproductos_consulta
     
    659652                                   
    660653                                    /////////////////////////////////////////////////////
    661                                     //Saber el precio seleccionado
     654                                    //Saber el precio seleccionado                                      
    662655                                    foreach($producto['tarifas'] as $tarifa)
    663                                     {     
    664                                        
    665                                         //iva
    666                                         $perseo_iva=0;
     656                                    {         
     657                                       
    667658                                        //tarifa venta
    668659                                        $perseo_tarifaventa=0;
    669660                                        //tarifa aumento   
    670                                         $perseo_tarifaaumento=0   ;                                                    
     661                                        $perseo_tarifaaumento=0 ;                           
    671662                                                if (isset($tarifa))
    672663                                                {
    673                                                     $perseo_iva= ($producto['porcentajeiva']/100)+1;
     664                                                    //$perseo_iva= ($producto['porcentajeiva']/100)+1;
    674665                                                   
    675666                                                        if($perseo_parametros['perseotarifaVenta']==$tarifa['tarifasid'])
    676667                                                        {
    677                                                             //$perseo_tarifaventa=round($tarifa['precio'],2) * $perseo_iva;
    678668                                                            $perseo_tarifaventa=round($tarifa['precio'],2);
     669                                                            $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_price', 'meta_value'=> $perseo_tarifaventa )); //nose
     670                                                            $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_regular_price', 'meta_value'=> $perseo_tarifaventa ));
     671                                                            ///////////////////////////////////////////////////
     672                                                            //insertamos Nuevo producto CUARTA TABLA plugin_wc_product_meta_lookup
     673                                                            $wpdb->update($table_prefix.'wc_product_meta_lookup',
     674                                                                array(
     675                                                                    'product_id'    => $idPost,
     676                                                                    'sku'           => '0',
     677                                                                    'virtual'       => '0',
     678                                                                    'downloadable'  => '0',
     679                                                                    'min_price'     =>  0,
     680                                                                    'max_price'     =>  $perseo_tarifaventa,
     681                                                                    'onsale'        => '0',
     682                                                                    'stock_quantity'=> '',
     683                                                                    'stock_status'  => 'instock',
     684                                                                    'rating_count'  => '0',
     685                                                                    'average_rating'=> '0.00',
     686                                                                    'total_sales'   => '0',
     687                                                                    'tax_status'    => 'taxable',
     688                                                                    'tax_class'     => ''
     689                                                                    ) ,
     690                                                                array('product_id' => $idPost)
     691                                                                );
    679692                                                        };
    680693                                                            //precio 2
    681694                                                        if($perseo_parametros['perseotarifaAumento']==$tarifa['tarifasid'])
    682                                                         {
    683                                                             //$perseo_tarifaaumento =round($tarifa['precio'],2)* $perseo_iva;
     695                                                        {                                                         
    684696                                                            $perseo_tarifaaumento =round($tarifa['precio'],2);
    685                                                         }
    686 
    687                                                 $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_price', 'meta_value'=> $perseo_tarifaventa )); //nose
    688                                                 $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_regular_price', 'meta_value'=> $perseo_tarifaventa ));
    689                                                 $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_sale_price', 'meta_value'=> $perseo_tarifaaumento));
    690                                    
    691                                  
    692                                                    
     697                                                            $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $idPost, 'meta_key'  => '_sale_price', 'meta_value'=> $perseo_tarifaaumento));
     698                                                            ///////////////////////////////////////////////////
     699                                                            //insertamos Nuevo producto CUARTA TABLA plugin_wc_product_meta_lookup
     700                                                            $wpdb->update($table_prefix.'wc_product_meta_lookup',
     701                                                                array(
     702                                                                    'product_id'    => $idPost,
     703                                                                    'sku'           => '0',
     704                                                                    'virtual'       => '0',
     705                                                                    'downloadable'  => '0',
     706                                                                    'min_price'     =>  $perseo_tarifaaumento,
     707                                                                    'max_price'     =>  0,
     708                                                                    'onsale'        => '0',
     709                                                                    'stock_quantity'=> '',
     710                                                                    'stock_status'  => 'instock',
     711                                                                    'rating_count'  => '0',
     712                                                                    'average_rating'=> '0.00',
     713                                                                    'total_sales'   => '0',
     714                                                                    'tax_status'    => 'taxable',
     715                                                                    'tax_class'     => ''
     716                                                                    ) ,
     717                                                                array('product_id' => $idPost)
     718                                                                );
     719
     720                                                        }
    693721                                                };         
    694722                                    }
    695                                       ///////////////////////////////////////////////////
    696                                     //insertamos Nuevo producto CUARTA TABLA plugin_wc_product_meta_lookup
    697                                     $wpdb->insert($table_prefix.'wc_product_meta_lookup',
    698                                                 array(
    699                                                     'product_id'    => $idPost,
    700                                                     'sku'           => '0',
    701                                                     'virtual'       => '0',
    702                                                     'downloadable'  => '0',
    703                                                     'min_price'     =>  $perseo_tarifaaumento,
    704                                                     'max_price'     =>  $perseo_tarifaventa,
    705                                                     'onsale'        => '0',
    706                                                     'stock_quantity'=> '',
    707                                                     'stock_status'  => 'instock',
    708                                                     'rating_count'  => '0',
    709                                                     'average_rating'=> '0.00',
    710                                                     'total_sales'   => '0',
    711                                                     'tax_status'    => 'taxable',
    712                                                     'tax_class'     => ''
    713                                                     )
    714                                     );
    715723                                   
     724                                                                       
    716725
    717726                                    ///////////////////////////////////////////////////
     
    839848                                                           
    840849                                                            ///////////////////////////////////////////
    841                                                             //selecciona la imagen del producto
     850                                                            //selecciona la primera imagen q sera visible en el producto
    842851                                                            if ($imagen["primera"]==1){                                                       
    843852                                                            $perseo_resima = $wpdb->get_var($perseo_sqlima);
     
    851860                                                            //// imagen padre
    852861                                                            $perseo_nuevaima = $wpdb->get_var($perseo_sqlima);
     862                                                           
    853863                                                            if ($imagen["primera"]==0){
    854864                                                            $perseo_sumar= $perseo_sumar.$perseo_nuevaima.',';
     
    897907                                //echo "PRODUCTO MODIFICADO";
    898908                                //echo "<br>";
    899                                // echo $ConsultaProductoUpd;
    900                                // echo "<br>";
    901                                // echo '<br>';
    902                                 //echo $ConsultaProductoUpd;
    903                                 //echo '<br>';
    904                                // echo date_format(date_create($producto['fechamodificacion']),'Y-m-d H:i:s').' > '.$ConsultaProductofecha;
    905                                 //echo '<br>';
    906                                // $perseo_tabla = $wpdb->prefix.'_posts';
    907909                                $perseo_actualizar = array(
    908910                                    'post_content'      => $producto['fichatecnica'],
     
    913915                                    );
    914916
    915                                 //var_dump( $perseo_actualizar);
    916                                 //echo "<br>";
    917                                 //echo "<br>";
    918917
    919918                                $wpdb->update($table_prefix.'posts', $perseo_actualizar, array('ID' => $ConsultaProductoUpd));
    920919
    921920                                update_post_meta($ConsultaProductoUpd, '_stock', $producto['existenciastotales']);
    922                
     921
     922                                ////////////////////////////////////////////////////
     923                                //Eliminamos impuestos
     924                                $wpdb->query("Delete from {$table_prefix}postmeta where meta_key  = '_tax_status'  and  post_id=".$ConsultaProductoUpd);
     925                                /////////////////////////////////////////
     926                                ///saber si tiene IVA 12 % o 0%
     927                                if ($producto['porcentajeiva']=='12'){                                                   
     928                                    $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $ConsultaProductoUpd, 'meta_key'  => '_tax_status', 'meta_value'=> 'taxable') );
     929                                } else {                                                   
     930                                    $wpdb->insert($table_prefix.'postmeta', array('post_id'=> $ConsultaProductoUpd, 'meta_key'  => '_tax_status', 'meta_value'=> 'none') );
     931                                };
     932
    923933                                ///////////////////////////////////////////////////
    924934                                //insertamos Nuevo producto TERCERA TABLA plugin_term_relationships
     
    935945                                };
    936946
    937                                // echo '<br>';
    938                                // echo $resProdCat;
    939                                // echo '<br>';
    940                                // echo  $ConsultaProductoUpd;
    941                                 //echo '<br>';
    942947
    943948                                $wpdb->query("Delete from {$table_prefix}term_relationships where object_id=".$ConsultaProductoUpd);
     
    947952                               
    948953                                /////////////////////////////////////////////////////
    949                                 //Saber el precio seleccionado
    950                                  //iva
    951                                  $perseo_iva=0;
    952                                  //tarifa venta
     954                                //Saber el precio seleccionado                               
     955                                   
     956                                foreach($producto['tarifas'] as $tarifa)
     957                                {             
     958                                //tarifa venta
    953959                                 $perseo_tarifaventa=0;
    954960                                 //tarifa aumento   
    955                                  $perseo_tarifaaumento=0   ;   
    956                                 foreach($producto['tarifas'] as $tarifa)
    957                                 {     
    958                                                                                        
     961                                 $perseo_tarifaaumento=0;
     962
    959963                                        if (isset($tarifa))
    960964                                        {
    961                                             $perseo_iva= ($producto['porcentajeiva']/100)+1;
     965                                            //$perseo_iva= ($producto['porcentajeiva']/100)+1;
    962966
    963967                                                        if($perseo_parametros['perseotarifaVenta']==$tarifa['tarifasid'])
    964                                                         {
    965                                                             //$perseo_tarifaventa=round($tarifa['precio'],2) * $perseo_iva;
     968                                                        {                                                           
    966969                                                            $perseo_tarifaventa=round($tarifa['precio'],2);
     970                                                            update_post_meta($ConsultaProductoUpd, '_price', $perseo_tarifaventa);
     971                                                            update_post_meta($ConsultaProductoUpd, '_regular_price', $perseo_tarifaventa );
     972
     973                                                            ///////////////////////////////////////////////////
     974                                                            //insertamos Nuevo producto CUARTA TABLA plugin_wc_product_meta_lookup
     975                                                                $wpdb->update($table_prefix.'wc_product_meta_lookup',
     976                                                                array(
     977                                                                'max_price'     =>  $perseo_tarifaventa
     978                                                                ),
     979                                                                array('product_id' => $ConsultaProductoUpd)
     980                                                            );
     981
    967982                                                        };
    968983                                                            //precio 2
    969984                                                        if($perseo_parametros['perseotarifaAumento']==$tarifa['tarifasid'])
    970                                                         {
    971                                                             //$perseo_tarifaaumento =round($tarifa['precio'],2)* $perseo_iva;
     985                                                        {                                                           
    972986                                                            $perseo_tarifaaumento =round($tarifa['precio'],2);
    973                                                         }
    974                                           //  var_dump($tarifa);
    975                                           //  echo '<br>'.$ConsultaProductoUpd;
    976 
    977                                           update_post_meta($ConsultaProductoUpd, '_price', $perseo_tarifaventa);
    978                                           update_post_meta($ConsultaProductoUpd, '_regular_price', $perseo_tarifaventa );
    979                                           update_post_meta($ConsultaProductoUpd, '_sale_price', $perseo_tarifaaumento);
     987                                                            update_post_meta($ConsultaProductoUpd, '_sale_price', $perseo_tarifaaumento);
     988
     989                                                            ///////////////////////////////////////////////////
     990                                                            //insertamos Nuevo producto CUARTA TABLA plugin_wc_product_meta_lookup
     991                                                            $wpdb->update($table_prefix.'wc_product_meta_lookup',
     992                                                            array(
     993                                                            'min_price'     =>  $perseo_tarifaaumento
     994                                                            ),
     995                                                            array('product_id' => $ConsultaProductoUpd)
     996                                                            );
     997
     998                                                        }                                     
    980999                                        };         
    9811000                                }
     
    9831002                               
    9841003
    985                                 ///////////////////////////////////////////////////
    986                                 //insertamos Nuevo producto CUARTA TABLA plugin_wc_product_meta_lookup
    987                                     $wpdb->update($table_prefix.'wc_product_meta_lookup',
    988                                     array(
    989                                     'min_price'     =>  $perseo_tarifaaumento,
    990                                     'max_price'     =>  $perseo_tarifaventa
    991                                     ),
    992                                     array('product_id' => $ConsultaProductoUpd)
    993                                 );
     1004                               
    9941005
    9951006                                ///////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.