Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 03007e57

Von G. Richardson vor fast 4 Jahren hinzugefügt

  • ID 03007e57dd84ccebbc7f00a4480d64b54539b60b
  • Vorgänger bd218b67
  • Nachfolger 1b8b9cd4

artransactions.t - Umstellung Konjunkturpaket

Tests, bei denen Salden abgefragt werden, auf 2019 umgestellt.

Unterschiede anzeigen:

t/controllers/csvimport/artransactions.t
26 26
use SL::DB::AccTransaction;
27 27

  
28 28
my ($customer, $currency_id, $employee, $taxzone, $project, $department);
29
my ($transdate, $transdate_string);
29 30

  
30 31
sub reset_state {
31 32
  # Create test data
32 33
  my %params = @_;
33 34

  
35
  $transdate = DateTime->today_local;
36
  $transdate->set_year(2019) if $transdate->year == 2020; # hardcode for 2019 in 2020, because of tax rate change in Germany
37
  $transdate_string = $transdate->to_kivitendo;
38

  
34 39
  $params{$_} ||= {} for qw(buchungsgruppe customer tax);
35 40

  
36 41
  clear_up();
......
96 101

  
97 102
##### manually create an ar transaction from scratch, testing the methods
98 103
$::myconfig{numberformat} = '1000.00';
104
$::myconfig{dateformat}   = 'dd.mm.yyyy';
99 105
my $old_locale = $::locale;
100 106
# set locale to en so we can match errors
101 107
$::locale = Locale->new('en');
......
109 115
  currency_id  => $currency_id,
110 116
  taxincluded  => 'f',
111 117
  customer_id  => $customer->id,
112
  transdate    => DateTime->today,
118
  transdate    => $transdate,
113 119
  employee_id  => SL::DB::Manager::Employee->current->id,
114 120
  transactions => [],
115 121
);
......
138 144

  
139 145
$ar->pay_invoice(  chart_id      => SL::DB::Manager::Chart->find_by(accno => '1200')->id, # bank
140 146
                   amount        => $ar->open_amount,
141
                   transdate     => DateTime->now->to_kivitendo,
147
                   transdate     => $transdate,
142 148
                   payment_type  => 'without_skonto',  # default if not specified
143 149
                  );
