Revision c6d47254
Von Kivitendo Admin vor fast 8 Jahren hinzugefügt
t/bank/bank_transactions.t | ||
---|---|---|
12 | 12 |
|
13 | 13 |
use SL::DB::Buchungsgruppe; |
14 | 14 |
use SL::DB::Currency; |
15 |
use SL::DB::Exchangerate; |
|
16 | 15 |
use SL::DB::Customer; |
17 | 16 |
use SL::DB::Vendor; |
18 |
use SL::DB::Employee; |
|
19 | 17 |
use SL::DB::Invoice; |
20 |
use SL::DB::Part; |
|
21 | 18 |
use SL::DB::Unit; |
22 | 19 |
use SL::DB::TaxZone; |
23 | 20 |
use SL::DB::BankAccount; |
... | ... | |
25 | 22 |
use SL::DB::PurchaseInvoice; |
26 | 23 |
use SL::DB::BankTransaction; |
27 | 24 |
use SL::Controller::BankTransaction; |
25 |
use SL::Dev::ALL; |
|
28 | 26 |
use Data::Dumper; |
29 | 27 |
|
30 |
my ($customer, $vendor, $currency_id, @parts, $unit, $employee, $tax, $tax7, $tax_9, $taxzone, $payment_terms, $bank_account);
|
|
28 |
my ($customer, $vendor, $currency_id, $unit, $tax, $tax7, $tax_9, $payment_terms, $bank_account);
|
|
31 | 29 |
my ($transdate1, $transdate2, $currency); |
32 | 30 |
my ($ar_chart,$bank,$ar_amount_chart, $ap_chart, $ap_amount_chart); |
33 | 31 |
my ($ar_transaction, $ap_transaction); |
... | ... | |
39 | 37 |
SL::DB::Manager::InvoiceItem->delete_all(all => 1); |
40 | 38 |
SL::DB::Manager::Invoice->delete_all(all => 1); |
41 | 39 |
SL::DB::Manager::PurchaseInvoice->delete_all(all => 1); |
42 |
SL::DB::Manager::Part->delete_all(all => 1); |
|
43 | 40 |
SL::DB::Manager::Customer->delete_all(all => 1); |
44 | 41 |
SL::DB::Manager::Vendor->delete_all(all => 1); |
45 | 42 |
SL::DB::Manager::BankAccount->delete_all(all => 1); |
... | ... | |
70 | 67 |
sub reset_state { |
71 | 68 |
my %params = @_; |
72 | 69 |
|
73 |
$params{$_} ||= {} for qw(unit customer part tax vendor);
|
|
70 |
$params{$_} ||= {} for qw(unit customer tax vendor); |
|
74 | 71 |
|
75 | 72 |
clear_up(); |
76 | 73 |
|
77 | 74 |
$transdate1 = DateTime->today; |
78 | 75 |
$transdate2 = DateTime->today->add(days => 5); |
79 | 76 |
|
80 |
$employee = SL::DB::Manager::Employee->current || croak "No employee"; |
|
81 | 77 |
$tax = SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.19, %{ $params{tax} }) || croak "No tax"; |
82 | 78 |
$tax7 = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07) || croak "No tax for 7\%"; |
83 |
$taxzone = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || croak "No taxzone"; |
|
84 | 79 |
$tax_9 = SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.19, %{ $params{tax} }) || croak "No tax"; |
85 | 80 |
|
86 | 81 |
$currency_id = $::instance_conf->get_currency_id; |
... | ... | |
95 | 90 |
name => SL::DB::Manager::Chart->find_by(description => 'Bank')->description, |
96 | 91 |
)->save; |
97 | 92 |
|
98 |
$customer = SL::DB::Customer->new(
|
|
93 |
$customer = SL::Dev::CustomerVendor::create_customer(
|
|
99 | 94 |
name => 'Test Customer', |
100 |
currency_id => $currency_id, |
|
101 |
taxzone_id => $taxzone->id, |
|
102 | 95 |
iban => 'DE12500105170648489890', |
103 | 96 |
bic => 'TESTBIC', |
104 | 97 |
account_number => '648489890', |
105 | 98 |
mandate_date_of_signature => $transdate1, |
106 | 99 |
mandator_id => 'foobar', |
107 | 100 |
bank => 'Geizkasse', |
101 |
bank_code => 'G1235', |
|
108 | 102 |
depositor => 'Test Customer', |
109 |
%{ $params{customer} } |
|
110 | 103 |
)->save; |
111 | 104 |
|
112 |
$payment_terms = SL::DB::PaymentTerm->new( |
|
113 |
description => 'payment', |
|
114 |
description_long => 'payment', |
|
115 |
terms_netto => '30', |
|
116 |
terms_skonto => '5', |
|
117 |
percent_skonto => '0.05', |
|
118 |
auto_calculation => 1, |
|
119 |
)->save; |
|
120 |
|
|
121 |
$vendor = SL::DB::Vendor->new( |
|
122 |
name => 'Test Vendor', |
|
123 |
currency_id => $currency_id, |
|
124 |
taxzone_id => $taxzone->id, |
|
125 |
payment_id => $payment_terms->id, |
|
126 |
iban => 'DE12500105170648489890', |
|
127 |
bic => 'TESTBIC', |
|
128 |
account_number => '648489890', |
|
129 |
bank => 'Geizkasse', |
|
130 |
depositor => 'Test Vendor', |
|
131 |
%{ $params{vendor} } |
|
105 |
$payment_terms = SL::Dev::Payment::create_payment_terms; |
|
106 |
|
|
107 |
$vendor = SL::Dev::CustomerVendor::create_vendor( |
|
108 |
name => 'Test Vendor', |
|
109 |
payment_id => $payment_terms->id, |
|
110 |
iban => 'DE12500105170648489890', |
|
111 |
bic => 'TESTBIC', |
|
112 |
account_number => '648489890', |
|
113 |
bank => 'Geizkasse', |
|
114 |
bank_code => 'G1235', |
|
115 |
depositor => 'Test Vendor', |
|
132 | 116 |
)->save; |
133 | 117 |
|
134 | 118 |
$ar_chart = SL::DB::Manager::Chart->find_by( accno => '1400' ); # Forderungen |
... | ... | |
222 | 206 |
|
223 | 207 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv1'); |
224 | 208 |
|
225 |
my $bt = $ar_transaction->create_bank_transaction or die "Couldn't create bank_transaction";
|
|
209 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
|
|
226 | 210 |
|
227 | 211 |
$::form->{invoice_ids} = { |
228 | 212 |
$bt->id => [ $ar_transaction->id ] |
... | ... | |
247 | 231 |
payment_id => $payment_terms->id, |
248 | 232 |
); |
249 | 233 |
|
250 |
my $bt = $ar_transaction->create_bank_transaction(amount => $ar_transaction->amount_less_skonto) or die "Couldn't create bank_transaction"; |
|
234 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction, |
|
235 |
amount => $ar_transaction->amount_less_skonto |
|
236 |
) or die "Couldn't create bank_transaction"; |
|
251 | 237 |
|
252 | 238 |
$::form->{invoice_ids} = { |
253 | 239 |
$bt->id => [ $ar_transaction->id ] |
... | ... | |
274 | 260 |
my $ar_transaction_1 = test_ar_transaction(invnumber => 'salesinv_1'); |
275 | 261 |
my $ar_transaction_2 = test_ar_transaction(invnumber => 'salesinv_2'); |
276 | 262 |
|
277 |
my $bt = $ar_transaction_1->create_bank_transaction(amount => ($ar_transaction_1->amount + $ar_transaction_2->amount), |
|
278 |
purpose => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber, |
|
279 |
) or die "Couldn't create bank_transaction"; |
|
263 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction_1, |
|
264 |
amount => ($ar_transaction_1->amount + $ar_transaction_2->amount), |
|
265 |
purpose => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber, |
|
266 |
) or die "Couldn't create bank_transaction"; |
|
280 | 267 |
|
281 | 268 |
$::form->{invoice_ids} = { |
282 | 269 |
$bt->id => [ $ar_transaction_1->id, $ar_transaction_2->id ] |
... | ... | |
304 | 291 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid'); |
305 | 292 |
|
306 | 293 |
# amount 135 > 119 |
307 |
my $bt = $ar_transaction->create_bank_transaction(amount => 135) or die "Couldn't create bank_transaction"; |
|
294 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction, |
|
295 |
amount => 135 |
|
296 |
) or die "Couldn't create bank_transaction"; |
|
308 | 297 |
|
309 | 298 |
$::form->{invoice_ids} = { |
310 | 299 |
$bt->id => [ $ar_transaction->id ] |
... | ... | |
332 | 321 |
|
333 | 322 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid partial'); |
334 | 323 |
|
335 |
my $bt_1 = $ar_transaction->create_bank_transaction(amount => 10) or die "Couldn't create bank_transaction"; |
|
336 |
my $bt_2 = $ar_transaction->create_bank_transaction(amount => 119, |
|
337 |
transdate => DateTime->today->add(days => 5), |
|
338 |
) or die "Couldn't create bank_transaction"; |
|
324 |
my $bt_1 = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction, |
|
325 |
amount => 10 |
|
326 |
) or die "Couldn't create bank_transaction"; |
|
327 |
my $bt_2 = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction, |
|
328 |
amount => 119, |
|
329 |
transdate => DateTime->today->add(days => 5), |
|
330 |
) or die "Couldn't create bank_transaction"; |
|
339 | 331 |
|
340 | 332 |
$::form->{invoice_ids} = { |
341 | 333 |
$bt_1->id => [ $ar_transaction->id ] |
... | ... | |
366 | 358 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv partial payment'); |
367 | 359 |
|
368 | 360 |
# amount 100 < 119 |
369 |
my $bt = $ar_transaction->create_bank_transaction(amount => 100) or die "Couldn't create bank_transaction"; |
|
361 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction, |
|
362 |
amount => 100 |
|
363 |
) or die "Couldn't create bank_transaction"; |
|
370 | 364 |
|
371 | 365 |
$::form->{invoice_ids} = { |
372 | 366 |
$bt->id => [ $ar_transaction->id ] |
Auch abrufbar als: Unified diff
bank_transactions.t nutzt jetzt SL::Dev::Payment