From a6af3f631722f15396801d60cd5873f1e8c1a9fb Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 13 Dec 2018 14:59:38 +0100 Subject: [PATCH] Bug 21605: (follow-up) Simple ternary boolean to number conversion Imo it is much easier to do just "$a ? 1 : 0" than testing defined($a) etc. in the additional loop. Less code, more readable? Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens (cherry picked from commit 482b323da1e18324941963359b9a1bd96f297c44) Signed-off-by: Martin Renvoize (cherry picked from commit fee85191b0be2690cbfada45f4eba54ef0e75c35) Signed-off-by: Lucas Gass (cherry picked from commit e1050653fba9a2eb0af5926b8cc9326ca721f939) Signed-off-by: Fridolin Somers --- admin/edi_accounts.pl | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/admin/edi_accounts.pl b/admin/edi_accounts.pl index fb7cddc49e..84d4e11f21 100755 --- a/admin/edi_accounts.pl +++ b/admin/edi_accounts.pl @@ -82,17 +82,14 @@ else { download_directory => scalar $input->param('download_directory'), san => scalar $input->param('san'), transport => scalar $input->param('transport'), + quotes_enabled => $input->param('quotes_enabled') ? 1 : 0, + invoices_enabled => $input->param('invoices_enabled') ? 1 : 0, + orders_enabled => $input->param('orders_enabled') ? 1 : 0, + responses_enabled => $input->param('responses_enabled') ? 1 : 0, + auto_orders => $input->param('auto_orders') ? 1 : 0, id_code_qualifier => scalar $input->param('id_code_qualifier'), plugin => scalar $input->param('plugin'), }; - # ensure all capability fields set to binary 0 or 1 - foreach my $capability - (qw( quotes_enabled invoices_enabled orders_enabled responses_enabled auto_orders)) { - $fields->{$capability} = defined $input->param($capability); - if ($fields->{$capability} != 1) { - $fields->{$capability} = 0; - } - } if ($id) { $schema->resultset('VendorEdiAccount')->search( -- 2.39.5