Revision f36da7b6
Von Kivitendo Admin vor mehr als 8 Jahren hinzugefügt
SL/Controller/BankTransaction.pm | ||
---|---|---|
436 | 436 |
); |
437 | 437 |
|
438 | 438 |
SL::DB::RecordLink->new(@props)->save; |
439 |
|
|
440 |
# "close" a sepa_export_item if it exists |
|
441 |
# currently only works, if there is only exactly one open sepa_export_item |
|
442 |
if ( my $seis = $invoice->find_sepa_export_items({ executed => 0 }) ) { |
|
443 |
if ( scalar @$seis == 1 ) { |
|
444 |
# moved the execution and the check for sepa_export into a method, |
|
445 |
# this isn't part of a transaction, though |
|
446 |
$seis->[0]->set_executed if $invoice->id == $seis->[0]->arap_id; |
|
447 |
}; |
|
448 |
}; |
|
449 |
|
|
439 | 450 |
} |
440 | 451 |
$bank_transaction->save; |
441 | 452 |
} |
SL/DB/BankTransaction.pm | ||
---|---|---|
71 | 71 |
remote_account_number => 3, |
72 | 72 |
skonto_exact_amount => 5, |
73 | 73 |
wrong_sign => -1, |
74 |
sepa_export_item => 5, |
|
74 | 75 |
); |
75 | 76 |
|
76 | 77 |
my ($agreement,$rule_matches); |
... | ... | |
114 | 115 |
|
115 | 116 |
#search invoice number in purpose |
116 | 117 |
my $invnumber = $invoice->invnumber; |
117 |
# invnumbernhas to have at least 3 characters
|
|
118 |
# invnumber has to have at least 3 characters
|
|
118 | 119 |
my $squashed_purpose = $self->purpose; |
119 | 120 |
$squashed_purpose =~ s/ //g; |
120 | 121 |
if (length($invnumber) > 4 && $squashed_purpose =~ /$invnumber/ && $invoice->is_sales){ |
... | ... | |
206 | 207 |
}; |
207 | 208 |
}; |
208 | 209 |
|
210 |
# if there is exactly one non-executed sepa_export_item for the invoice |
|
211 |
if ( my $seis = $invoice->find_sepa_export_items({ executed => 0 }) ) { |
|
212 |
if ( scalar @$seis == 1 ) { |
|
213 |
my $sei = $seis->[0]; |
|
214 |
|
|
215 |
# test for amount and id matching only, sepa transfer date and bank |
|
216 |
# transaction date needn't match |
|
217 |
my $arap = $invoice->is_sales ? 'ar' : 'ap'; |
|
218 |
if ( abs($self->amount) == ($sei->amount) |
|
219 |
&& $invoice->id == $sei->arap_id |
|
220 |
) { |
|
221 |
$agreement += $points{sepa_export_item}; |
|
222 |
$rule_matches .= 'sepa_export_item(' . $points{'sepa_export_item'} . ') '; |
|
223 |
}; |
|
224 |
} else { |
|
225 |
# zero or more than one sepa_export_item, do nothing for this invoice |
|
226 |
# zero: do nothing, no sepa_export_item exists, no match |
|
227 |
# more than one: does this ever apply? Currently you can't create sepa |
|
228 |
# exports for invoices that already have a non-executed sepa_export |
|
229 |
}; |
|
230 |
}; |
|
231 |
|
|
209 | 232 |
return ($agreement,$rule_matches); |
210 | 233 |
}; |
211 | 234 |
|
SL/DB/SepaExportItem.pm | ||
---|---|---|
1 | 1 |
package SL::DB::SepaExportItem; |
2 | 2 |
|
3 | 3 |
use strict; |
4 |
use SL::DB::SepaExport; |
|
4 | 5 |
|
5 | 6 |
use SL::DB::MetaSetup::SepaExportItem; |
6 | 7 |
|
... | ... | |
20 | 21 |
return $result || ($self->sepa_export_id <=> $other->sepa_export_id) || ($self->id <=> $other->id); |
21 | 22 |
} |
22 | 23 |
|
24 |
sub set_executed { |
|
25 |
my ($self) = @_; |
|
26 |
|
|
27 |
$self->executed(1); # does execution date also need to be set? |
|
28 |
$self->save; |
|
29 |
# if all the sepa_export_items in the sepa_export are closed (executed), close the sepa_export |
|
30 |
if ( SL::DB::Manager::SepaExportItem->get_all_count( where => [ sepa_export_id => $self->sepa_export_id, executed => 0] ) == 0 ) { |
|
31 |
my $sepa_export = SL::DB::Manager::SepaExport->find_by(id => $self->sepa_export_id); |
|
32 |
$sepa_export->executed(1); |
|
33 |
$sepa_export->closed(1); |
|
34 |
$sepa_export->save(changes_only=>1); |
|
35 |
}; |
|
36 |
}; |
|
37 |
|
|
38 |
|
|
39 |
sub arap_id { |
|
40 |
my ($self) = @_; |
|
41 |
if ( $self->ar_id ) { |
|
42 |
return $self->ar_id; |
|
43 |
} else { |
|
44 |
return $self->ap_id; |
|
45 |
}; |
|
46 |
}; |
|
47 |
|
|
23 | 48 |
1; |
Auch abrufbar als: Unified diff
"Kontoauszug verbuchen - SEPA-Zahlungen berücksichtigen und schließen
Erstellt man SEPA-Überweisungen für das Bankprogramm, verbucht die
Zahlungsausgänge aber per "Kontoauszug verbuchen", wird der
ursprüngliche SEPA-Prozess unterbrochen. Dort war vorgesehen, daß man
nach dem Import/Export den SEPA-Export manuell abschliesst, wodurch
automatisch die betroffenen Rechnungen bezahlt wurden, mit dem
Zahlungsdatum laut SEPA-Export. Entfällt dieser Schritt wegen Verbuchung
per Kontoauszug bleiben die SEPA-Exporte hingegen immer offen. Außer daß
die Liste immer weiter wächst hat das auch den Effekt, daß für
Rechnungen mit noch offenen SEPA-Exports nicht erneut SEPA-Überweisungen
erstellt werden können, was bei Teilzahlungen aber erforderlich ist.
Mit dieser Erweiterung wird nun beim "Kontoauszug verbuchen" auch
geprüft, ob es für die Rechnung eine SEPA-Anweisung gibt, und hierfür
extra Punkte vergeben. Außerdem wird bei erfolgreicher Zahlung der
Rechnung auch der SEPA-Export für die Rechnung geschlossen.
Wenn dabei festgestellt wird, daß alle Export einer SEPA-Export-Gruppe
bezahlt sind, wird auch die SEPA-Export-Gruppe geschlossen.