144 150
$result = $ar->validate_acc_trans(debug => 0);
......
152 158
# to debug errors in certain tests, run after test_import:
153 159
#   die Dumper($entry->{errors});
154 160
##### basic test
155
$file = \<<EOL;
156
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart
161
$file = \<<"EOL";
162
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart,transdate
157 163
datatype,accno,amount,taxkey
158
"Rechnung",960,4,1,"invoice 1",f,1400
164
"Rechnung",960,4,1,"invoice 1",f,1400,"$transdate_string"
159 165
"AccTransaction",8400,159.48,3
160 166
EOL
161 167
$entries = test_import($file);
......
172 178
is $entry->{object}->netamount, '159.48', 'ar netamount tax not included is 159.48';
173 179

  
174 180
##### test for duplicate invnumber
175
$file = \<<EOL;
176
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart
181
$file = \<<"EOL";
182
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart,transdate
177 183
datatype,accno,amount,taxkey
178
"Rechnung",960,4,1,"invoice 1",f,1400
184
"Rechnung",960,4,1,"invoice 1",f,1400,"$transdate_string"
179 185
"AccTransaction",8400,159.48,3
180 186
EOL
181 187
$entries = test_import($file);
......
184 190
is $entry->{errors}->[0], 'Error: invnumber already exists', 'detects verify_amount differences';
185 191

  
186 192
##### test for no invnumber given
187
$file = \<<EOL;
188
datatype,customer_id,taxzone_id,currency_id,taxincluded,archart
193
$file = \<<"EOL";
194
datatype,customer_id,taxzone_id,currency_id,taxincluded,archart,transdate
189 195
datatype,accno,amount,taxkey
190
"Rechnung",960,4,1,f,1400
196
"Rechnung",960,4,1,f,1400,"$transdate_string"
191 197
"AccTransaction",8400,159.48,3
192 198
EOL
193 199
$entries = test_import($file);
......
196 202
is $entry->{object}->invnumber =~ /^\d+$/, 1, 'invnumber assigned automatically';
197 203

  
198 204
##### basic test without amounts in Rechnung, only specified in AccTransaction
199
$file = \<<EOL;
200
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart
205
$file = \<<"EOL";
206
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart,transdate
201 207
datatype,accno,amount,taxkey
202
"Rechnung",960,4,1,"invoice 1 no amounts",f,1400
208
"Rechnung",960,4,1,"invoice 1 no amounts",f,1400,"$transdate_string"
203 209
"AccTransaction",8400,159.48,3
204 210
EOL
205 211
$entries = test_import($file);
......
214 220
is $::form->round_amount($entry->{object}->transactions->[0]->amount, 2), 159.48, 'invoice 1 ar amount is 159.48';
215 221

  
216 222
##### basic test: credit_note
217
$file = \<<EOL;
218
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart
223
$file = \<<"EOL";
224
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart,transdate
219 225
datatype,accno,amount,taxkey
220
"Rechnung",960,4,1,"credit note",f,1400
226
"Rechnung",960,4,1,"credit note",f,1400,"$transdate_string"
221 227
"AccTransaction",8400,-159.48,3
222 228
EOL
223 229
$entries = test_import($file);
......
233 239
is $entry->{object}->netamount, '-159.48', 'credit note netamount tax not included is 159.48';
234 240

  
235 241
#### verify_amount differs: max_amount_diff = 0.02, 189.80 is ok, 189.81 is not
236
$file = \<<EOL;
237
datatype,customer_id,verify_amount,verify_netamount,taxzone_id,currency_id,invnumber,taxincluded,archart
242
$file = \<<"EOL";
243
datatype,customer_id,verify_amount,verify_netamount,taxzone_id,currency_id,invnumber,taxincluded,archart,transdate
238 244
datatype,accno,amount,taxkey
239
"Rechnung",960,189.81,159.48,4,1,"invoice amounts differing",f,1400
245
"Rechnung",960,189.81,159.48,4,1,"invoice amounts differing",f,1400,"$transdate_string"
240 246
"AccTransaction",8400,159.48,3
241 247
EOL
242 248
$entries = test_import($file);
......
244 250
is $entry->{errors}->[0], 'Amounts differ too much', 'detects verify_amount differences';
245 251

  
246 252
#####  direct debit
247
$file = \<<EOL;
248
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,direct_debit,archart
253
$file = \<<"EOL";
254
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,direct_debit,archart,transdate
249 255
datatype,accno,amount,taxkey
250
"Rechnung",960,4,1,"invoice with direct debit",f,t,1400
256
"Rechnung",960,4,1,"invoice with direct debit",f,t,1400,"$transdate_string"
251 257
"AccTransaction",8400,159.48,3
252 258
EOL
253 259

  
......
257 263
is $entry->{object}->direct_debit, '1', 'direct debit';
258 264

  
259 265
#### tax included
260
$file = \<<EOL;
261
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart
266
$file = \<<"EOL";
267
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart,transdate
262 268
datatype,accno,amount,taxkey
263
"Rechnung",960,4,1,"invoice 1 tax included no amounts",t,1400
269
"Rechnung",960,4,1,"invoice 1 tax included no amounts",t,1400,"$transdate_string"
264 270
"AccTransaction",8400,189.78,3
265 271
EOL
266 272

  
......
273 279
is $::form->round_amount($entry->{object}->transactions->[0]->amount, 2), '159.48', 'taxincluded acc_trans netamount';
274 280

  
275 281
#### multiple tax included
276
$file = \<<EOL;
277
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart
282
$file = \<<"EOL";
283
datatype,customer_id,taxzone_id,currency_id,invnumber,taxincluded,archart,transdate
278 284
datatype,accno,amount,taxkey
279
"Rechnung",960,4,1,"invoice multiple tax included",t,1400
285
"Rechnung",960,4,1,"invoice multiple tax included",t,1400,"$transdate_string"
280 286
"AccTransaction",8400,94.89,3
281 287
"AccTransaction",8400,94.89,3
282 288
EOL

Auch abrufbar als: Unified diff