Revision 06c4e576
Von Bernd Bleßmann vor mehr als 1 Jahr hinzugefügt
t/controllers/csvimport/aptransactions.t | ||
---|---|---|
84 | 84 |
sep_char => ',', |
85 | 85 |
quote_char => '"', |
86 | 86 |
numberformat => $::myconfig{numberformat}, |
87 |
duplicates => 'check_db', |
|
88 |
duplicates_vendor_and_invnumber => 1, |
|
87 | 89 |
); |
88 | 90 |
|
89 | 91 |
my $csv_aptransactions_import = SL::Controller::CsvImport::APTransaction->new( |
... | ... | |
187 | 189 |
|
188 | 190 |
$saved_invoices++; |
189 | 191 |
|
190 |
##### test for duplicate invnumber |
|
191 |
# $file = \<<"EOL"; |
|
192 |
# datatype,vendornumber,currency_id,invnumber,taxincluded,apchart,transdate |
|
193 |
# datatype,accno,amount,taxkey |
|
194 |
# "Rechnung",2,1,"invoice 1",f,1600,"$transdate_string" |
|
195 |
# "AccTransaction",3400,159.48,3 |
|
196 |
# EOL |
|
197 |
# $entries = test_import($file); |
|
198 |
# $entry = $entries->[0]; |
|
199 |
# $entry->{object}->validate_acc_trans; |
|
200 |
# is $entry->{errors}->[0], 'Error: invnumber already exists', 'detects verify_amount differences'; |
|
192 |
##### test for duplicate invnumber for same vendor |
|
193 |
$file = \<<"EOL"; |
|
194 |
datatype,vendornumber,currency_id,invnumber,taxincluded,apchart,transdate |
|
195 |
datatype,accno,amount,taxkey |
|
196 |
"Rechnung",2,1,"invoice 1",f,1600,"$transdate_string" |
|
197 |
"AccTransaction",3400,159.48,9 |
|
198 |
EOL |
|
199 |
|
|
200 |
$entries = test_import($file); |
|
201 |
$entry = $entries->[0]; |
|
202 |
is $entry->{errors}->[0], 'Duplicate in database', 'detects duplicate invnumer for same vendor'; |
|
203 |
|
|
204 |
##### test for duplicate invnumber for different vendor |
|
205 |
my $different_vendor = new_vendor( |
|
206 |
name => 'anderer Testlieferant', |
|
207 |
currency_id => $currency_id, |
|
208 |
taxzone_id => $taxzone->id, |
|
209 |
vendornumber => 777, |
|
210 |
)->save; |
|
211 |
|
|
212 |
$file = \<<"EOL"; |
|
213 |
datatype,vendornumber,currency_id,invnumber,taxincluded,apchart,transdate |
|
214 |
datatype,accno,amount,taxkey |
|
215 |
"Rechnung",777,1,"invoice 1",f,1600,"$transdate_string" |
|
216 |
"AccTransaction",3400,159.48,9 |
|
217 |
EOL |
|
218 |
|
|
219 |
$entries = test_import($file); |
|
220 |
is $entries->[0]->{errors}->[0], undef, 'duplicate invnumber, different vendor: no errors in ap row'; |
|
221 |
is $entries->[1]->{errors}->[0], undef, 'duplicate invnumber, different vendor: no errors in acc_trans row'; |
|
222 |
|
|
223 |
$entry = $entries->[0]; |
|
224 |
is $entry->{object}->invnumber, 'invoice 1', 'duplicate invnumber, different vendor: invnumber ok'; |
|
225 |
is $entry->{object}->vendor_id, $different_vendor->id, 'duplicate invnumber, different vendor: vendor_id ok'; |
|
226 |
|
|
227 |
$saved_invoices++; |
|
201 | 228 |
|
202 | 229 |
##### test for no invnumber given |
203 |
# $file = \<<"EOL"; |
|
204 |
# datatype,vendornumber,currency_id,taxincluded,apchart,transdate |
|
205 |
# datatype,accno,amount,taxkey |
|
206 |
# "Rechnung",2,1,f,1600,"$transdate_string" |
|
207 |
# "AccTransaction",3400,159.48,3 |
|
208 |
# EOL |
|
209 |
# $entries = test_import($file); |
|
210 |
# $entry = $entries->[0]; |
|
211 |
# $entry->{object}->validate_acc_trans; |
|
212 |
# is $entry->{object}->invnumber =~ /^\d+$/, 1, 'invnumber assigned automatically'; |
|
230 |
$file = \<<"EOL"; |
|
231 |
datatype,vendornumber,currency_id,taxincluded,apchart,transdate |
|
232 |
datatype,accno,amount,taxkey |
|
233 |
"Rechnung",2,1,f,1600,"$transdate_string" |
|
234 |
"AccTransaction",3400,159.48,9 |
|
235 |
EOL |
|
236 |
|
|
237 |
$entries = test_import($file); |
|
238 |
$entry = $entries->[0]; |
|
239 |
$entry->{object}->validate_acc_trans; |
|
240 |
is $entry->{errors}->[0], 'Error: Invoice Number missing', 'detects missing invnubmer'; |
|
241 |
|
|
213 | 242 |
|
214 | 243 |
##### basic test without amounts in Rechnung, only specified in AccTransaction |
215 | 244 |
$file = \<<"EOL"; |
... | ... | |
588 | 617 |
$entry = $entries->[0]; |
589 | 618 |
is $entry->{object}->validate_acc_trans, 1, 'ap amount test: acc_trans validates'; |
590 | 619 |
is $entry->{object}->duedate->to_kivitendo, '30.04.2016', 'duedate'; |
591 |
is $entry->{info_data}->{amount}, '326', "First invoice amount displayed in info data";
|
|
620 |
is $entry->{info_data}->{calc_amount}, '326.00', "First calculated invoice amount displayed in info data";
|
|
592 | 621 |
$entry = $entries->[4]; |
593 |
is $entry->{info_data}->{amount}, '326', "Second invoice amount displayed in info data";
|
|
622 |
is $entry->{info_data}->{calc_amount}, '326.00', "Second calculated invoice amount displayed in info data";
|
|
594 | 623 |
|
595 | 624 |
$saved_invoices++; |
596 | 625 |
$saved_invoices++; |
... | ... | |
656 | 685 |
$file = \<<EOL; |
657 | 686 |
datatype,vendornumber,currency_id,invnumber,taxincluded,apchart |
658 | 687 |
datatype,accno,amount,taxkey |
659 |
"Rechnung",2,1,"invoice 1 tax included no amounts",t,1600
|
|
688 |
"Rechnung",2,1,"invoice 2 tax included no amounts",t,1600
|
|
660 | 689 |
"AccTransaction",3400,189.78,8 |
661 | 690 |
EOL |
662 | 691 |
|
Auch abrufbar als: Unified diff
CSV-Import Kreditorenbuchungen: Anpassungen Unit-Test:
- Dublettenprüfung
- fehlende Rechnungsnummer
- Anzeige errechneter Betrag