Revision 1a3b9961
Von Kivitendo Admin vor mehr als 7 Jahren hinzugefügt
t/datev/invoices.t | ||
---|---|---|
16 | 16 |
|
17 | 17 |
clear_up(); |
18 | 18 |
|
19 |
my $dbh = SL::DB->client->dbh; |
|
20 |
|
|
19 | 21 |
my $buchungsgruppe7 = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 7%') || die "No accounting group for 7\%"; |
20 | 22 |
my $bank = SL::DB::Manager::Chart->find_by(description => 'Bank') || die 'Can\'t find chart "Bank"'; |
21 | 23 |
my $date = DateTime->new(year => 2017, month => 1, day => 1); |
22 | 24 |
my $payment_date = DateTime->new(year => 2017, month => 1, day => 5); |
25 |
my $gldate = DateTime->new(year => 2017, month => 2, day => 9); # simulate bookings for Jan being made in Feb |
|
23 | 26 |
|
24 | 27 |
my $part1 = SL::Dev::Part::create_part(partnumber => '19', description => 'Part 19%')->save; |
25 | 28 |
my $part2 = SL::Dev::Part::create_part( |
... | ... | |
30 | 33 |
|
31 | 34 |
my $invoice = SL::Dev::Record::create_sales_invoice( |
32 | 35 |
invnumber => "1 sales invoice", |
36 |
itime => $gldate, |
|
37 |
gldate => $gldate, |
|
38 |
intnotes => 'booked in February', |
|
33 | 39 |
taxincluded => 0, |
34 | 40 |
transdate => $date, |
35 | 41 |
invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70), |
... | ... | |
78 | 84 |
}, |
79 | 85 |
], "trans_id datev check ok"; |
80 | 86 |
|
87 |
my $march_9 = DateTime->new(year => 2017, month => 3, day => 9); |
|
81 | 88 |
my $invoice2 = SL::Dev::Record::create_sales_invoice( |
82 | 89 |
invnumber => "2 sales invoice", |
90 |
itime => $march_9, |
|
91 |
gldate => $march_9, |
|
92 |
intnotes => 'booked in March', |
|
83 | 93 |
taxincluded => 0, |
84 | 94 |
transdate => $date, |
85 | 95 |
invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 6, sellprice => 70), |
... | ... | |
89 | 99 |
|
90 | 100 |
my $credit_note = SL::Dev::Record::create_credit_note( |
91 | 101 |
invnumber => 'Gutschrift 34', |
102 |
itime => $gldate, |
|
103 |
gldate => $gldate, |
|
104 |
intnotes => 'booked in February', |
|
92 | 105 |
taxincluded => 0, |
93 | 106 |
transdate => $date, |
94 | 107 |
invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70), |
... | ... | |
96 | 109 |
] |
97 | 110 |
); |
98 | 111 |
|
99 |
my $startdate = DateTime->new(year => 2017, month => 1, day => 1); |
|
112 |
my $startdate = DateTime->new(year => 2017, month => 1, day => 1);
|
|
100 | 113 |
my $enddate = DateTime->new(year => 2017, month => 12, day => 31); |
101 | 114 |
|
102 | 115 |
my $datev = SL::DATEV->new( |
103 |
dbh => $credit_note->db->dbh, |
|
116 |
dbh => $dbh, |
|
117 |
from => $startdate, |
|
118 |
to => $enddate, |
|
119 |
); |
|
120 |
$datev->generate_datev_data(from_to => $datev->fromto); |
|
121 |
my $datev_lines = $datev->generate_datev_lines; |
|
122 |
my $umsatzsumme = sum map { $_->{umsatz} } @{ $datev_lines }; |
|
123 |
cmp_ok($::form->round_amount($umsatzsumme,2), '==', 3924.5, "Sum of all bookings ok"); |
|
124 |
|
|
125 |
note('testing gldatefrom'); |
|
126 |
my $datev = SL::DATEV->new( |
|
127 |
dbh => $dbh, |
|
104 | 128 |
from => $startdate, |
105 |
to => $enddate
|
|
129 |
to => DateTime->new(year => 2017, month => 01, day => 31),
|
|
106 | 130 |
); |
131 |
|
|
132 |
$::form = Support::TestSetup->create_new_form; |
|
133 |
$::form->{gldatefrom} = DateTime->new(year => 2017, month => 3, day => 1)->to_kivitendo; |
|
134 |
|
|
107 | 135 |
$datev->generate_datev_data(from_to => $datev->fromto); |
108 | 136 |
my $datev_lines = $datev->generate_datev_lines; |
109 | 137 |
my $umsatzsumme = sum map { $_->{umsatz} } @{ $datev_lines }; |
110 |
is($umsatzsumme, 3924.50, "umsatzsumme ok"); |
|
138 |
cmp_ok($umsatzsumme, '==', 1569.8, "Sum of bookings made after March 1st (only invoice2) ok"); |
|
139 |
|
|
140 |
$::form->{gldatefrom} = DateTime->new(year => 2017, month => 5, day => 1)->to_kivitendo; |
|
141 |
$datev->generate_datev_data(from_to => $datev->fromto); |
|
142 |
cmp_bag $datev->generate_datev_lines, [], "no bookings for January made after May 1st: ok"; |
|
111 | 143 |
|
112 | 144 |
done_testing(); |
113 | 145 |
clear_up(); |
... | ... | |
120 | 152 |
SL::DB::Manager::Part->delete_all( all => 1); |
121 | 153 |
}; |
122 | 154 |
|
123 |
|
|
124 | 155 |
1; |
125 |
|
Auch abrufbar als: Unified diff
DATEV-Export nach Erfassungsdatum filtern
Hat man einen DATEV-Export schon für einen bestimmten Zeitraum
exportiert, und muß nachträglich noch ein paar Buchungen in dem Zeitraum
tätigen, kann man diese nachträglichen Buchungen nun gesondert
exportieren, indem man ein Datum nach dem letzten Exportdatum
angibt.