Revision 6309c617
Von Jan Büren vor mehr als 3 Jahren hinzugefügt
t/pay_posting_import/datev.csv | ||
---|---|---|
1 |
"DTVF";700;21;"Buchungsstapel";9;20210705140408955;20210705140408939;"LO";"";"kivitendo";49999;40392;20210101;6;20210601;20210630;"Lohn-Buchungen 06/2021";"LG";1;0;0;"EUR";;"";;55464;"";;;"";"004999940392F08" |
|
2 |
Umsatz;S/H;;;;;Konto;Gegenkonto (ohne BU-Schlüssel);;Belegdatum;Belegfeld 1;Belegfeld 2;;Buchungstext;;;;;;;;;;;;;;;;;;;;;;;KOST1;KOST2;KOST Menge;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Festschreibung |
|
3 |
2455,11;H;;;;;379000;136900;;3006;202106;;;AAG 06/2021 AOK Baden-Württemberg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
4 |
230;H;;;;;379000;136900;;3006;202106;;;AAG 06/2021 BKK Debeka;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
5 |
142,31;H;;;;;379000;136900;;3006;202106;;;AAG 06/2021 IKK classic;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
6 |
43872,97;S;;;;;379000;372000;;3006;202106;;;AUSZAHLUNGSVERBINDL.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
7 |
1787,21;S;;;;;379000;372500;;3006;202106;;;Verbindl. Einbehaltung Arbeitn;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
8 |
10808,16;S;;;;;379000;373000;;3006;202106;;;VERBINDL.FINANZAMT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
9 |
23109,51;S;;;;;379000;374000;;3006;202106;;;VERBINDL.KRANKENKASSEN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
10 |
40;S;;;;;379000;377000;;3006;202106;;;Verb. aus Vermögensbildung;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
11 |
384;S;;;;;379000;494700;;3006;202106;;;KFZ-NUTZUNG;;;;;;;;;;;;;;;;;;;;;;;wisavis;2016;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
12 |
623,57;S;;;;;379000;494700;;3006;202106;;;KFZ-NUTZUNG;;;;;;;;;;;;;;;;;;;;;;;wisavis;2018;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
13 |
662,65;S;;;;;379000;494700;;3006;202106;;;KFZ-NUTZUNG;;;;;;;;;;;;;;;;;;;;;;;wisavis;2019;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
|
14 |
298;S;;;;;379000;494700;;3006;202106;;;Diff. USt-MindestBMG (Firmenwagen);;;;;;;;;;;;;;;;;;;;;;;wisavis;2021;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0 |
t/pay_posting_import/datev_import.t | ||
---|---|---|
1 |
use strict; |
|
2 |
use Test::More; |
|
3 |
use Test::Exception; |
|
4 |
|
|
5 |
use lib 't'; |
|
6 |
|
|
7 |
use_ok 'Support::TestSetup'; |
|
8 |
|
|
9 |
use SL::Controller::PayPostingImport; |
|
10 |
|
|
11 |
use utf8; |
|
12 |
use Data::Dumper; |
|
13 |
use File::Slurp; |
|
14 |
use Text::CSV_XS qw (csv); |
|
15 |
|
|
16 |
Support::TestSetup::login(); |
|
17 |
|
|
18 |
my $dbh = SL::DB->client->dbh; |
|
19 |
my @charts = qw(379000 136900 372000 372500 373000 374000 377000 494700); |
|
20 |
local $::locale = Locale->new('en'); |
|
21 |
diag("init csv"); |
|
22 |
clear_up(); |
|
23 |
|
|
24 |
# datev naming convention and expected filename entry in $::form |
|
25 |
$::form->{ATTACHMENTS}{file}{filename} = 'DTVF_44979_43392_LOHNBUCHUNGEN_LUG_202106_20210623_0946'; |
|
26 |
$::form->{file} = read_file('t/pay_posting_import/datev.csv'); |
|
27 |
my $source = $::form->{ATTACHMENTS}{file}{filename}; |
|
28 |
|
|
29 |
# get data as aoa datev encodes always CP1252 |
|
30 |
my $csv_array = csv (in => "t/pay_posting_import/datev.csv", |
|
31 |
binary => 0, |
|
32 |
auto_diag => 1, sep_char => ";", encoding=> "cp1252"); |
|
33 |
|
|
34 |
# probably no correct charts in test db |
|
35 |
throws_ok{ |
|
36 |
SL::Controller::PayPostingImport::parse_and_import(); |
|
37 |
} qr/No such Chart 379000/, "Importing Pay Postings without correct charts"; |
|
38 |
|
|
39 |
# create charts |
|
40 |
foreach my $accno (@charts) { |
|
41 |
SL::DB::Chart->new( |
|
42 |
accno => $accno, |
|
43 |
description => 'Löhne mit Gestöhne', |
|
44 |
charttype => 'A', |
|
45 |
category => 'Q', |
|
46 |
link => '', |
|
47 |
taxkey_id => '0', |
|
48 |
datevautomatik => 'f', |
|
49 |
)->save; |
|
50 |
} |
|
51 |
|
|
52 |
# and add department (KOST1 description) |
|
53 |
SL::DB::Department->new( |
|
54 |
description => 'Wisavis' |
|
55 |
)->save; |
|
56 |
|
|
57 |
SL::Controller::PayPostingImport::parse_and_import(); |
|
58 |
|
|
59 |
# get all gl imported bookings |
|
60 |
my $gl_bookings = SL::DB::Manager::GLTransaction->get_all(where => [imported => 1] ); |
|
61 |
|
|
62 |
# $i number of real data entries in the array (first two rows are headers) |
|
63 |
my $i = 2; |
|
64 |
is(scalar @{ $csv_array } - $i, scalar @{ $gl_bookings }, "Correct number of imported Pay Posting Bookings"); |
|
65 |
|
|
66 |
# check all imported bookings |
|
67 |
foreach my $booking (@{ $gl_bookings }) { |
|
68 |
my $current_row = $csv_array->[$i]; |
|
69 |
|
|
70 |
my $accno_credit = $current_row->[1] eq 'S' ? $current_row->[7] : $current_row->[6]; |
|
71 |
my $accno_debit = $current_row->[1] eq 'S' ? $current_row->[6] : $current_row->[7]; |
|
72 |
my $amount = $::form->parse_amount({ numberformat => '1000,00' }, $current_row->[0]); |
|
73 |
|
|
74 |
# gl |
|
75 |
is ($current_row->[13], $booking->reference, "Buchungstext correct"); |
|
76 |
is ("Wisavis", $booking->department->description, "Department correctly assigned"); |
|
77 |
is ($source, $booking->transactions->[0]->source, "Source 0 correctly assigned"); |
|
78 |
is ($source, $booking->transactions->[1]->source, "Source 1 correctly assigned"); |
|
79 |
|
|
80 |
# acc_trans |
|
81 |
cmp_ok ($amount, '==', $booking->transactions->[0]->amount, "Correct amount Soll"); |
|
82 |
cmp_ok ($amount * -1, '==', $booking->transactions->[1]->amount, "Correct amount Haben"); |
|
83 |
is (ref $booking->transdate, 'DateTime', "Booking has a Transdate"); |
|
84 |
is ($accno_credit, $booking->transactions->[0]->chart->accno, "Sollkonto richtig"); |
|
85 |
is ($accno_debit, $booking->transactions->[1]->chart->accno, "Habenkonto richtig"); |
|
86 |
|
|
87 |
$i++; |
|
88 |
} |
|
89 |
|
|
90 |
clear_up(); |
|
91 |
|
|
92 |
|
|
93 |
done_testing(); |
|
94 |
|
|
95 |
1; |
|
96 |
|
|
97 |
sub clear_up { |
|
98 |
SL::DB::Manager::AccTransaction->delete_all( all => 1); |
|
99 |
SL::DB::Manager::GLTransaction->delete_all( all => 1); |
|
100 |
foreach my $accno (@charts) { |
|
101 |
SL::DB::Manager::Chart->delete_all(where => [ accno => $accno ] ); |
|
102 |
} |
|
103 |
}; |
Auch abrufbar als: Unified diff
PayPostingImport: Testfall gegen DATEV-CSV Struktur