View | Details | Raw Unified | Return to bug 6427
Collapse All | Expand All

(-)a/installer/data/mysql/kohastructure.sql (-44 / +90 lines)
Lines 265-270 CREATE TABLE `borrowers` ( -- this table includes information about your patrons Link Here
265
  `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
265
  `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
266
  `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
266
  `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
267
  `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history
267
  `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history
268
  `account_balance` decimal(28,6) NOT NULL,
268
  UNIQUE KEY `cardnumber` (`cardnumber`),
269
  UNIQUE KEY `cardnumber` (`cardnumber`),
269
  PRIMARY KEY `borrowernumber` (`borrowernumber`),
270
  PRIMARY KEY `borrowernumber` (`borrowernumber`),
270
  KEY `categorycode` (`categorycode`),
271
  KEY `categorycode` (`categorycode`),
Lines 2737-2786 CREATE TABLE `messages` ( -- circulation messages left via the patron's check ou Link Here
2737
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2738
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2738
2739
2739
--
2740
--
2740
-- Table structure for table `accountlines`
2741
--
2742
2743
DROP TABLE IF EXISTS `accountlines`;
2744
CREATE TABLE `accountlines` (
2745
  `accountlines_id` int(11) NOT NULL AUTO_INCREMENT,
2746
  `borrowernumber` int(11) NOT NULL default 0,
2747
  `accountno` smallint(6) NOT NULL default 0,
2748
  `itemnumber` int(11) default NULL,
2749
  `date` date default NULL,
2750
  `amount` decimal(28,6) default NULL,
2751
  `description` mediumtext,
2752
  `dispute` mediumtext,
2753
  `accounttype` varchar(5) default NULL,
2754
  `amountoutstanding` decimal(28,6) default NULL,
2755
  `lastincrement` decimal(28,6) default NULL,
2756
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2757
  `notify_id` int(11) NOT NULL default 0,
2758
  `notify_level` int(2) NOT NULL default 0,
2759
  `note` text NULL default NULL,
2760
  `manager_id` int(11) NULL,
2761
  PRIMARY KEY (`accountlines_id`),
2762
  KEY `acctsborridx` (`borrowernumber`),
2763
  KEY `timeidx` (`timestamp`),
2764
  KEY `itemnumber` (`itemnumber`),
2765
  CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2766
  CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
2767
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2768
2769
--
2770
-- Table structure for table `accountoffsets`
2771
--
2772
2773
DROP TABLE IF EXISTS `accountoffsets`;
2774
CREATE TABLE `accountoffsets` (
2775
  `borrowernumber` int(11) NOT NULL default 0,
2776
  `accountno` smallint(6) NOT NULL default 0,
2777
  `offsetaccount` smallint(6) NOT NULL default 0,
2778
  `offsetamount` decimal(28,6) default NULL,
2779
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2780
  CONSTRAINT `accountoffsets_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2781
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2782
2783
--
2784
-- Table structure for table `action_logs`
2741
-- Table structure for table `action_logs`
2785
--
2742
--
2786
2743
Lines 3518-3523 CREATE TABLE items_search_fields ( Link Here
3518
    ON DELETE SET NULL ON UPDATE CASCADE
3475
    ON DELETE SET NULL ON UPDATE CASCADE
3519
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3476
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3520
3477
3478
--
3479
-- Table structure for table 'account_credits'
3480
--
3481
DROP TABLE IF EXISTS account_credits;
3482
CREATE TABLE IF account_credits (
3483
    credit_id int(11) NOT NULL AUTO_INCREMENT,     -- The unique id for this credit
3484
    borrowernumber int(11) NOT NULL,               -- The borrower this credit applies to
3485
    `type` varchar(255) NOT NULL,                  -- The type of credit this is ( defined by Koha::Accounts::CreditTypes )
3486
    amount_received decimal(28,6) DEFAULT NULL,    -- If this was a cash payment, the amount of money given
3487
    amount_paid decimal(28,6) NOT NULL,            -- The actual ammount paid, if less than amount_recieved, change was given back
3488
    amount_remaining decimal(28,6) NOT NULL,       -- The amount of this credit that has not been applied to outstanding debits
3489
    amount_voided decimal(28,6) NULL DEFAULT NULL, -- The amount of this credit was for before it was voided
3490
    notes text,                                    -- Misc notes for this credit
3491
    branchcode VARCHAR( 10 ) NULL DEFAULT NULL,    -- Branchcode where the credit was created ( if any )
3492
    manager_id int(11) DEFAULT NULL,               -- The borrowernumber of the user who created this credit ( if any )
3493
    created_on timestamp NULL DEFAULT NULL,        -- Timestamp for when this credit was created
3494
    updated_on timestamp NULL DEFAULT NULL,        -- Timestamp for when this credit was last modified
3495
    PRIMARY KEY (credit_id),
3496
    KEY borrowernumber (borrowernumber),
3497
    KEY branchcode (branchcode)
3498
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3499
3500
--
3501
-- Constraints for table `account_credits`
3502
--
3503
ALTER TABLE `account_credits`
3504
  ADD CONSTRAINT account_credits_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
3505
  ADD CONSTRAINT account_credits_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE;
3506
3507
--
3508
-- Table structure for table 'account_debits'
3509
--
3510
3511
DROP TABLE IF EXISTS account_debits;
3512
CREATE TABLE account_debits (
3513
    debit_id int(11) NOT NULL AUTO_INCREMENT,           -- The unique id for this debit
3514
    borrowernumber int(11) NOT NULL DEFAULT '0',        -- The borrower this debit applies to
3515
    itemnumber int(11) DEFAULT NULL,                    -- The item related to this debit ( for fines, lost fees, etc )
3516
    issue_id int(11) DEFAULT NULL,                      -- The checkout this debit is related to ( again, for fines, lost fees, etc )
3517
    `type` varchar(255) NOT NULL,                       -- The type of debit this is ( defined by Koha::Accounts::DebitTypes )
3518
    accruing tinyint(1) NOT NULL DEFAULT '0',           -- Boolean flag, tells of if this is a fine that is still accruing
3519
    amount_original decimal(28,6) DEFAULT NULL,         -- The total amount of this debit
3520
    amount_outstanding decimal(28,6) DEFAULT NULL,      -- The amount still owed on this debit
3521
    amount_last_increment decimal(28,6) DEFAULT NULL,   -- The amount by which this debit last changed
3522
    description mediumtext,                             -- The description for this debit
3523
    notes text,                                         -- Misc notes for this debit
3524
    branchcode VARCHAR( 10 ) NULL DEFAULT NULL,         -- Branchcode where the debit was created ( if any )
3525
    manager_id int(11) DEFAULT NULL,                    -- The borrowernumber of the user who created this debit ( if any )
3526
    created_on timestamp NULL DEFAULT NULL,             -- Timestamp for when this credit was created
3527
    updated_on timestamp NULL DEFAULT NULL,             -- Timestamp for when this credit was last modified
3528
    PRIMARY KEY (debit_id),
3529
    KEY acctsborridx (borrowernumber),
3530
    KEY itemnumber (itemnumber),
3531
    KEY borrowernumber (borrowernumber),
3532
    KEY issue_id (issue_id),
3533
    KEY branchcode (branchcode)
3534
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3535
3536
--
3537
-- Constraints for table `account_debits`
3538
--
3539
ALTER TABLE `account_debits`
3540
    ADD CONSTRAINT account_debits_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
3541
    ADD CONSTRAINT account_debits_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE;
3542
3543
--
3544
-- Table structure for table 'account_offsets'
3545
--
3546
3547
DROP TABLE IF EXISTS account_offsets;
3548
CREATE TABLE account_offsets (
3549
    offset_id int(11) NOT NULL AUTO_INCREMENT,                                              -- Unique id for this offset
3550
    debit_id int(11) DEFAULT NULL,                                                          -- Related debit
3551
    credit_id int(11) DEFAULT NULL,                                                         -- Related credit ( if any )
3552
    `type` varchar(255) DEFAULT NULL,                                                       -- The type of this offset ( defined by Koha::Accounts::OffsetTypes ), if any
3553
    amount decimal(28,6) NOT NULL,                                                          -- The amount of the offset, positive means patron owes more, negative means patron owes less
3554
    created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,    -- Timestamp for when this offset was created
3555
    PRIMARY KEY (offset_id),
3556
    KEY fee_id (debit_id),
3557
    KEY payment_id (credit_id)
3558
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3559
3560
--
3561
-- Constraints for table `account_offsets`
3562
--
3563
ALTER TABLE `account_offsets`
3564
    ADD CONSTRAINT account_offsets_ibfk_1 FOREIGN KEY (debit_id) REFERENCES account_debits (debit_id) ON DELETE CASCADE ON UPDATE CASCADE,
3565
    ADD CONSTRAINT account_offsets_ibfk_2 FOREIGN KEY (credit_id) REFERENCES account_credits (credit_id) ON DELETE CASCADE ON UPDATE CASCADE;
3566
3521
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3567
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3522
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3568
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3523
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
3569
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (-3 / +191 lines)
Lines 37-42 use Getopt::Long; Link Here
37
use C4::Context;
37
use C4::Context;
38
use C4::Installer;
38
use C4::Installer;
39
use C4::Dates;
39
use C4::Dates;
40
use Koha::Database;
40
41
41
use MARC::Record;
42
use MARC::Record;
42
use MARC::File::XML ( BinaryEncoding => 'utf8' );
43
use MARC::File::XML ( BinaryEncoding => 'utf8' );
Lines 7257-7262 if ( CheckVersion($DBversion) ) { Link Here
7257
7258
7258
    $dbh->{AutoCommit} = 1;
7259
    $dbh->{AutoCommit} = 1;
7259
    $dbh->{RaiseError} = 0;
7260
    $dbh->{RaiseError} = 0;
7261
   SetVersion ($DBversion);
7260
}
7262
}
7261
7263
7262
$DBversion = "3.13.00.031";
7264
$DBversion = "3.13.00.031";
Lines 8814-8820 if ( CheckVersion($DBversion) ) { Link Here
8814
    $dbh->do("ALTER TABLE  `biblioitems` CHANGE  `cn_sort`  `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8816
    $dbh->do("ALTER TABLE  `biblioitems` CHANGE  `cn_sort`  `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8815
    $dbh->do("ALTER TABLE  `deletedbiblioitems` CHANGE  `cn_sort`  `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8817
    $dbh->do("ALTER TABLE  `deletedbiblioitems` CHANGE  `cn_sort`  `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8816
    print "Upgrade to $DBversion done (Bug 12424 - ddc sorting of call numbers truncates long Cutter parts)\n";
8818
    print "Upgrade to $DBversion done (Bug 12424 - ddc sorting of call numbers truncates long Cutter parts)\n";
8817
    SetVersion ($DBversion);
8819
    SetVersion($DBversion);
8818
}
8820
}
8819
8821
8820
$DBversion = "3.17.00.030";
8822
$DBversion = "3.17.00.030";
Lines 9672-9678 if ( CheckVersion($DBversion) ) { Link Here
9672
    $dbh->do(q|SET foreign_key_checks = 1|);;
9674
    $dbh->do(q|SET foreign_key_checks = 1|);;
9673
9675
9674
    print "Upgrade to $DBversion done (Bug 11944 - Convert DB tables to utf8_unicode_ci)\n";
9676
    print "Upgrade to $DBversion done (Bug 11944 - Convert DB tables to utf8_unicode_ci)\n";
9675
    SetVersion ($DBversion);
9677
    SetVersion($DBversion);
9676
}
9678
}
9677
9679
9678
$DBversion = "3.19.00.007";
9680
$DBversion = "3.19.00.007";
Lines 9867-9872 if(CheckVersion($DBversion)) { Link Here
9867
    SetVersion($DBversion);
9869
    SetVersion($DBversion);
9868
}
9870
}
9869
9871
9872
$DBversion = "XXX";
9873
if ( CheckVersion($DBversion) ) {
9874
    $dbh->do(q{
9875
        ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
9876
    });
9877
    $dbh->do(q{
9878
        ALTER TABLE issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
9879
    });
9880
    $dbh->do(q{
9881
        UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC
9882
    });
9883
9884
    $dbh->do(q{
9885
        UPDATE accountlines a LEFT JOIN issues i USING ( borrowernumber, itemnumber ) SET accounttype = 'F' WHERE i.issue_id IS NULL
9886
    });
9887
9888
    $dbh->do("
9889
        CREATE TABLE IF NOT EXISTS account_credits (
9890
            credit_id int(11) NOT NULL AUTO_INCREMENT,
9891
            borrowernumber int(11) NOT NULL,
9892
            `type` varchar(255) NOT NULL,
9893
            amount_received decimal(28,6) DEFAULT NULL,
9894
            amount_paid decimal(28,6) NOT NULL,
9895
            amount_remaining decimal(28,6) NOT NULL,
9896
            amount_voided decimal(28,6) NULL DEFAULT NULL,
9897
            notes text,
9898
            branchcode VARCHAR( 10 ) NULL DEFAULT NULL,
9899
            manager_id int(11) DEFAULT NULL,
9900
            created_on timestamp NULL DEFAULT NULL,
9901
            updated_on timestamp NULL DEFAULT NULL,
9902
            PRIMARY KEY (credit_id),
9903
            KEY borrowernumber (borrowernumber),
9904
            KEY branchcode (branchcode)
9905
        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
9906
    ");
9907
    $dbh->do("
9908
        CREATE TABLE IF NOT EXISTS account_debits (
9909
            debit_id int(11) NOT NULL AUTO_INCREMENT,
9910
            borrowernumber int(11) NOT NULL DEFAULT '0',
9911
            itemnumber int(11) DEFAULT NULL,
9912
            issue_id int(11) DEFAULT NULL,
9913
            `type` varchar(255) NOT NULL,
9914
            accruing tinyint(1) NOT NULL DEFAULT '0',
9915
            amount_original decimal(28,6) DEFAULT NULL,
9916
            amount_outstanding decimal(28,6) DEFAULT NULL,
9917
            amount_last_increment decimal(28,6) DEFAULT NULL,
9918
            description mediumtext,
9919
            notes text,
9920
            branchcode VARCHAR( 10 ) NULL DEFAULT NULL,
9921
            manager_id int(11) DEFAULT NULL,
9922
            created_on timestamp NULL DEFAULT NULL,
9923
            updated_on timestamp NULL DEFAULT NULL,
9924
            PRIMARY KEY (debit_id),
9925
            KEY acctsborridx (borrowernumber),
9926
            KEY itemnumber (itemnumber),
9927
            KEY borrowernumber (borrowernumber),
9928
            KEY issue_id (issue_id),
9929
            KEY branchcode (branchcode)
9930
        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
9931
    ");
9932
9933
    $dbh->do("
9934
        CREATE TABLE account_offsets (
9935
            offset_id int(11) NOT NULL AUTO_INCREMENT,
9936
            debit_id int(11) DEFAULT NULL,
9937
            credit_id int(11) DEFAULT NULL,
9938
            `type` varchar(255) DEFAULT NULL,
9939
            amount decimal(28,6) NOT NULL COMMENT 'A positive number here represents a payment, a negative is a increase in a fine.',
9940
            created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
9941
            PRIMARY KEY (offset_id),
9942
            KEY fee_id (debit_id),
9943
            KEY payment_id (credit_id)
9944
        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
9945
    ");
9946
9947
    $dbh->do("
9948
        ALTER TABLE `account_credits`
9949
          ADD CONSTRAINT account_credits_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
9950
          ADD CONSTRAINT account_credits_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE;
9951
    ");
9952
    $dbh->do("
9953
        ALTER TABLE `account_debits`
9954
          ADD CONSTRAINT account_debits_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
9955
          ADD CONSTRAINT account_debits_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE;
9956
    ");
9957
    $dbh->do("
9958
        ALTER TABLE `account_offsets`
9959
          ADD CONSTRAINT account_offsets_ibfk_1 FOREIGN KEY (debit_id) REFERENCES account_debits (debit_id) ON DELETE CASCADE ON UPDATE CASCADE,
9960
          ADD CONSTRAINT account_offsets_ibfk_2 FOREIGN KEY (credit_id) REFERENCES account_credits (credit_id) ON DELETE CASCADE ON UPDATE CASCADE;
9961
    ");
9962
9963
    $dbh->do("
9964
        ALTER TABLE borrowers ADD account_balance DECIMAL( 28, 6 ) NOT NULL;
9965
    ");
9966
9967
    my $schema = Koha::Database->new()->schema;
9968
    my $debit_rs = $schema->resultset('AccountDebit');
9969
    my $credit_rs = $schema->resultset('AccountCredit');
9970
    my $issues_rs = $schema->resultset('Issue');
9971
9972
    use Koha::Accounts::DebitTypes;
9973
    use Koha::Accounts::CreditTypes;
9974
9975
    my $debit_types_map = {
9976
        'A'    => Koha::Accounts::DebitTypes::AccountManagementFee,
9977
        'F'    => Koha::Accounts::DebitTypes::Fine,
9978
        'FU'   => Koha::Accounts::DebitTypes::Fine,
9979
        'L'    => Koha::Accounts::DebitTypes::Lost,
9980
        'M'    => Koha::Accounts::DebitTypes::Sundry,
9981
        'N'    => Koha::Accounts::DebitTypes::NewCard,
9982
        'Rent' => Koha::Accounts::DebitTypes::Rental,
9983
    };
9984
9985
    my $credit_types_map = {
9986
        'FOR' => Koha::Accounts::CreditTypes::Forgiven,
9987
        'LR'  => Koha::Accounts::CreditTypes::Found,
9988
        'Pay' => Koha::Accounts::CreditTypes::Payment,
9989
        'PAY' => Koha::Accounts::CreditTypes::Payment,
9990
        'WO'  => Koha::Accounts::CreditTypes::WriteOff,
9991
        'W'   => Koha::Accounts::CreditTypes::WriteOff,
9992
        'C'   => Koha::Accounts::CreditTypes::Credit,
9993
        'CR'  => Koha::Accounts::CreditTypes::Credit,
9994
    };
9995
9996
    my $sth = $dbh->prepare("SELECT * FROM accountlines");
9997
    $sth->execute();
9998
    while ( my $a = $sth->fetchrow_hashref() ) {
9999
        if ( $debit_types_map->{ $a->{accounttype} } ) {
10000
            $debit_rs->create(
10001
                {
10002
                    borrowernumber     => $a->{borrowernumber},
10003
                    itemnumber         => $a->{itemnumber},
10004
                    amount_original    => $a->{amount},
10005
                    amount_outstanding => $a->{amountoutstanding},
10006
                    created_on         => $a->{timestamp},
10007
                    description        => $a->{description},
10008
                    notes              => $a->{note},
10009
                    manager_id         => $a->{manager_id},
10010
                    accruing           => $a->{accounttype} eq 'FU',
10011
                    type     => $debit_types_map->{ $a->{accounttype} },
10012
                    issue_id => $a->{accounttype} eq 'FU'
10013
                    ? $issues_rs->single(
10014
                        {
10015
                            borrowernumber => $a->{borrowernumber},
10016
                            itemnumber     => $a->{itemnumber},
10017
                        }
10018
                      )->issue_id()
10019
                    : undef,
10020
                }
10021
            );
10022
        }
10023
        elsif ( $credit_types_map->{ $a->{accounttype} } ) {
10024
            $credit_rs->create(
10025
                {
10026
                    borrowernumber   => $a->{borrowernumber},
10027
                    amount_paid      => $a->{amount} * -1,
10028
                    amount_remaining => $a->{amountoutstanding} * -1,
10029
                    created_on       => $a->{timestamp},
10030
                    notes            => $a->{note},
10031
                    manager_id       => $a->{manager_id},
10032
                    type => $credit_types_map->{ $a->{accounttype} },
10033
                }
10034
            );
10035
        }
10036
        else {
10037
            # Everything else must be a MANUAL_INV
10038
            $debit_rs->create(
10039
                {
10040
                    borrowernumber     => $a->{borrowernumber},
10041
                    itemnumber         => $a->{itemnumber},
10042
                    amount_original    => $a->{amount},
10043
                    amount_outstanding => $a->{amountoutstanding},
10044
                    created_on         => $a->{timestamp},
10045
                    description        => $a->{description},
10046
                    notes              => $a->{note},
10047
                    manager_id         => $a->{manager_id},
10048
                    type               => Koha::Accounts::DebitTypes::Sundry,
10049
                }
10050
            );
10051
        }
10052
    }
10053
10054
    print "Upgrade to $DBversion done ( Bug 6427 - Rewrite of the accounts system )\n";
10055
    SetVersion ($DBversion);
10056
}
10057
10058
9870
=head1 FUNCTIONS
10059
=head1 FUNCTIONS
9871
10060
9872
=head2 TableExists($table)
10061
=head2 TableExists($table)
9873
- 

Return to bug 6427