Lines 1219-1249
subtest 'FieldsForCalculatingFundValues with a vendor NOT including tax in their
Link Here
|
1219 |
$schema->storage->txn_begin; |
1219 |
$schema->storage->txn_begin; |
1220 |
|
1220 |
|
1221 |
# Test FieldsForCalculatingFundValues() |
1221 |
# Test FieldsForCalculatingFundValues() |
1222 |
t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1'); |
1222 |
t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '1' ); |
1223 |
my ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues(); |
1223 |
my ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues(); |
1224 |
is ( $unitprice_field, 'unitprice_tax_included', "We expect this to be unitprice_tax_included" ); |
1224 |
is( $unitprice_field, 'unitprice_tax_included', "We expect this to be unitprice_tax_included" ); |
1225 |
is ( $ecost_field, 'ecost_tax_included', "We expect this to be ecost_tax_included" ); |
1225 |
is( $ecost_field, 'ecost_tax_included', "We expect this to be ecost_tax_included" ); |
1226 |
t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0'); |
1226 |
t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '0' ); |
1227 |
( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues(); |
1227 |
( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues(); |
1228 |
is ( $unitprice_field, 'unitprice_tax_excluded', "We expect this to be unitprice_tax_excluded" ); |
1228 |
is( $unitprice_field, 'unitprice_tax_excluded', "We expect this to be unitprice_tax_excluded" ); |
1229 |
is ( $ecost_field, 'ecost_tax_excluded', "We expect this to be ecost_tax_excluded" ); |
1229 |
is( $ecost_field, 'ecost_tax_excluded', "We expect this to be ecost_tax_excluded" ); |
1230 |
|
1230 |
|
1231 |
# Test GetBudgetOrdered() |
1231 |
# Test GetBudgetOrdered() |
1232 |
# ----------------------- |
1232 |
# ----------------------- |
1233 |
|
1233 |
|
1234 |
# Build an order |
1234 |
# Build an order |
1235 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
1235 |
t::lib::Mocks::mock_preference( 'OrderPriceRounding', 'nearest_cent' ); |
1236 |
my $item_1 = $builder->build_sample_item; |
1236 |
my $item_1 = $builder->build_sample_item; |
1237 |
my $invoice = $builder->build({ source => 'Aqinvoice'}); |
1237 |
my $invoice = $builder->build( { source => 'Aqinvoice' } ); |
1238 |
my $currency = $builder->build({ source => 'Currency', value => { active => 1, archived => 0, symbol => 'F', rate => 2, isocode => undef, currency => 'BOO' } }); |
1238 |
my $currency = $builder->build( |
1239 |
my $vendor = $builder->build({ source => 'Aqbookseller',value => { listincgst => 0, invoiceincgst => 0, listprice => $currency->{currency}, invoiceprice => $currency->{currency} } }); |
1239 |
{ |
1240 |
my $basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0, booksellerid => $vendor->{id} } }); |
1240 |
source => 'Currency', |
1241 |
my $budget_period = $builder->build({ source => 'Aqbudgetperiod' }); |
1241 |
value => { active => 1, archived => 0, symbol => 'F', rate => 2, isocode => undef, currency => 'BOO' } |
1242 |
my $budget = $builder->build({ source => 'Aqbudget', value => { |
|
|
1243 |
budget_period_id => $budget_period->{budget_period_id}, |
1244 |
budget_parent_id => undef, |
1245 |
} |
1242 |
} |
1246 |
}); |
1243 |
); |
|
|
1244 |
my $vendor = $builder->build( |
1245 |
{ |
1246 |
source => 'Aqbookseller', |
1247 |
value => { |
1248 |
listincgst => 0, invoiceincgst => 0, listprice => $currency->{currency}, |
1249 |
invoiceprice => $currency->{currency} |
1250 |
} |
1251 |
} |
1252 |
); |
1253 |
my $basket = |
1254 |
$builder->build( { source => 'Aqbasket', value => { is_standing => 0, booksellerid => $vendor->{id} } } ); |
1255 |
my $budget_period = $builder->build( { source => 'Aqbudgetperiod' } ); |
1256 |
my $budget = $builder->build( |
1257 |
{ |
1258 |
source => 'Aqbudget', |
1259 |
value => { |
1260 |
budget_period_id => $budget_period->{budget_period_id}, |
1261 |
budget_parent_id => undef, |
1262 |
} |
1263 |
} |
1264 |
); |
1247 |
my $orderdata = { |
1265 |
my $orderdata = { |
1248 |
basketno => $basket->{basketno}, |
1266 |
basketno => $basket->{basketno}, |
1249 |
booksellerid => $vendor->{id}, |
1267 |
booksellerid => $vendor->{id}, |
Lines 1269-1317
subtest 'FieldsForCalculatingFundValues with a vendor NOT including tax in their
Link Here
|
1269 |
$orderdata = $order->unblessed(); |
1287 |
$orderdata = $order->unblessed(); |
1270 |
|
1288 |
|
1271 |
# Place the order |
1289 |
# Place the order |
1272 |
$order = $builder->build({ source => 'Aqorder', value => $orderdata }); |
1290 |
$order = $builder->build( { source => 'Aqorder', value => $orderdata } ); |
1273 |
|
1291 |
|
1274 |
# Check order values with different CalculateFundValuesIncludingTax options |
1292 |
# Check order values with different CalculateFundValuesIncludingTax options |
1275 |
t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0'); |
1293 |
t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '0' ); |
1276 |
my $budget_ordered = GetBudgetOrdered( $order->{budget_id} ); |
1294 |
my $budget_ordered = GetBudgetOrdered( $order->{budget_id} ); |
1277 |
is ( $budget_ordered, 10, "We expect this to be the tax exclusive value" ); |
1295 |
is( $budget_ordered, 10, "We expect this to be the tax exclusive value" ); |
1278 |
t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1'); |
1296 |
t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '1' ); |
1279 |
$budget_ordered = GetBudgetOrdered( $order->{budget_id} ); |
1297 |
$budget_ordered = GetBudgetOrdered( $order->{budget_id} ); |
1280 |
is ( $budget_ordered, 11.5, "We expect this to be the tax inclusive value" ); |
1298 |
is( $budget_ordered, 11.5, "We expect this to be the tax inclusive value" ); |
1281 |
|
1299 |
|
1282 |
# Test GetBudgetSpent() and GetBudgetHierarchy() |
1300 |
# Test GetBudgetSpent() and GetBudgetHierarchy() |
1283 |
# ----------------------------------------------- |
1301 |
# ----------------------------------------------- |
1284 |
|
1302 |
|
1285 |
# Receive the order |
1303 |
# Receive the order |
1286 |
$orderdata->{unitprice} = 10; #we are paying what we expected |
1304 |
$orderdata->{unitprice} = 10; #we are paying what we expected |
1287 |
|
1305 |
|
1288 |
# Do some maths |
1306 |
# Do some maths |
1289 |
$order = Koha::Acquisition::Order->new($orderdata); |
1307 |
$order = Koha::Acquisition::Order->new($orderdata); |
1290 |
$order->populate_with_prices_for_receiving(); |
1308 |
$order->populate_with_prices_for_receiving(); |
1291 |
$orderdata = $order->unblessed(); |
1309 |
$orderdata = $order->unblessed(); |
1292 |
my $received_order = $builder->build({ source => 'Aqorder', value => $orderdata }); |
1310 |
my $received_order = $builder->build( { source => 'Aqorder', value => $orderdata } ); |
1293 |
|
1311 |
|
1294 |
# Receive a copy of the order |
1312 |
# Receive a copy of the order |
1295 |
ModReceiveOrder({ |
1313 |
ModReceiveOrder( |
1296 |
biblionumber => $orderdata->{biblionumber}, |
1314 |
{ |
1297 |
order => $received_order, |
1315 |
biblionumber => $orderdata->{biblionumber}, |
1298 |
invoice => $invoice, |
1316 |
order => $received_order, |
|
|
1317 |
invoice => $invoice, |
1299 |
quantityreceived => 1, |
1318 |
quantityreceived => 1, |
1300 |
budget_id => $orderdata->{budget_id}, |
1319 |
budget_id => $orderdata->{budget_id}, |
1301 |
received_items => [], |
1320 |
received_items => [], |
1302 |
}); |
1321 |
} |
|
|
1322 |
); |
1303 |
|
1323 |
|
1304 |
t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0'); |
1324 |
t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '0' ); |
1305 |
my $spent_amount = GetBudgetSpent( $orderdata->{budget_id} ); |
1325 |
my $spent_amount = GetBudgetSpent( $orderdata->{budget_id} ); |
1306 |
is ( $spent_amount, 10, "We expect this to be the tax exclusive value" ); |
1326 |
is( $spent_amount, 10, "We expect this to be the tax exclusive value" ); |
1307 |
my $gbh = GetBudgetHierarchy($budget->{budget_period_id}); |
1327 |
my $gbh = GetBudgetHierarchy( $budget->{budget_period_id} ); |
1308 |
is ( @$gbh[0]->{budget_spent}, 10, "We expect this value to be the tax exclusive value"); |
1328 |
is( @$gbh[0]->{budget_spent}, 10, "We expect this value to be the tax exclusive value" ); |
1309 |
|
1329 |
|
1310 |
t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1'); |
1330 |
t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '1' ); |
1311 |
$spent_amount = GetBudgetSpent( $orderdata->{budget_id} ); |
1331 |
$spent_amount = GetBudgetSpent( $orderdata->{budget_id} ); |
1312 |
is ( $spent_amount, 11.5, "We expect this to be the tax inclusive value" ); |
1332 |
is( $spent_amount, 11.5, "We expect this to be the tax inclusive value" ); |
1313 |
$gbh = GetBudgetHierarchy($budget->{budget_period_id}); |
1333 |
$gbh = GetBudgetHierarchy( $budget->{budget_period_id} ); |
1314 |
is ( @$gbh[0]->{budget_spent}, 11.5, "We expect this value to be the tax inclusive value"); |
1334 |
is( @$gbh[0]->{budget_spent}, 11.5, "We expect this value to be the tax inclusive value" ); |
1315 |
|
1335 |
|
1316 |
$schema->storage->txn_rollback; |
1336 |
$schema->storage->txn_rollback; |
1317 |
}; |
1337 |
}; |
1318 |
- |
|
|