use MARC::File::XML ( BinaryEncoding => 'utf8' );
use File::Path qw[remove_tree]; # perl core module
-use File::Spec;
use File::Slurp;
# FIXME - The user might be installing a new database, so can't rely
WHERE COALESCE(permanent,0)=0 AND dir='koha_upload'
});
-my $tmp= File::Spec->tmpdir.'/koha_upload';
+my $tmp = C4::Context->temporary_directory . '/koha_upload';
remove_tree( $tmp ) if -d $tmp;
print "Upgrade to $DBversion done (Bug 14893 - Separate temporary storage per instance in Upload.pm)\n";
WHERE ordernumber = ?
|);
- require Koha::Number::Price;
+ require Number::Format;
+ my $format = Number::Format->new;
+ my $precision = 2;
for my $order ( @$orders ) {
$sth_get_bookseller->execute( $order->{ordernumber} );
my ( $bookseller ) = $sth_get_bookseller->fetchrow_hashref;
- $order->{rrp} = Koha::Number::Price->new( $order->{rrp} )->round;
- $order->{ecost} = Koha::Number::Price->new( $order->{ecost} )->round;
+ $order->{rrp} = $format->round( $order->{rrp}, $precision );
+ $order->{ecost} = $format->round( $order->{ecost}, $precision );
$order->{tax_rate} ||= 0 ; # tax_rate can be NULL in DB
# Ordering
if ( $bookseller->{listincgst} ) {
$order->{rrp_tax_included} = $order->{rrp};
- $order->{rrp_tax_excluded} = Koha::Number::Price->new(
- $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
+ $order->{rrp_tax_excluded} = $format->round(
+ $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ), $precision );
$order->{ecost_tax_included} = $order->{ecost};
- $order->{ecost_tax_excluded} = Koha::Number::Price->new(
- $order->{ecost} / ( 1 + $order->{tax_rate} ) )->round;
+ $order->{ecost_tax_excluded} = $format->round(
+ $order->{ecost} / ( 1 + $order->{tax_rate} ), $precision );
}
else {
$order->{rrp_tax_excluded} = $order->{rrp};
- $order->{rrp_tax_included} = Koha::Number::Price->new(
- $order->{rrp} * ( 1 + $order->{tax_rate} ) )->round;
+ $order->{rrp_tax_included} = $format->round(
+ $order->{rrp} * ( 1 + $order->{tax_rate} ), $precision );
$order->{ecost_tax_excluded} = $order->{ecost};
- $order->{ecost_tax_included} = Koha::Number::Price->new(
- $order->{ecost} * ( 1 + $order->{tax_rate} ) )->round;
+ $order->{ecost_tax_included} = $format->round(
+ $order->{ecost} * ( 1 + $order->{tax_rate} ), $precision );
}
#receiving
if ( $bookseller->{listincgst} ) {
- $order->{unitprice_tax_included} = Koha::Number::Price->new( $order->{unitprice} )->round;
- $order->{unitprice_tax_excluded} = Koha::Number::Price->new(
- $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
+ $order->{unitprice_tax_included} = $format->round( $order->{unitprice}, $precision );
+ $order->{unitprice_tax_excluded} = $format->round(
+ $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ), $precision );
}
else {
- $order->{unitprice_tax_excluded} = Koha::Number::Price->new( $order->{unitprice} )->round;
- $order->{unitprice_tax_included} = Koha::Number::Price->new(
- $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ) )->round;
+ $order->{unitprice_tax_excluded} = $format->round( $order->{unitprice}, $precision );
+ $order->{unitprice_tax_included} = $format->round(
+ $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ), $precision );
}
# If the order is received, the tax is calculated from the unit price
if ( $order->{orderstatus} eq 'complete' ) {
- $order->{tax_value} = Koha::Number::Price->new(
+ $order->{tax_value} = $format->round(
( $order->{unitprice_tax_included} - $order->{unitprice_tax_excluded} )
- * $order->{quantity} )->round;
+ * $order->{quantity}, $precision );
} else {
# otherwise the ecost is used
- $order->{tax_value} = Koha::Number::Price->new(
+ $order->{tax_value} = $format->round(
( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
- $order->{quantity} )->round;
+ $order->{quantity}, $precision );
}
$sth_update_order->execute(
WHERE ordernumber = ?
|);
- require Koha::Number::Price;
for my $order (@$orders) {
my $tax_value_on_ordering =
$order->{quantity} *
print "Upgrade to $DBversion done (Bug 11674 - Add system preference MarcFieldDocURL)\n";
}
+$DBversion = '17.12.00.032';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|
+ UPDATE letter SET code = "SERIAL_ALERT" WHERE code = "RLIST";
+ |);
+ $dbh->do(q|
+ UPDATE letter SET name = "New serial issue" WHERE name = "Routing List";
+ |);
+ $dbh->do(q|
+ UPDATE subscription SET letter = "SERIAL_ALERT" WHERE letter = "RLIST";
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19794 - Rename RLIST notice to SERIAL_ALERT)\n";
+}
+
+$DBversion = '17.12.00.033';
+if( CheckVersion( $DBversion ) ) {
+ if ( !column_exists( 'accountlines', 'payment_type' ) ) {
+ $dbh->do(q{
+ ALTER TABLE accountlines ADD payment_type varchar(80) default NULL AFTER accounttype
+ });
+ }
+
+ $dbh->do(q{
+ INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES ('PAYMENT_TYPE')
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18786 - Add ability to create custom payment types)\n";
+}
+
+$DBversion = '17.12.00.034';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ INSERT IGNORE INTO account_offset_types ( type ) VALUES ('Void Payment')
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18790 - Add ability to void payment)\n";
+}
+
+$DBversion = '17.12.00.035';
+if( CheckVersion( $DBversion ) ) {
+ my ( $original_value ) = $dbh->selectrow_array(q|
+ SELECT value FROM systempreferences WHERE variable="MarkLostItemsAsReturned"
+ |);
+ if ( $original_value and $original_value eq '1' ) {
+ $dbh->do(q{
+ UPDATE systempreferences
+ SET type="multiple",
+ options="batchmod|moredetail|cronjob|additem",
+ value="batchmod,moredetail,cronjob,additem"
+ WHERE variable="MarkLostItemsAsReturned"
+ });
+ } else {
+ $dbh->do(q{
+ UPDATE systempreferences
+ SET type="multiple",
+ options="batchmod|moredetail|cronjob|additem",
+ value=""
+ WHERE variable="MarkLostItemsAsReturned"
+ });
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19974 - Make MarkLostItemsAsReturned multiple)\n";
+}
+
+$DBversion = '17.12.00.036';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('CanMarkHoldsToPullAsLost','do_not_allow','do_not_allow|allow|allow_and_notify','Add a button to the "Holds to pull" screen to mark an item as lost and notify the patron.','Choice');
+ } );
+ $dbh->do( q{
+ INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('reserves', 'CANCEL_HOLD_ON_LOST', '', 'Hold has been cancelled', 0, "Hold has been cancelled", "Dear [% borrower.firstname %] [% borrower.surname %],\n\nWe regret to inform you, that the following item can not be provided due to it being missing. Your hold was cancelled.\n\nTitle: [% biblio.title %]\nAuthor: [% biblio.author %]\nCopy: [% item.copynumber %]\nLocation: [% branch.branchname %]", 'email', 'default');
+ } );
+ $dbh->do( q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('UpdateItemWhenLostFromHoldList','',NULL,'This is a list of values to update an item when it is marked as lost from the holds to pull screen','Free');
+ } );
+ $dbh->do( q{
+ UPDATE systempreferences SET options="batchmod|moredetail|cronjob|additem|pendingreserves", value="batchmod|moredetail|cronjob|additem|pendingreserves" WHERE variable="MarkLostItemsAsReturned";
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19287 - Add ability to mark an item 'Lost' from 'Holds to pull' list (CanMarkHoldsToPullAsLost, UpdateItemWhenLostFromHoldList and CANCEL_HOLD_ON_LOST))\n";
+}
+
+$DBversion = '17.12.00.037';
+if( CheckVersion( $DBversion ) ) {
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (This change has been reverted, nothing done!)\n";
+}
+
+$DBversion = '17.12.00.038';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'slo' WHERE iso639_2_code = 'slk' AND rfc4646_subtag = 'sk';
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20245 - Use Bibliographic code value for Slovak language)\n";
+}
+
+$DBversion = '17.12.00.039';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'baq' WHERE iso639_2_code = 'eus' AND rfc4646_subtag = 'eu';
+ } );
+ $dbh->do( q{
+ UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'mao' WHERE iso639_2_code = 'mri' AND rfc4646_subtag = 'mi';
+ } );
+ $dbh->do( q{
+ UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'alb' WHERE iso639_2_code = 'sqi' AND rfc4646_subtag = 'sq';
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20482 - Use Bibliographic code value for Basque, Maori and Albanian languages)\n";
+}
+
+$DBversion = '17.12.00.040';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ INSERT IGNORE INTO systempreferences ( value, variable, options, explanation, type )
+ VALUES ( '0', 'ProtectSuperlibrarianPrivileges', NULL, 'If enabled, non-superlibrarians cannot set superlibrarian privileges', 'YesNo' )
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20100 - Add new system preference ProtectSuperlibrarianPrivileges)\n";
+}
+
+$DBversion = '17.12.00.041';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q{
+ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server');
+ } );
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 11317 - Add a new permission to access files stored on the server)\n";
+}
+
+$DBversion = '17.12.00.042';
+if( CheckVersion( $DBversion ) ) {
+
+ if (!TableExists('oauth_access_tokens')) {
+ $dbh->do(q{
+ CREATE TABLE oauth_access_tokens (
+ `access_token` VARCHAR(191) NOT NULL,
+ `client_id` VARCHAR(191) NOT NULL,
+ `expires` INT NOT NULL,
+ PRIMARY KEY (`access_token`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
+ });
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20402 - Implement OAuth2 authentication for REST API)\n";
+}
+
+$DBversion = '17.12.00.043';
+if(CheckVersion($DBversion)) {
+
+ if (!TableExists('api_keys')) {
+ $dbh->do(q{
+ CREATE TABLE `api_keys` (
+ `client_id` VARCHAR(191) NOT NULL,
+ `secret` VARCHAR(191) NOT NULL,
+ `description` VARCHAR(255) NOT NULL,
+ `patron_id` INT(11) NOT NULL,
+ `active` TINYINT(1) DEFAULT 1 NOT NULL,
+ PRIMARY KEY `client_id` (`client_id`),
+ UNIQUE KEY `secret` (`secret`),
+ KEY `patron_id` (`patron_id`),
+ CONSTRAINT `api_keys_fk_patron_id`
+ FOREIGN KEY (`patron_id`)
+ REFERENCES `borrowers` (`borrowernumber`)
+ ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+ });
+ }
+
+ print "Upgrade to $DBversion done (Bug 20568 - Add API key management interface for patrons)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '17.12.00.044';
+if(CheckVersion($DBversion)) {
+
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`)
+ VALUES
+ ('RESTOAuth2ClientCredentials','0',NULL,'If enabled, the OAuth2 client credentials flow is enabled for the REST API.','YesNo');
+ });
+
+ print "Upgrade to $DBversion done (Bug 20624 - Disable OAuth2 client credentials grant by default)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '18.05.00.000';
+if( CheckVersion( $DBversion ) ) {
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Koha 18.05)\n";
+}
+
+$DBversion = '18.06.00.000';
+if( CheckVersion( $DBversion ) ) {
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Koha 18.06 - It's Adventure time!)\n";
+}
+
+$DBversion = '18.06.00.001';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{UPDATE permissions SET description = 'Manage budgets' WHERE code = 'period_manage';});
+ $dbh->do(q{UPDATE permissions SET description = 'Manage funds' WHERE code = 'budget_manage';});
+ $dbh->do(q{UPDATE permissions SET description = 'Modify funds (can''t create lines, but can modify existing ones)' WHERE code = 'budget_modify';});
+ $dbh->do(q{UPDATE permissions SET description = 'Manage baskets and order lines' WHERE code = 'order_manage';});
+ $dbh->do(q{UPDATE permissions SET description = 'Manage all baskets and order lines, regardless of restrictions on them' WHERE code = 'order_manage_all';});
+ $dbh->do(q{UPDATE permissions SET description = 'Manage basket groups' WHERE code = 'group_manage';});
+ $dbh->do(q{UPDATE permissions SET description = 'Receive orders and manage shipments' WHERE code = 'order_receive';});
+ $dbh->do(q{UPDATE permissions SET description = 'Add and delete funds (but can''t modify funds)' WHERE code = 'budget_add_del';});
+ $dbh->do(q{UPDATE permissions SET description = 'Manage all funds' WHERE code = 'budget_manage_all';});
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 3849- Improve descriptions of granular acquisition permissions)\n";
+}
+
+$DBversion = '18.06.00.002';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{DELETE FROM userflags WHERE bit = 12 AND flag = 'management';});
+ $dbh->do(q{UPDATE borrowers SET flags = flags - ( flags & (1<<12) ) WHERE flags & (1 << 12);});
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 2426 - Remove deprecated management permission)\n";
+}
+
+$DBversion = '18.06.00.003';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "ALTER TABLE search_field CHANGE COLUMN type type ENUM('', 'string', 'date', 'number', 'boolean', 'sum', 'isbn', 'stdno') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine'" );
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20073 - Add new types for Elasticsearch fields)\n";
+}
+
+$DBversion = '18.06.00.004';
+if( CheckVersion( $DBversion ) ) {
+
+ # Add 'Manual Credit' offset type
+ $dbh->do(q{
+ INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('Manual Credit');
+ });
+
+ # Fix wrong account offsets / Manual credits
+ $dbh->do(q{
+ UPDATE account_offsets
+ SET credit_id=debit_id,
+ debit_id=NULL,
+ type='Manual Credit'
+ WHERE amount < 0 AND
+ type='Manual Debit' AND
+ debit_id IN
+ (SELECT accountlines_id AS debit_id
+ FROM accountlines
+ WHERE accounttype='C');
+ });
+
+ # Fix wrong account offsets / Manually forgiven amounts
+ $dbh->do(q{
+ UPDATE account_offsets
+ SET credit_id=debit_id,
+ debit_id=NULL,
+ type='Writeoff'
+ WHERE amount < 0 AND
+ type='Manual Debit' AND
+ debit_id IN
+ (SELECT accountlines_id AS debit_id
+ FROM accountlines
+ WHERE accounttype='FOR');
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20980 - Manual credit offsets are stored as debits)\n";
+}
+
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.