Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6a349447

Von Kivitendo Admin vor mehr als 9 Jahren hinzugefügt

  • ID 6a3494478a287c2820e3f68a09bef700af1f57e0
  • Vorgänger b09bc3de
  • Nachfolger 15f58ff3

DATEV - Buchungscheck prüft nur Buchungen einer trans_id

DATEV-Check für AR/AP/IS/IR/GL:

In der ersten Inkarnation wurden beim Check alle Buchungen des selben
Tages mit geprüft. In der zweiten Version wurde zusätzlich zum
Tagesdatum nach der trans_id der aktuellen Buchung gefiltert. Hatte die
Zahlung ein anderes Datum als die Rechnung wurde die Rechnung nicht
nochmal geprüft.

Jetzt wird beim Datevcheck bei jeder Buchung/Zahlung immer die komplette
Buchung auf Datevkompatibilität geprüft.

Es ist nun auch möglich, einzelne Transaktionen gezielt zu
kontrollieren, z.B. per console, indem man nur die trans_id ohne
von-bis-Datum eingibt.

Tritt ein DATEV-Exportfehler auf wird nun außerdem mehr Information zu
den verdächtigen Buchungen ausgegeben (vorher nur trans_id und amount).

Unterschiede anzeigen:

SL/DATEV.pm
199 199
    $self->{trans_id} = $_[0];
200 200
  }
201 201

  
202
  die "illegal trans_id passed for DATEV export: " . $self->{trans_id} . "\n" unless $self->{trans_id} =~ m/^\d+$/;
203

  
202 204
  return $self->{trans_id};
