Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 09a2093d

Von G. Richardson vor mehr als 4 Jahren hinzugefügt

  • ID 09a2093df3c809a942af7676f0e9bec30808410c
  • Vorgänger 09dd8754
  • Nachfolger e765ebf8

DATEV Export Lieferdatum - für Dialogbuchungzahlungen wieder erlauben

In Commit eab277a411 wurde das Lieferdatum für Buchungen auf
"Zahlungs"konten deaktiviert. Für Einkaufs- und Verkaufsrechnungen ist
das auch korrekt, hier soll nur die Hauptbuchung im DATEV-Export mit
Lieferdatum exportiert werden, die Zahlungen sind vom Lieferdatum
unabhängig. (Zumindest solange nicht automatisch Steuer bei
Skontobuchungen berücksichtigt wird).

Bei Dialogbuchungen soll hingegen schon das Lieferdatum erscheinen, auch
wenn eins der Buchungskonten z.B. Bank ist. Ob das Lieferdatum bei der
entsprechenden Dialogbuchung sinnvoll ist muß natürlich der Bucher
entscheiden.

Hierfür wurde auch einer der DATEV-Tests überarbeitet.

Unterschiede anzeigen:

SL/DATEV.pm
1051 1051
      if (($transaction->[$haben]->{'duedate'} // '') ne "") {
1052 1052
        $datev_data{belegfeld2} = $transaction->[$haben]->{'duedate'};
1053 1053
      }
1054
      if (($transaction->[$haben]->{'deliverydate'} // '') ne "" &&
1055
          $transaction->[$haben]->{'link'} !~ m/_paid/           &&
1056
          $transaction->[$soll]->{'link'}  !~ m/_paid/              ) {
1054

  
1055
      # if deliverydate exists, add it to datev export if it is
1056
      # * an ar/ap booking that is not a payment
1057
      # * a gl booking
1058
      if (    ($transaction->[$haben]->{'deliverydate'} // '') ne ''
1059
           && (
1060
                (    $transaction->[$haben]->{'table'} =~ /^(ar|ap)$/
1061
                  && $transaction->[$haben]->{'link'}  !~ m/_paid/
1062
                  && $transaction->[$soll]->{'link'}   !~ m/_paid/
1063
                )
1064
                || $transaction->[$haben]->{'table'} eq 'gl'
1065
              )
1066
         ) {
1057 1067
        $datev_data{leistungsdatum} = $transaction->[$haben]->{'deliverydate'};
1058 1068
      }
1059 1069
    }
t/datev/datev_format_2018.t
28 28
my $date            = DateTime->new(year => 2017, month =>  7, day => 19);
29 29
my $department      = create_department(description => 'Kästchenweiße heiße Preise');
30 30
my $project         = create_project(projectnumber => 2017, description => '299');
31
my $bank            = SL::DB::Manager::Chart->find_by(description => 'Bank') || die 'Can\'t find chart "Bank"';
31 32
my $customer        = new_customer(name => 'Test customer', ustid => $ustid)->save();
32 33
my $part1 = new_part(partnumber => '19', description => 'Part 19%')->save;
33 34
my $part2 = new_part(
......
51 52
);
52 53

  
53 54
# lets make a boom
54
# generate_datev_* doesnt care about encoding but
55
# generate_datev_* doesn't care about encoding but
55 56
# csv_buchungsexport does! all arabic will be deleted
56 57
# and no string will be left as invnumber
57 58

  
......
61 62
);
62 63

  
63 64
my $startdate = DateTime->new(year => 2017, month =>  1, day =>  1);
64
my $enddate   = DateTime->new(year => 2017, month =>  12, day => 31);
65
my $enddate   = DateTime->new(year => 2017, month => 12, day => 31);
65 66
my $today     = DateTime->new(year => 2017, month =>  3, day => 17);
66 67

  
67

  
68 68
$datev1->from($startdate);
69 69
$datev1->to($enddate);
70 70

  
......
122 122
$invoice->invnumber('meine muh');
123 123
$invoice->save();
124 124

  
125
$invoice->pay_invoice(chart_id      => $bank->id,
126
                      amount        => $invoice->open_amount,
127
                      transdate     => $invoice->transdate->clone->add(days => 10),
128
                      memo          => 'foobar',
129
                      source        => 'barfoo',
130
                     );
131

  
125 132
my $datev4 = SL::DATEV->new(
126 133
  dbh        => $dbh,
127 134
  trans_id   => $invoice->id,
......
148 155
ok(!($die_message3), 'no die message');
149 156
ok(scalar @{ $datev_csv4->warnings } == 0, 'no warnings');
150 157

  
151
my @sorted =  sort { $a->[0] cmp $b->[0] } @{ $lines_aref };
152
cmp_deeply $sorted[0],    [ '1963,5', 'S', 'EUR', '', '', '',
153
                            '1400', '8400', '', '1907', 'meine muh',
154
                            '', '', 'Test customer', '', '', '', '', '', '',
155
                            '', '', '', '', '', '', '', '', '',
156
                            '', '', '', '', '', '', '', "K\x{e4}stchen",
157
                            '299', '', $ustid, '', '', '',
158
                            '', '', '', '', '', '', '', '', '',
159
                            '', '', '', '', '', '', '', '', '',
160
                            '', '', '', '', '', '', '', '', '',
161
                            '', '', '', '', '', '', '', '', '',
162
                            '', '', '', '', '', '', '', '', '',
163
                            '', '', '', '', '', '', '', '', '',
164
                            '', '', '', '', '', '', '', '', '',
165
                            '', '', '', '', '', '', '', '1', '',
166
                            '', '', '', '', '',
167
                          ];
168
cmp_deeply $sorted[1],     [ '535', 'S', 'EUR', '', '', '',
169
                             '1400', '8300', '', '1907','meine muh',
170
                            '', '', 'Test customer', '', '', '', '', '', '',
171
                            '', '', '', '', '', '', '', '', '',
172
                            '', '', '', '', '', '', '', "K\x{e4}stchen",
173
                            '299', '', $ustid, '', '', '',
174
                            '', '', '', '', '', '', '', '', '',
175
                            '', '', '', '', '', '', '', '', '',
176
                            '', '', '', '', '', '', '', '', '',
177
                            '', '', '', '', '', '', '', '', '',
178
                            '', '', '', '', '', '', '', '', '',
179
                            '', '', '', '', '', '', '', '', '',
180
                            '', '', '', '', '', '', '', '', '',
181
                            '', '', '', '', '', '', '', '1', '',
182
                            '', '', '', '', '',
183
                          ];
158

  
159
note('testing invoice without deliverydate');
160
my @sorted =  sort { $a->[0] cmp $b->[0] } @{ $lines_aref }; # sort by string-comparison of amount
161
cmp_deeply $sorted[0],
162
           [ '1963,5', 'S', 'EUR', '', '', '',
163
             '1400', '8400', '', '1907', 'meine muh',
164
             '', '', 'Test customer', '', '', '', '', '', '',
165
             '', '', '', '', '', '', '', '', '',
166
             '', '', '', '', '', '', '', "K\x{e4}stchen",
167
             '299', '', $ustid, '', '', '',
168
             '', '', '', '', '', '', '', '', '',
169
             '', '', '', '', '', '', '', '', '',
170
             '', '', '', '', '', '', '', '', '',
171
             '', '', '', '', '', '', '', '', '',
172
             '', '', '', '', '', '', '', '', '',
173
             '', '', '', '', '', '', '', '', '',
174
             '', '', '', '', '', '', '', '', '',
175
             '', '', '', '', '', '', '', '1', '',
176
             '', '', '', '', '',
177
           ],
178
           'invoice without deliverydate 19% tax export ok';
179
cmp_deeply $sorted[2],
180
           [ '535', 'S', 'EUR', '', '', '',
181
             '1400', '8300', '', '1907','meine muh',
182
             '', '', 'Test customer', '', '', '', '', '', '',
183
             '', '', '', '', '', '', '', '', '',
184
             '', '', '', '', '', '', '', "K\x{e4}stchen",
185
             '299', '', $ustid, '', '', '',
186
             '', '', '', '', '', '', '', '', '',
187
             '', '', '', '', '', '', '', '', '',
188
             '', '', '', '', '', '', '', '', '',
189
             '', '', '', '', '', '', '', '', '',
190
             '', '', '', '', '', '', '', '', '',
191
             '', '', '', '', '', '', '', '', '',
192
             '', '', '', '', '', '', '', '', '',
193
             '', '', '', '', '', '', '', '1', '',
194
             '', '', '', '', '',
195
           ],
196
           'invoice without deliverydate 16% tax export ok';
197
cmp_deeply $sorted[1],
198
           [ '2498,5', 'S', 'EUR', '', '', '',
199
             '1200', '1400', '', '2907','meine muh',
200
             '', '', 'Test customer', '', '', '', '', '', '',
201
             '', '', '', '', '', '', '', '', '',
202
             '', '', '', '', '', '', '', "K\x{e4}stchen",
203
             '299', '', $ustid, '', '', '',
204
             '', '', '', '', '', '', '', '', '',
205
             '', '', '', '', '', '', '', '', '',
206
             '', '', '', '', '', '', '', '', '',
207
             '', '', '', '', '', '', '', '', '',
208
             '', '', '', '', '', '', '', '', '',
209
             '', '', '', '', '', '', '', '', '',
210
             '', '', '', '', '', '', '', '', '',
211
             '', '', '', '', '', '', '', '1', '',
212
             '', '', '', '', '',
213
           ],
214
           'invoice without deliverydate payment export ok';
215

  
184 216
# create one haben buchung with GLTransaction today
185 217

  
186 218
my $expense_chart = SL::DB::Manager::Chart->find_by(accno => '4660'); # Reisekosten
187 219
my $cash_chart    = SL::DB::Manager::Chart->find_by(accno => '1000'); # Kasse
188 220

  
221
note('testing gl transaction without deliverydate');
189 222
my $gl_transaction = create_gl_transaction(
190 223
  reference      => "Reise März 2018",
191
  description    => "Reisekonsten März 2018 / Ma Schmidt",
224
  description    => "Reisekosten März 2018 / Ma Schmidt",
192 225
  transdate      => $today,
193 226
  taxincluded    => 1,
194 227
  type           => undef,
......
222 255
                                     );
223 256

  
224 257
my @data_csv    = sort { $a->[0] cmp $b->[0] } @{ $datev_csv3->lines };
225
cmp_deeply($data_csv[0], [ '100', 'S', 'EUR', '', '', '', '4660', '1000', 9, '1703', 'Reise März 2',
226
                     '', '', 'Reisekonsten März 2018 / Ma Schmidt', '', '', '', '', '', '', '', '',
227
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
228
                     '', '', '', '', '', '', '', '', '', '', '',
229
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
230
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
231
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
232
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
233
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
234
                     '', '', '1', '', '', '', '', '', '', ]
235
       );
236

  
237

  
238
# check deliverydate
258
cmp_deeply($data_csv[0],
259
           [ '100', 'S', 'EUR', '', '', '', '4660', '1000', 9, '1703', 'Reise März 2',
260
             '', '', 'Reisekosten März 2018 / Ma Schmidt', '', '', '', '', '', '', '', '',
261
             '', '', '', '', '', '', '', '', '', '', '', '', '',
262
             '', '', '', '', '', '', '', '', '', '', '',
263
             '', '', '', '', '', '', '', '', '', '', '', '', '',
264
             '', '', '', '', '', '', '', '', '', '', '', '', '',
265
             '', '', '', '', '', '', '', '', '', '', '', '', '',
266
             '', '', '', '', '', '', '', '', '', '', '', '', '',
267
             '', '', '', '', '', '', '', '', '', '', '', '', '',
268
             '', '', '1', '', '', '', '', '', '',
269
           ],
270
           'gl datev export without delivery date ok');
271

  
272

  
273
note('testing same invoice, but with deliverydate');
274
# 8400 and 8300 should have deliverydate in datev, payment should not
239 275
$invoice->deliverydate(DateTime->new(year => 2017, month =>  7, day => 18));
240 276
$invoice->save();
241 277

  
......
255 291
                                 locked       => $datev1->locked,
256 292
);
257 293
@sorted    = sort { $a->[0] cmp $b->[0] } @{ $datev_csv->lines };
258
cmp_deeply $sorted[0],    [ '1963,5', 'S', 'EUR', '', '', '',
259
                            '1400', '8400', '', '1907', 'meine muh',
260
                            '', '', 'Test customer', '', '', '', '', '', '',
261
                            '', '', '', '', '', '', '', '', '',
262
                            '', '', '', '', '', '', '', "K\x{e4}stchen",
263
                            '299', '', $ustid, '', '', '',
264
                            '', '', '', '', '', '', '', '', '',
265
                            '', '', '', '', '', '', '', '', '',
266
                            '', '', '', '', '', '', '', '', '',
267
                            '', '', '', '', '', '', '', '', '',
268
                            '', '', '', '', '', '', '', '', '',
269
                            '', '', '', '', '', '', '', '', '',
270
                            '', '', '', '', '', '', '', '', '',
271
                            '', '', '', '', '', '', '', '1', '18072017',
272
                            '', '', '', '', '',
273
                          ];
274
cmp_deeply $sorted[1],     [ '535', 'S', 'EUR', '', '', '',
275
                             '1400', '8300', '', '1907','meine muh',
276
                            '', '', 'Test customer', '', '', '', '', '', '',
277
                            '', '', '', '', '', '', '', '', '',
278
                            '', '', '', '', '', '', '', "K\x{e4}stchen",
279
                            '299', '', $ustid, '', '', '',
280
                            '', '', '', '', '', '', '', '', '',
281
                            '', '', '', '', '', '', '', '', '',
282
                            '', '', '', '', '', '', '', '', '',
283
                            '', '', '', '', '', '', '', '', '',
284
                            '', '', '', '', '', '', '', '', '',
285
                            '', '', '', '', '', '', '', '', '',
286
                            '', '', '', '', '', '', '', '', '',
287
                            '', '', '', '', '', '', '', '1', '18072017',
288
                            '', '', '', '', '',
289
                          ];
290

  
294
cmp_deeply $sorted[0],
295
           [ '1963,5', 'S', 'EUR', '', '', '',
296
             '1400', '8400', '', '1907', 'meine muh',
297
             '', '', 'Test customer', '', '', '', '', '', '',
298
             '', '', '', '', '', '', '', '', '',
299
             '', '', '', '', '', '', '', "K\x{e4}stchen",
300
             '299', '', $ustid, '', '', '',
301
             '', '', '', '', '', '', '', '', '',
302
             '', '', '', '', '', '', '', '', '',
303
             '', '', '', '', '', '', '', '', '',
304
             '', '', '', '', '', '', '', '', '',
305
             '', '', '', '', '', '', '', '', '',
306
             '', '', '', '', '', '', '', '', '',
307
             '', '', '', '', '', '', '', '', '',
308
             '', '', '', '', '', '', '', '1', '18072017',
309
             '', '', '', '', '',
310
           ],
311
           'invoice with deliverydate 19% tax export ok';
312

  
313
cmp_deeply $sorted[2],
314
           [ '535', 'S', 'EUR', '', '', '',
315
             '1400', '8300', '', '1907','meine muh',
316
             '', '', 'Test customer', '', '', '', '', '', '',
317
             '', '', '', '', '', '', '', '', '',
318
             '', '', '', '', '', '', '', "K\x{e4}stchen",
319
             '299', '', $ustid, '', '', '',
320
             '', '', '', '', '', '', '', '', '',
321
             '', '', '', '', '', '', '', '', '',
322
             '', '', '', '', '', '', '', '', '',
323
             '', '', '', '', '', '', '', '', '',
324
             '', '', '', '', '', '', '', '', '',
325
             '', '', '', '', '', '', '', '', '',
326
             '', '', '', '', '', '', '', '', '',
327
             '', '', '', '', '', '', '', '1', '18072017',
328
             '', '', '', '', '',
329
           ],
330
           'invoice with deliverydate 16% tax export ok';
331

  
332
cmp_deeply $sorted[1],
333
           [ '2498,5', 'S', 'EUR', '', '', '',
334
             '1200', '1400', '', '2907','meine muh',
335
             '', '', 'Test customer', '', '', '', '', '', '',
336
             '', '', '', '', '', '', '', '', '',
337
             '', '', '', '', '', '', '', "K\x{e4}stchen",
338
             '299', '', $ustid, '', '', '',
339
             '', '', '', '', '', '', '', '', '',
340
             '', '', '', '', '', '', '', '', '',
341
             '', '', '', '', '', '', '', '', '',
342
             '', '', '', '', '', '', '', '', '',
343
             '', '', '', '', '', '', '', '', '',
344
             '', '', '', '', '', '', '', '', '',
345
             '', '', '', '', '', '', '', '', '',
346
             '', '', '', '', '', '', '', '1', '',
347
             '', '', '', '', '',
348
           ],
349
           'invoice with deliverydate payment export ok';
350

  
351
note('testing same gl transaction with deliverydate');
291 352
$gl_transaction->deliverydate(DateTime->new(year => 2017, month =>  7, day => 18));
292 353
$gl_transaction->save;
293 354

  
......
307 368
);
308 369

  
309 370
@sorted      = sort { $a->[0] cmp $b->[0] } @{ $datev_csv->lines };
310
cmp_deeply($sorted[0], [ '100', 'S', 'EUR', '', '', '', '4660', '1000', 9, '1703', 'Reise März 2',
311
                         '', '', 'Reisekonsten März 2018 / Ma Schmidt', '', '', '', '', '', '', '', '',
312
                         '', '', '', '', '', '', '', '', '', '', '', '', '',
313
                         '', '', '', '', '', '', '', '', '', '', '',
314
                         '', '', '', '', '', '', '', '', '', '', '', '', '',
315
                         '', '', '', '', '', '', '', '', '', '', '', '', '',
316
                         '', '', '', '', '', '', '', '', '', '', '', '', '',
317
                         '', '', '', '', '', '', '', '', '', '', '', '', '',
318
                         '', '', '', '', '', '', '', '', '', '', '', '', '',
319
                         '', '', '1', '', '', '', '', '', '', ]
320
);
321

  
371
cmp_deeply($sorted[0],
372
           [ '100', 'S', 'EUR', '', '', '', '4660', '1000', 9, '1703', 'Reise März 2',
373
             '', '', 'Reisekosten März 2018 / Ma Schmidt', '', '', '', '', '', '', '', '',
374
             '', '', '', '', '', '', '', '', '', '', '', '', '',
375
             '', '', '', '', '', '', '', '', '', '', '',
376
             '', '', '', '', '', '', '', '', '', '', '', '', '',
377
             '', '', '', '', '', '', '', '', '', '', '', '', '',
378
             '', '', '', '', '', '', '', '', '', '', '', '', '',
379
             '', '', '', '', '', '', '', '', '', '', '', '', '',
380
             '', '', '', '', '', '', '', '', '', '', '', '', '',
381
             '', '', '1', '18072017', '', '', '', '', '',
382
           ],
383
          'testing gl transaction with delivery date datev export ok');
322 384

  
323 385
# TODO warnings are not yet tested
324 386
# currently most of the valid_checks are senseless because of

Auch abrufbar als: Unified diff