Revision 00ce6f4f
Von Kivitendo Admin vor mehr als 8 Jahren hinzugefügt
SL/DB/Helper/Payment.pm | ||
---|---|---|
4 | 4 |
|
5 | 5 |
use parent qw(Exporter); |
6 | 6 |
our @EXPORT = qw(pay_invoice); |
7 |
our @EXPORT_OK = qw(skonto_date skonto_charts amount_less_skonto within_skonto_period percent_skonto reference_account reference_amount open_amount open_percent remaining_skonto_days skonto_amount check_skonto_configuration valid_skonto_amount get_payment_suggestions validate_payment_type open_sepa_transfer_amount get_payment_select_options_for_bank_transaction); |
|
7 |
our @EXPORT_OK = qw(skonto_date skonto_charts amount_less_skonto within_skonto_period percent_skonto reference_account reference_amount open_amount open_percent remaining_skonto_days skonto_amount check_skonto_configuration valid_skonto_amount get_payment_suggestions validate_payment_type open_sepa_transfer_amount get_payment_select_options_for_bank_transaction create_bank_transaction);
|
|
8 | 8 |
our %EXPORT_TAGS = ( |
9 | 9 |
"ALL" => [@EXPORT, @EXPORT_OK], |
10 | 10 |
); |
... | ... | |
624 | 624 |
return 1; |
625 | 625 |
} |
626 | 626 |
|
627 |
sub create_bank_transaction { |
|
628 |
my ($self, %params) = @_; |
|
629 |
|
|
630 |
require SL::DB::Chart; |
|
631 |
require SL::DB::BankAccount; |
|
632 |
|
|
633 |
my $bank_chart; |
|
634 |
if ( $params{chart_id} ) { |
|
635 |
$bank_chart = SL::DB::Manager::Chart->find_by(chart_id => $params{chart_id}) or die "Can't find bank chart"; |
|
636 |
} elsif ( $::instance_conf->get_ar_paid_accno_id ) { |
|
637 |
$bank_chart = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_ar_paid_accno_id); |
|
638 |
} else { |
|
639 |
$bank_chart = SL::DB::Manager::Chart->find_by(description => 'Bank') or die "Can't find bank chart"; |
|
640 |
}; |
|
641 |
my $bank_account = SL::DB::Manager::BankAccount->find_by(chart_id => $bank_chart->id) or die "Can't find bank account for chart"; |
|
642 |
|
|
643 |
my $multiplier = $self->is_sales ? 1 : -1; |
|
644 |
my $amount = ($params{amount} || $self->amount) * $multiplier; |
|
645 |
|
|
646 |
my $transdate = $params{transdate} || DateTime->today; |
|
647 |
|
|
648 |
my $bt = SL::DB::BankTransaction->new( |
|
649 |
local_bank_account_id => $bank_account->id, |
|
650 |
remote_bank_code => $self->customervendor->bank_code, |
|
651 |
remote_account_number => $self->customervendor->account_number, |
|
652 |
transdate => $transdate, |
|
653 |
valutadate => $transdate, |
|
654 |
amount => $::form->round_amount($amount, 2), |
|
655 |
currency => $self->currency->id, |
|
656 |
remote_name => $self->customervendor->depositor, |
|
657 |
purpose => $self->invnumber |
|
658 |
)->save; |
|
659 |
}; |
|
660 |
|
|
661 |
|
|
627 | 662 |
sub _round { |
628 | 663 |
my $value = shift; |
629 | 664 |
my $num_dec = 2; |
... | ... | |
955 | 990 |
without_skonto and with_skonto_pt if payment date is within skonto_date, |
956 | 991 |
preselect with_skonto_pt, otherwise preselect without skonto. |
957 | 992 |
|
993 |
=item C<create_bank_transaction %params> |
|
994 |
|
|
995 |
Method used for testing purposes, allows you to quickly create bank |
|
996 |
transactions from invoices to have something to test payments against. |
|
997 |
|
|
998 |
my $ap = SL::DB::Manager::Invoice->find_by(id => 41); |
|
999 |
$ap->create_bank_transaction(amount => $ap->amount/2, transdate => DateTime->today->add(days => 5)); |
|
1000 |
|
|
1001 |
Amount is always relative to the absolute amount of the invoice, use positive |
|
1002 |
values for sales and purchases. |
|
1003 |
|
|
958 | 1004 |
=back |
959 | 1005 |
|
960 | 1006 |
=head1 TODO AND CAVEATS |
Auch abrufbar als: Unified diff
Neue PaymentHelper Funktion create_bank_transaction
Simuliert den MT940-Import und erstellt gültige Kontoauszugsimportzeilen für
Rechnungen, mit denen man z.B. den "Kontoauszug verbuchen" testen kann.
Ist also v.A. für Tests oder beim Entwickeln nützlich.
Beispiele finden sich im POD.