You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Update payment mapping settings and validation logic
- Enhanced the description in settings to clarify the requirements for payment types and methods.
- Modified the payment mappings table to include data attributes for live UX validation.
- Updated validation logic to allow saving gateways with empty account_id when payment_method is provided.
- Implemented checks to ensure payment_method is required for CASH payment_type, while CREDIT can be saved without it.
- Adjusted invoice generation logic to omit paymentMethod when it is empty, ensuring correct payload structure.
- Added tests to validate the new behavior and ensure proper handling of payment mappings.
- Bumped version to 0.1.2 and updated changelog for clarity on changes made.
Co-authored-by: Copilot <copilot@github.com>
Copy file name to clipboardExpand all lines: includes/admin/other_settings.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,7 @@
99
99
'bank_accounts' => $bank_accounts,
100
100
'active_gateways' => $active_gateways,
101
101
'all_gateways' => $all_gateways,
102
-
'description' => __( 'Debe configurar método de pago, cuenta bancaria y tipo de pago para cada gateway activo. Los gateways inactivos con mapeo guardado también se muestran para edición.' ),
102
+
'description' => __( 'Configure el tipo de pago para cada gateway. Cuando el tipo es <strong>Contado (CASH)</strong>, la Forma de pago es obligatoria. Cuando es <strong>Crédito (CREDIT)</strong>, la Forma de pago es opcional. La Cuenta bancaria siempre es opcional. Los gateways inactivos con mapeo guardado también se muestran para edición.' ),
if ( ! $gateway_map['payment_type'] || $cash_without_method ) {
296
303
WC_Admin_Settings::add_error(
297
304
sprintf(
298
-
__('Integration Alegra Woocommerce: Debe configurar método de pago, cuenta bancaria y tipo de pago para el gateway activo "%s".', 'integration-alegra-woo'),
305
+
__('Integration Alegra Woocommerce: Debe configurar el tipo de pago para el gateway activo "%s". Si el tipo de pago es CASH, también debe configurar la Forma de pago.', 'integration-alegra-woo'),
299
306
$gateway_title
300
307
)
301
308
);
@@ -307,37 +314,30 @@ public function validate_payment_mappings_table_field($key, $value): array
307
314
$payment_method = $gateway_map['payment_method'];
308
315
$account_id = $gateway_map['account_id'];
309
316
310
-
if (($payment_method && !$account_id) || (!$payment_method && $account_id)) {
311
-
WC_Admin_Settings::add_error(
312
-
sprintf(
313
-
__('Integration Alegra Woocommerce: El gateway "%s" tiene configuración incompleta. Debe seleccionar método y cuenta.', 'integration-alegra-woo'),
314
-
$gateway_id
315
-
)
316
-
);
317
-
$has_errors = true;
318
-
continue;
319
-
}
320
-
321
-
if (!$payment_method && !$account_id) {
317
+
// payment_method is required only for CASH; silently skip those rows.
0 commit comments