203 205
}
204 206

  
......
346 348
sub _get_transactions {
347 349
  $main::lxdebug->enter_sub();
348 350
  my $self     = shift;
349
  my $fromto   =  shift;
351
  my $fromto   = shift;
350 352
  my $progress_callback = shift || sub {};
351 353

  
352 354
  my $form     =  $main::form;
353 355

  
354 356
  my $trans_id_filter = '';
355 357

  
356
  $trans_id_filter = 'AND ac.trans_id = ' . $self->trans_id if $self->trans_id;
358
  if ( $self->{trans_id} ) {
359
    # ignore dates when trans_id is passed so that the entire transaction is
360
    # checked, not just either the initial bookings or the subsequent payments
361
    # (the transdates will likely differ)
362
    $fromto = '';
363
    $trans_id_filter = 'ac.trans_id = ' . $self->trans_id;
364
  } else {
365
    $fromto      =~ s/transdate/ac\.transdate/g;
366
  };
357 367

  
358 368
  my ($notsplitindex);
359 369

  
360
  $fromto      =~ s/transdate/ac\.transdate/g;
361

  
362 370
  my $filter   = '';            # Useful for debugging purposes
363 371

  
364 372
  my %all_taxchart_ids = selectall_as_map($form, $self->dbh, qq|SELECT DISTINCT chart_id, TRUE AS is_set FROM tax|, 'chart_id', 'is_set');
......
421 429
  $self->{DATEV} = [];
422 430

  
423 431
  my $counter = 0;
424
  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
432
  my $continue = 1; #
433
  my $name;
434
  while ( $continue && (my $ref = $sth->fetchrow_hashref("NAME_lc")) ) {
435
    last unless $ref;  # for single transactions
425 436
    $counter++;
426 437
    if (($counter % 500) == 0) {
427 438
      $progress_callback->($counter);
......
445 456
    # keep fetching new acc_trans lines until the end of a balanced group is reached
446 457
    while (abs($count) > 0.01 || $firstrun || ($subcent && abs($count) > 0.005)) {
447 458
      my $ref2 = $sth->fetchrow_hashref("NAME_lc");
448
      last unless ($ref2);
459
      unless ( $ref2 ) {
460
        $continue = 0;
461
        last;
462
      };
449 463

  
450 464
      # check if trans_id of current acc_trans line is still the same as the
451
      # trans_id of the first line in group
465
      # trans_id of the first line in group, i.e. we haven't finished a 0-group
466
      # before moving on to the next trans_id, error will likely be in the old
467
      # trans_id.
452 468

  
453 469
      if ($ref2->{trans_id} != $trans->[0]->{trans_id}) {
454
        $self->add_error("Unbalanced ledger! old trans_id " . $trans->[0]->{trans_id} . " new trans_id " . $ref2->{trans_id} . " count $count");
470
        require SL::DB::Manager::AccTransaction;
471
        if ( $trans->[0]->{trans_id} ) {
472
          my $acc_trans_old_obj  = SL::DB::Manager::AccTransaction->get_first(where => [ trans_id => $trans->[0]->{trans_id} ]);
473
          $self->add_error("Unbalanced ledger! Old: " . $acc_trans_old_obj->transaction_name) if ref($acc_trans_old_obj);
474
        };
475
        if ( $ref2->{trans_id} ) {
476
          my $acc_trans_curr_obj = SL::DB::Manager::AccTransaction->get_first(where => [ trans_id => $ref2->{trans_id} ]);
477
          $self->add_error("Unbalanced ledger! New:" . $acc_trans_curr_obj->transaction_name) if ref($acc_trans_curr_obj);
478
        };
479
        $self->add_error("count: $count");
455 480
        return;
456 481
      }
457 482

  
......
618 643

  
619 644
    $absumsatz = $form->round_amount($absumsatz, 2);
620 645
    if (abs($absumsatz) >= (0.01 * (1 + scalar @taxed))) {
621
      $self->add_error("Datev-Export fehlgeschlagen! Bei Transaktion $trans->[0]->{trans_id} ($absumsatz)");
646
      require SL::DB::Manager::AccTransaction;
647
      my $acc_trans_obj  = SL::DB::Manager::AccTransaction->get_first(where => [ trans_id => $trans->[0]->{trans_id} ]);
648
      $self->add_error("Datev-Export fehlgeschlagen! Bei Transaktion " . $acc_trans_obj->transaction_name . " ($absumsatz)");
622 649

  
623 650
    } elsif (abs($absumsatz) >= 0.01) {
624 651
      $self->add_net_gross_differences($absumsatz);
......
1066 1093

  
1067 1094
  use SL::DATEV qw(:CONSTANTS);
1068 1095

  
1096
  my $startdate = DateTime->new(year => 2014, month => 9, day => 1);
1097
  my $enddate   = DateTime->new(year => 2014, month => 9, day => 31);
1069 1098
  my $datev = SL::DATEV->new(
1070 1099
    exporttype => DATEV_ET_BUCHUNGEN,
1071 1100
    format     => DATEV_FORMAT_KNE,
......
1073 1102
    to         => $enddate,
1074 1103
  );
1075 1104

  
1105
  # To only export transactions from a specific trans_id: (from and to are ignored)
1106
  my $invoice = SL::DB::Manager::Invoice->find_by( invnumber => '216' );
1107
  my $datev = SL::DATEV->new(
1108
    exporttype => DATEV_ET_BUCHUNGEN,
1109
    format     => DATEV_FORMAT_KNE,
1110
    trans_id   => $invoice->trans_id,
1111
  );
1112

  
1076 1113
  my $datev = SL::DATEV->new(
1077 1114
    exporttype => DATEV_ET_STAMM,
1078 1115
    format     => DATEV_FORMAT_KNE,
......
1084 1121
  my $hashref = $datev->get_datev_stamm;
1085 1122
  $datev->save_datev_stamm($hashref);
1086 1123

  
1087
  # manually clean up temporary directories
1124
  # manually clean up temporary directories older than 8 hours
1088 1125
  $datev->clean_temporary_directories;
1089 1126

  
1090 1127
  # export
......
1117 1154

  
1118 1155
=item new PARAMS
1119 1156

  
1120
Generic constructor. See section attributes for information about hat to pass.
1157
Generic constructor. See section attributes for information about what to pass.
1121 1158

  
1122 1159
=item get_datev_stamm
1123 1160

  
......
1159 1196

  
1160 1197
=item filenames
1161 1198

  
1162
Returns a list of filenames generated by this DATEV object. This only works if th files were generated during it's lifetime, not if the object was created from a download_token.
1199
Returns a list of filenames generated by this DATEV object. This only works if the files were generated during its lifetime, not if the object was created from a download_token.
1163 1200

  
1164 1201
=item net_gross_differences
1165 1202

  
......
1211 1248

  
1212 1249
=item to
1213 1250

  
1214
Set boundary dates for the export. Currently thse MUST be set for the export to work.
1251
Set boundary dates for the export. Unless a trans_id is passed these MUST be
1252
set for the export to work.
1253

  
1254
=item trans_id
1255

  
1256
To check only one gl/ar/ap transaction, pass the trans_id. The attributes
1257
L<from> and L<to> are currently still needed for the query to be assembled
1258
correctly.
1215 1259

  
1216 1260
=item accnofrom
1217 1261

  
......
1255 1299

  
1256 1300
=item *
1257 1301

  
1258
OBE rxport was called, which is not yet implemented.
1302
OBE export was called, which is not yet implemented.
1259 1303

  
1260 1304
=item *
1261 1305

  
......
1274 1318
=item *
1275 1319

  
1276 1320
C<Datev-Export fehlgeschlagen! Bei Transaktion %d (%f).>  This error occurs if a
1277
transaction could not be reliably sorted out, or had rounding errors over the acceptable threshold.
1321
transaction could not be reliably sorted out, or had rounding errors above the acceptable threshold.
1278 1322

  
1279 1323
=back
1280 1324

  
......
1284 1328

  
1285 1329
=item *
1286 1330

  
1287
Handling of Vollvorlauf is currently not fully implemented. You must provide both from and to to get a working export.
1331
Handling of Vollvorlauf is currently not fully implemented. You must provide both from and to in order to get a working export.
1288 1332

  
1289 1333
=item *
1290 1334

  

Auch abrufbar als: Unified diff