Plugin Directory

Changeset 2644114


Ignore:
Timestamp:
12/14/2021 07:23:52 PM (4 years ago)
Author:
kakaroto84
Message:

1.6.0

  • In properties you can configure the account as a natural person or as a company, with the respective change the invoices will be generated depending on the type chosen
Location:
wc-yabi/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • wc-yabi/trunk/content/settings.php

    r2469031 r2644114  
    4343           
    4444                <tr>
     45                    <th width="14%"><label for="yabi_owner"><?php echo __('Type of Owner','yabi-wc'); ?>:</label></th>
     46                    <td>
     47                        <select id="yabi_owner" name="yabi_owner">
     48                            <option value="company" <?php if( 'company' == get_option( 'yabi_owner' ) ) echo 'selected'; ?>><?php echo __('Company','yabi-wc'); ?></option>
     49                            <option value="person" <?php if( 'person' == get_option( 'yabi_owner' ) ) echo 'selected'; ?>><?php echo __('Person','yabi-wc'); ?></option>                             
     50                        </select>
     51                    </td>
     52                </tr>
     53           
     54                <tr>
    4555                    <th width="14%"><label for="yabi_businessunituuid"><?php echo __('Business Unit Uuid','yabi-wc'); ?>:</label></th>
    4656                    <td>
    47                         <input type="text" class="large-text" id="yabi_invoice_name" name="yabi_businessunituuid" value="<?php echo esc_attr( get_option('yabi_businessunituuid') ); ?>" /><br/>
     57                        <input type="text" class="large-text" id="yabi_businessunituuid" name="yabi_businessunituuid" value="<?php echo esc_attr( get_option('yabi_businessunituuid') ); ?>" /><br/>
    4858                        <span class="description">xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</span>
    4959                    </td>
  • wc-yabi/trunk/includes/ajax.php

    r2630794 r2644114  
    9191            'dateTime' => $dateTime,
    9292        );     
    93                
    94         $graphQL = yabi_create_invoice_person( $person, $products, $payment );
     93       
     94        if( 'person' == get_option( 'yabi_owner' ) )
     95        {
     96            $graphQL = yabi_create_invoice_person( $person, $products, $payment );
     97        }
     98        else
     99        {               
     100            $graphQL = yabi_create_invoice_company( $person, $products, $payment );
     101        }
    95102       
    96103        $response = yabi_send_data( $graphQL );
  • wc-yabi/trunk/includes/transaction.php

    r2630794 r2644114  
    3333}
    3434
    35 function yabi_create_invoice_person( $person, $products, $payment )
     35function yabi_create_invoice_company( $person, $products, $payment )
    3636{
    3737    $businessUnitUuid = get_option('yabi_businessunituuid');
     
    137137    return $graphQL;
    138138
     139}
     140
     141function yabi_create_invoice_person( $person, $products, $payment )
     142{
     143    $businessUnitUuid = get_option( 'yabi_businessunituuid' );
     144    $invoiceConsecutive = get_option( 'yabi_invoice_name' ) . get_option( 'yabi_invoice_number' );
     145   
     146    $data_products = yabi_create_products( $products );
     147    $tax_subtotal = yabi_create_tax( $data_products );
     148   
     149    $note = '';
     150    $observations = '';
     151    $commercial = yabi_create_commercial( $person );
     152     
     153    if( !empty( $person['note_name'] ) && !empty( $person['note_value'] ) )
     154    {
     155        $note = 'note:{
     156              name:"'. $person['note_name'] .'"
     157              value:"'. $person['note_value'] .'"
     158            }';
     159    }   
     160   
     161    if( !empty( $person['observations'] ) )
     162    {
     163        $observations = 'invoiceOptionalData:[{
     164            name:"Observations"
     165            value:"'. $person['observations'] .'"
     166        }]';
     167    }
     168   
     169    $invoicetypecode = "SALES_INVOICE";
     170    if( $person['accountid'] == 'LEGAL' )
     171    {
     172        $invoicetypecode = "SALES_INVOICE";
     173    }
     174   
     175    $graphQL = 'mutation{
     176      createInvoice(input:{
     177        businessUnitUuid:"'. $businessUnitUuid .'"
     178        invoiceConsecutive:"'. $invoiceConsecutive .'"
     179        invoiceAcquirerId:{
     180          identifier:"'. $person['identifier'] .'"
     181          type:'. $person['type'] .'
     182        }
     183        invoiceAcquirerData:{
     184          additionalAccountId:'. $person['accountid'] .'
     185          address:{
     186            countryCode:"CO"
     187            cityCode:"'. $person['citycode'] .'"
     188            line:"'. $person['address'] .'"
     189          }
     190          contact:{
     191            email:"'. $person['email'] .'"
     192            name:{
     193              firstName:"'. $person['name'] .'"
     194              familyName:"'. $person['lastname'] .'"
     195            }
     196            telephone:"'. $person['telephone'] .'"
     197            '. $note .'
     198          }
     199          '. $commercial .'
     200        }       
     201        invoiceDetails:{
     202          acquirerEmail:"'. $person['email'] .'"
     203          documentCurrencyId:"COP"
     204          dueDate:"'. $payment['dueDate'] .'"
     205          invoiceOperationCode:STANDARD
     206          invoiceTypeCode:'. $invoicetypecode .'
     207          issueDateTime:"'. $payment['dateTime'] .'"
     208        }
     209        invoiceData:{
     210          invoiceLines:[
     211            '. $data_products['graphQL'] .'
     212          ]
     213          paymentMeans:{
     214            id:CREDIT
     215            paymentDueDate:"'. $payment['dueDate'] .'"
     216            paymentId:"'. $payment['id'] .'"
     217            paymentMeansCode:"ZZZ"
     218          }
     219        }
     220        invoiceTaxDetails:[{
     221          id:1
     222          taxAmount:'. $data_products['total_tax'] .'
     223          taxSchemeId:IVA
     224          taxSubtotal:['. $tax_subtotal .']
     225        }]
     226        invoiceTotals:{
     227          allowanceTotalAmount:0
     228          chargeTotalAmount:0
     229          lineExtensionAmount:'. $data_products['total_value'] .'
     230          payableAmount:'. ( $data_products['total_tax'] + $data_products['total_value'] ) .'
     231          prepaidAmount:0
     232          taxExclusiveAmount:'. $data_products['total_value'] .'
     233          taxInclusiveAmount:'. ( $data_products['total_tax'] + $data_products['total_value'] ) .'
     234        }       
     235        '. $observations .'     
     236      }){
     237        invoice{
     238          invoiceUuid
     239          invoiceDianLog
     240          invoiceDetails
     241        }
     242      }
     243    }
     244    ';
     245
     246    return $graphQL;
    139247}
    140248
  • wc-yabi/trunk/languages/yabi-wc-es_CO.po

    r2630794 r2644114  
    44"Report-Msgid-Bugs-To: \n"
    55"POT-Creation-Date: 2020-12-02 23:02+0000\n"
    6 "PO-Revision-Date: 2021-11-03 08:58-0500\n"
     6"PO-Revision-Date: 2021-12-10 17:04-0500\n"
    77"Last-Translator: \n"
    88"Language-Team: \n"
     
    1212"Content-Transfer-Encoding: 8bit\n"
    1313"Plural-Forms: nplurals=2; plural=n != 1;\n"
    14 "X-Generator: Poedit 3.0\n"
     14"X-Generator: Poedit 3.0.1\n"
    1515"X-Loco-Version: 2.4.6; wp-5.5.3\n"
    1616
     
    348348msgid "You must select the type of person"
    349349msgstr "Debe seleccionar el tipo de persona"
     350
     351#: content/settings.php:45
     352msgid "Type of Owner"
     353msgstr "Tipo de dueño"
     354
     355#: content/settings.php:48
     356msgid "Company"
     357msgstr "Empresa"
     358
     359#: content/settings.php:49
     360msgid "Person"
     361msgstr "Persona natural"
  • wc-yabi/trunk/languages/yabi-wc-es_ES.po

    r2630794 r2644114  
    44"Report-Msgid-Bugs-To: \n"
    55"POT-Creation-Date: 2020-12-02 23:02+0000\n"
    6 "PO-Revision-Date: 2021-11-03 08:59-0500\n"
     6"PO-Revision-Date: 2021-12-10 17:03-0500\n"
    77"Last-Translator: \n"
    88"Language-Team: Español\n"
     
    1212"Content-Transfer-Encoding: 8bit\n"
    1313"Plural-Forms: nplurals=2; plural=n != 1;\n"
    14 "X-Generator: Poedit 3.0\n"
     14"X-Generator: Poedit 3.0.1\n"
    1515"X-Loco-Version: 2.4.6; wp-5.5.3\n"
    1616
     
    345345msgid "You must select the type of person"
    346346msgstr "Debe seleccionar el tipo de persona"
     347
     348#: content/settings.php:45
     349msgid "Type of Owner"
     350msgstr "Tipo de dueño"
     351
     352#: content/settings.php:48
     353msgid "Company"
     354msgstr "Empresa"
     355
     356#: content/settings.php:49
     357msgid "Person"
     358msgstr "Persona natural"
  • wc-yabi/trunk/languages/yabi-wc.pot

    r2630794 r2644114  
    322322msgid "You must select the type of person"
    323323msgstr ""
     324
     325#: content/settings.php:45
     326msgid "Type of Owner"
     327msgstr ""
     328
     329#: content/settings.php:48
     330msgid "Company"
     331msgstr ""
     332
     333#: content/settings.php:49
     334msgid "Person"
     335msgstr ""
  • wc-yabi/trunk/readme.txt

    r2630794 r2644114  
    44Donate link: https://www.paypal.me/datakun
    55Requires at least: 5.5
    6 Tested up to: 5.8.1
     6Tested up to: 5.8.2
    77Requires PHP: 7.4
    88Stable tag: trunk
     
    9696= 1.5.1 =
    9797* Fixed decimal problem on discount coupon
     98= 1.6.0 =
     99* In properties you can configure the account as a natural person or as a company, with the respective change the invoices will be generated depending on the type chosen
  • wc-yabi/trunk/wc-yabi.php

    r2630794 r2644114  
    99 * Plugin URI:        https://mireunion.com/yabi
    1010 * Description:       Create your electronic invoices of purchases made in woocommerce with Yabi
    11  * Version:           1.5.1
     11 * Version:           1.6.0
    1212 * Author:            Mex Avila
    1313 * Author URI:        https://datakun.com/
     
    160160    $yabi_invoice_name = sanitize_text_field( $_POST['yabi_invoice_name'] );
    161161    $yabi_invoice_number = sanitize_text_field( $_POST['yabi_invoice_number'] );
    162    
     162    $yabi_owner = sanitize_key( $_POST['yabi_owner'] );
    163163    $yabi_businessunituuid = sanitize_key( $_POST['yabi_businessunituuid'] );
    164164    $yabi_token = sanitize_key( $_POST['yabi_token'] );
     
    167167    update_option( 'yabi_invoice_name', $yabi_invoice_name );
    168168    update_option( 'yabi_invoice_number', $yabi_invoice_number );
    169    
     169    update_option( 'yabi_owner', $yabi_owner );
    170170    update_option( 'yabi_businessunituuid', $yabi_businessunituuid );
    171171    update_option( 'yabi_token', $yabi_token );
Note: See TracChangeset for help on using the changeset viewer.