my $csv;
$csv = SL::Helper::Csv->new(
- file => \"Kaffee;\n",
+ file => \"Kaffee\n",
header => [ 'description' ],
);
$csv = SL::Helper::Csv->new(
file => \"Kaffee;0.12;12,2;1,5234\n",
header => [ 'description', 'sellprice', 'lastcost_as_number', 'listprice' ],
- header_acc => { listprice => 'listprice_as_number' },
+ dispatch => { listprice => 'listprice_as_number' },
class => 'SL::DB::Part',
);
$csv->parse;
is $csv->get_objects->[0]->sellprice, 0.12, 'numeric attr works';
is $csv->get_objects->[0]->lastcost, 12.2, 'attr helper works';
-is $csv->get_objects->[0]->listprice, 1.5234, 'header_acc works';
+is $csv->get_objects->[0]->listprice, 1.5234, 'dispatch works';
#####
EOL
sep_char => ',',
quote_char => "'",
- header_acc => { listprice => 'listprice_as_number' },
+ dispatch => { listprice => 'listprice_as_number' },
class => 'SL::DB::Part',
);
$csv->parse;
);
is $csv->parse, undef, 'broken csv header won\'t get parsed';
+######
+
+$csv = SL::Helper::Csv->new(
+ file => \<<EOL,
+description;partnumber;sellprice;lastcost_as_number;
+"Kaf"fee";;0.12;1,221.52
+Beer;1123245;0.12;1.5234
+EOL
+ numberformat => '1,000.00',
+ class => 'SL::DB::Part',
+);
+is $csv->parse, undef, 'broken csv content won\'t get parsed';
+is_deeply $csv->errors, [ '"Kaf"fee";;0.12;1,221.52'."\n", 2023, 'EIQ - QUO character not allowed', 5, 2 ], 'error';
done_testing();
# vim: ft=perl