|
Lines 138-158
subtest 'add_item (_get_valid_items) tests' => sub {
Link Here
|
| 138 |
'Exception thrown if `code` parameter is missing'; |
138 |
'Exception thrown if `code` parameter is missing'; |
| 139 |
|
139 |
|
| 140 |
my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
140 |
my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 141 |
my $av = Koha::AuthorisedValue->new( |
141 |
my $dt = Koha::Account::DebitType->new( |
| 142 |
{ |
142 |
{ |
| 143 |
category => 'MANUAL_INV', |
143 |
code => 'BOBBYRANDOM', |
| 144 |
authorised_value => 'BOBBYRANDOM', |
144 |
description => 'Test bobbyrandom', |
| 145 |
lib => 'Test bobbyrandom', |
|
|
| 146 |
lib_opac => 'Test bobbyrandom', |
| 147 |
} |
145 |
} |
| 148 |
)->store; |
146 |
)->store; |
| 149 |
$av->replace_library_limits( [ $library2->branchcode ] ); |
147 |
$dt->replace_library_limits( [ $library2->branchcode ] ); |
| 150 |
|
148 |
|
| 151 |
throws_ok { $sale->add_item( { code => 'BOBBYRANDOM' } ) } |
149 |
throws_ok { $sale->add_item( { code => 'BOBBYRANDOM' } ) } |
| 152 |
'Koha::Exceptions::Account::UnrecognisedType', |
150 |
'Koha::Exceptions::Account::UnrecognisedType', |
| 153 |
'Exception thrown if passed an item code that is not valid for the cash registers branch'; |
151 |
'Exception thrown if passed an item code that is not valid for the cash registers branch'; |
| 154 |
|
152 |
|
| 155 |
$av->replace_library_limits(); |
153 |
$dt->replace_library_limits(); |
| 156 |
$sale->{valid_items} = undef; # Flush object cache for 'valid_items' |
154 |
$sale->{valid_items} = undef; # Flush object cache for 'valid_items' |
| 157 |
|
155 |
|
| 158 |
throws_ok { |
156 |
throws_ok { |
|
Lines 205-224
subtest 'purchase tests' => sub {
Link Here
|
| 205 |
} |
203 |
} |
| 206 |
)->store; |
204 |
)->store; |
| 207 |
|
205 |
|
| 208 |
my $item1 = Koha::AuthorisedValue->new( |
206 |
my $item1 = Koha::Account::DebitType->new( |
| 209 |
{ |
207 |
{ |
| 210 |
category => 'MANUAL_INV', |
208 |
code => 'COPYRANDOM', |
| 211 |
authorised_value => 'COPYRANDOM', |
209 |
description => 'Copier fee', |
| 212 |
lib => 'Copier fee', |
|
|
| 213 |
lib_opac => 'Copier fee', |
| 214 |
} |
210 |
} |
| 215 |
)->store; |
211 |
)->store; |
| 216 |
my $item2 = Koha::AuthorisedValue->new( |
212 |
my $item2 = Koha::Account::DebitType->new( |
| 217 |
{ |
213 |
{ |
| 218 |
category => 'MANUAL_INV', |
214 |
code => 'CARDRANDOM', |
| 219 |
authorised_value => 'CARDRANDOM', |
215 |
description => 'New card fee', |
| 220 |
lib => 'New card fee', |
|
|
| 221 |
lib_opac => 'New card fee', |
| 222 |
} |
216 |
} |
| 223 |
)->store; |
217 |
)->store; |
| 224 |
|
218 |
|
|
Lines 250-256
subtest 'purchase tests' => sub {
Link Here
|
| 250 |
|
244 |
|
| 251 |
is(ref($credit), 'Koha::Account::Line', "Koha::Account::Line returned"); |
245 |
is(ref($credit), 'Koha::Account::Line', "Koha::Account::Line returned"); |
| 252 |
ok($credit->is_credit, "return is a credit for payment"); |
246 |
ok($credit->is_credit, "return is a credit for payment"); |
| 253 |
is($credit->accounttype, 'Purchase', "accounttype set correctly to 'Purchase' for payment"); |
247 |
is($credit->credit_type_code, 'PURCHASE', "credit_type_code set correctly to 'PURCHASE' for payment"); |
| 254 |
is($credit->amount, -5.00, "amount is calculated correctly for payment"); |
248 |
is($credit->amount, -5.00, "amount is calculated correctly for payment"); |
| 255 |
is($credit->amountoutstanding, 0.00, "amountoutstanding is set to zero for payment"); |
249 |
is($credit->amountoutstanding, 0.00, "amountoutstanding is set to zero for payment"); |
| 256 |
is($credit->manager_id, $staff->borrowernumber, "manager_id set correctionly for payment"); |
250 |
is($credit->manager_id, $staff->borrowernumber, "manager_id set correctionly for payment"); |
|
Lines 258-264
subtest 'purchase tests' => sub {
Link Here
|
| 258 |
is($credit->payment_type, 'CASH', "payment_type set correctly for payment"); |
252 |
is($credit->payment_type, 'CASH', "payment_type set correctly for payment"); |
| 259 |
|
253 |
|
| 260 |
my $offsets = Koha::Account::Offsets->search({credit_id => $credit->accountlines_id}); |
254 |
my $offsets = Koha::Account::Offsets->search({credit_id => $credit->accountlines_id}); |
| 261 |
is($offsets->count, 2, "One offset was added for each item added"); |
255 |
is($offsets->count, 3, "One offset was added for each item added"); # 2 items + 1 purchase |
| 262 |
|
256 |
|
| 263 |
#ensure relevant fields are set |
257 |
#ensure relevant fields are set |
| 264 |
#ensure register_id is only ever set with a corresponding payment_type having been set |
258 |
#ensure register_id is only ever set with a corresponding payment_type having been set |
| 265 |
- |
|
|