Changeset 3485856
- Timestamp:
- 03/18/2026 04:17:18 PM (9 days ago)
- Location:
- gestoo-connector-for-peppol-invoicing/trunk
- Files:
-
- 5 edited
-
admin/class-gestoo-peppol-order-list-columns.php (modified) (1 diff)
-
gestoo-connector-for-peppol-invoicing.php (modified) (2 diffs)
-
includes/class-gestoo-peppol-order-handler.php (modified) (2 diffs)
-
includes/class-gestoo-peppol-wc-integration.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gestoo-connector-for-peppol-invoicing/trunk/admin/class-gestoo-peppol-order-list-columns.php
r3485800 r3485856 273 273 wp_send_json_error( [ 'message' => __( 'Order not found.', 'gestoo-connector-for-peppol-invoicing' ) ] ); 274 274 } 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; 277 279 wp_send_json_success( 278 280 [ 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 : [], 281 284 ] 282 285 ); -
gestoo-connector-for-peppol-invoicing/trunk/gestoo-connector-for-peppol-invoicing.php
r3485800 r3485856 4 4 * Plugin URI: https://www.gestoo.be 5 5 * Description: WooCommerce to GestOO connector: create invoices and send via Peppol. Official invoicing stays in GestOO. 6 * Version: 1.0. 06 * Version: 1.0.1 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 42 42 ); 43 43 44 define( 'GESTOO_PEPPOL_INVOICE_VERSION', '1.0. 0' );44 define( 'GESTOO_PEPPOL_INVOICE_VERSION', '1.0.1' ); 45 45 define( 'GESTOO_PEPPOL_INVOICE_PLUGIN_FILE', __FILE__ ); 46 46 define( 'GESTOO_PEPPOL_INVOICE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -
gestoo-connector-for-peppol-invoicing/trunk/includes/class-gestoo-peppol-order-handler.php
r3485542 r3485856 109 109 110 110 /** 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). 112 115 * 113 116 * @param WC_Order $order Commande WooCommerce. … … 138 141 return $value; 139 142 } 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; 148 173 } 149 174 -
gestoo-connector-for-peppol-invoicing/trunk/includes/class-gestoo-peppol-wc-integration.php
r3485542 r3485856 194 194 ], 195 195 'normalize_be_vat' => [ 196 'title' => __( 'Normalize Belgian VAT', 'gestoo-connector-for-peppol-invoicing' ),196 'title' => __( 'Normalize VAT for PEPPOL', 'gestoo-connector-for-peppol-invoicing' ), 197 197 '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' ), 199 199 'default' => 'yes', 200 200 'tab' => 'general', -
gestoo-connector-for-peppol-invoicing/trunk/readme.txt
r3485800 r3485856 5 5 Requires at least: 6.0 6 6 Tested up to: 6.9 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 Requires PHP: 7.4 9 9 Requires Plugins: woocommerce … … 80 80 == Changelog == 81 81 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 82 87 = 1.0.0 = 83 88 * **1.0 stable release.** Production-ready WooCommerce to GestOO connector for Peppol e-invoicing. … … 143 148 == Upgrade Notice == 144 149 150 = 1.0.1 = 151 VAT normalization fix: removes spaces/dots/hyphens from VAT numbers. Detailed Peppol errors (e.g. mod97) now shown in WooCommerce. Safe to update. 152 145 153 = 1.0.0 = 146 154 1.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.