Plugin Directory

Changeset 3485856


Ignore:
Timestamp:
03/18/2026 04:17:18 PM (9 days ago)
Author:
webdigit
Message:

Release 1.0.1

Location:
gestoo-connector-for-peppol-invoicing/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • gestoo-connector-for-peppol-invoicing/trunk/admin/class-gestoo-peppol-order-list-columns.php

    r3485800 r3485856  
    273273            wp_send_json_error( [ 'message' => __( 'Order not found.', 'gestoo-connector-for-peppol-invoicing' ) ] );
    274274        }
    275         $log        = $order->get_meta( Gestoo_Peppol_Order_Handler::meta_error_log() );
    276         $last_error = (string) $order->get_meta( Gestoo_Peppol_Order_Handler::meta_last_error() );
     275        $log            = $order->get_meta( Gestoo_Peppol_Order_Handler::meta_error_log() );
     276        $last_error     = (string) $order->get_meta( Gestoo_Peppol_Order_Handler::meta_last_error() );
     277        $peppol_message = (string) $order->get_meta( Gestoo_Peppol_Order_Handler::meta_peppol_message() );
     278        $display_error  = $last_error ?: $peppol_message;
    277279        wp_send_json_success(
    278280            [
    279                 'last_error' => $last_error,
    280                 'log'        => is_array( $log ) ? $log : [],
     281                'last_error'     => $display_error,
     282                'peppol_message' => $peppol_message,
     283                'log'            => is_array( $log ) ? $log : [],
    281284            ]
    282285        );
  • gestoo-connector-for-peppol-invoicing/trunk/gestoo-connector-for-peppol-invoicing.php

    r3485800 r3485856  
    44 * Plugin URI:        https://www.gestoo.be
    55 * Description:       WooCommerce to GestOO connector: create invoices and send via Peppol. Official invoicing stays in GestOO.
    6  * Version:           1.0.0
     6 * Version:           1.0.1
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
     
    4242);
    4343
    44 define( 'GESTOO_PEPPOL_INVOICE_VERSION', '1.0.0' );
     44define( 'GESTOO_PEPPOL_INVOICE_VERSION', '1.0.1' );
    4545define( 'GESTOO_PEPPOL_INVOICE_PLUGIN_FILE', __FILE__ );
    4646define( 'GESTOO_PEPPOL_INVOICE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • gestoo-connector-for-peppol-invoicing/trunk/includes/class-gestoo-peppol-order-handler.php

    r3485542 r3485856  
    109109
    110110    /**
    111      * Récupère le numéro de TVA depuis la commande (clés meta configurées, normalisation BE si activée).
     111     * Récupère le numéro de TVA depuis la commande (clés meta configurées, normalisation PEPPOL si activée).
     112     *
     113     * Quand normalisation activée : extrait le code pays (2 lettres) et les chiffres sans espaces, points, tirets.
     114     * Format sortie : XX123456789 (ex. BE056776111 pour PEPPOL/UBL).
    112115     *
    113116     * @param WC_Order $order Commande WooCommerce.
     
    138141            return $value;
    139142        }
    140         $country = $order->get_billing_country();
    141         if ( 'BE' !== $country ) {
    142             return $value;
    143         }
    144         if ( preg_match( '/^[A-Z]{2}\d+/', $value ) ) {
    145             return $value;
    146         }
    147         return 'BE' . $value;
     143        return self::normalize_vat_for_peppol( $value, $order->get_billing_country() );
     144    }
     145
     146    /**
     147     * Normalise un numéro de TVA pour PEPPOL : code pays + chiffres uniquement (sans espaces, points, tirets).
     148     *
     149     * @param string $raw_value   Valeur brute (ex. "BE 056.776.111", "056.776.111").
     150     * @param string $billing_country Code pays ISO 2 (ex. BE, FR) — fallback si non présent dans la valeur.
     151     * @return string Format XX123456789 (ex. BE056776111).
     152     */
     153    public static function normalize_vat_for_peppol( string $raw_value, string $billing_country = 'BE' ): string {
     154        $value = trim( $raw_value );
     155        if ( '' === $value ) {
     156            return '';
     157        }
     158        $country = strtoupper( substr( $billing_country, 0, 2 ) );
     159        if ( '' === $country ) {
     160            $country = 'BE';
     161        }
     162        // Extraire le code pays depuis la valeur si présent (2 lettres au début).
     163        if ( preg_match( '/^([A-Z]{2})[\s\.\-]*/i', $value, $m ) ) {
     164            $country = strtoupper( $m[1] );
     165            $value   = substr( $value, strlen( $m[0] ) );
     166        }
     167        // Chiffres uniquement (supprime espaces, points, tirets, lettres restantes).
     168        $digits = preg_replace( '/\D/', '', $value );
     169        if ( '' === $digits ) {
     170            return $raw_value;
     171        }
     172        return $country . $digits;
    148173    }
    149174
  • gestoo-connector-for-peppol-invoicing/trunk/includes/class-gestoo-peppol-wc-integration.php

    r3485542 r3485856  
    194194            ],
    195195            'normalize_be_vat'   => [
    196                 'title'   => __( 'Normalize Belgian VAT', 'gestoo-connector-for-peppol-invoicing' ),
     196                'title'   => __( 'Normalize VAT for PEPPOL', 'gestoo-connector-for-peppol-invoicing' ),
    197197                'type'    => 'checkbox',
    198                 'label'   => __( 'Prefix with BE when billing country is BE and value has no country prefix.', 'gestoo-connector-for-peppol-invoicing' ),
     198                'label'   => __( 'Normalize format: extract country code, digits only (no spaces, dots, hyphens). Output: XX123456789.', 'gestoo-connector-for-peppol-invoicing' ),
    199199                'default' => 'yes',
    200200                'tab'     => 'general',
  • gestoo-connector-for-peppol-invoicing/trunk/readme.txt

    r3485800 r3485856  
    55Requires at least: 6.0
    66Tested up to: 6.9
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88Requires PHP: 7.4
    99Requires Plugins: woocommerce
     
    8080== Changelog ==
    8181
     82= 1.0.1 =
     83* VAT number normalization: extract country code and digits only (no spaces, dots, hyphens) before sending to GestOO. Fixes PEPPOL rejection when WooCommerce stores "BE 056.776.111" or "056.776.111".
     84* Detailed Peppol error messages (e.g. mod97 invalid) now propagated to WooCommerce order meta and displayed in meta box and event log modal.
     85* Setting "Normalize VAT for PEPPOL" now applies to all EU countries, not just Belgium.
     86
    8287= 1.0.0 =
    8388* **1.0 stable release.** Production-ready WooCommerce to GestOO connector for Peppol e-invoicing.
     
    143148== Upgrade Notice ==
    144149
     150= 1.0.1 =
     151VAT normalization fix: removes spaces/dots/hyphens from VAT numbers. Detailed Peppol errors (e.g. mod97) now shown in WooCommerce. Safe to update.
     152
    145153= 1.0.0 =
    1461541.0 stable release. Retry syncs client data and resends. Full Peppol error messages displayed. Safe to update.
Note: See TracChangeset for help on using the changeset viewer.