use C4::Context;
use Koha::Database;
use Koha::Patrons;
-use Koha::InvoiceAdjustments;
+use Koha::Acquisition::Invoice::Adjustments;
use C4::Debug;
use vars qw(@ISA @EXPORT);
my ($shipmentcost_sum) = $sth->fetchrow_array;
$sum += $shipmentcost_sum;
- my $adjustments = Koha::InvoiceAdjustments->search({budget_id => $budget_id, closedate => { '!=' => undef } },{ join => 'invoiceid' });
+ my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $budget_id, closedate => { '!=' => undef } },{ join => 'invoiceid' });
while ( my $adj = $adjustments->next ){
$sum += $adj->adjustment;
}
$sth->execute($budget_id);
my $sum = 0 + $sth->fetchrow_array;
- my $adjustments = Koha::InvoiceAdjustments->search({budget_id => $budget_id, encumber_open => 1, closedate => undef},{ join => 'invoiceid' });
+ my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $budget_id, encumber_open => 1, closedate => undef},{ join => 'invoiceid' });
while ( my $adj = $adjustments->next ){
$sum += $adj->adjustment;
}
{ cascade_copy => 0, cascade_delete => 0 },
);
+=head2 aqinvoice_adjustments
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::AqinvoiceAdjustment>
+
+=cut
+
+__PACKAGE__->has_many(
+ "aqinvoice_adjustments",
+ "Koha::Schema::Result::AqinvoiceAdjustment",
+ { "foreign.budget_id" => "self.budget_id" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
=head2 aqinvoices
Type: has_many
__PACKAGE__->many_to_many("borrowernumbers", "aqbudgetborrowers", "borrowernumber");
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9MY8aD6YBjuLy8c7tDnZeg
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-07-16 13:50:45
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:zB7ox8a4KdDGq5fsbQfLGQ
# You can replace this text with custom content, and it will be preserved on regeneration
=head1 RELATIONS
+=head2 aqinvoice_adjustments
+
+Type: has_many
+
+Related object: L<Koha::Schema::Result::AqinvoiceAdjustment>
+
+=cut
+
+__PACKAGE__->has_many(
+ "aqinvoice_adjustments",
+ "Koha::Schema::Result::AqinvoiceAdjustment",
+ { "foreign.invoiceid" => "self.invoiceid" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
=head2 aqorders
Type: has_many
);
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SAUxWSdpMJK4atxhfgCAGg
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-07-16 13:50:45
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mpdxTbkz/8WInG5Wp4q7Ug
# You can replace this text with custom content, and it will be preserved on regeneration
use Koha::Acquisition::Currencies;
use Koha::DateUtils;
use Koha::Misc::Files;
-use Koha::InvoiceAdjustments;
+use Koha::Acquisition::Invoice::Adjustments;
my $input = new CGI;
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
}
elsif ( $op && $op eq 'del_adj' ) {
my $adjustment_id = $input->param('adjustment_id');
- my $del_adj = Koha::InvoiceAdjustments->find( $adjustment_id );
+ my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id );
$del_adj->delete() if ($del_adj);
}
elsif ( $op && $op eq 'mod_adj' ) {
for( my $i=0; $i < scalar @adjustment; $i++ ){
if( $adjustment_id[$i] eq 'new' ){
next unless ( $adjustment[$i] || $reason[$i] );
- my $new_adj = Koha::InvoiceAdjustment->new({
+ my $new_adj = Koha::Acquisition::Invoice::Adjustment->new({
invoiceid => $invoiceid,
adjustment => $adjustment[$i],
reason => $reason[$i],
$new_adj->store();
}
else {
- my $old_adj = Koha::InvoiceAdjustments->find( $adjustment_id[$i] );
+ my $old_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id[$i] );
unless ( $old_adj->adjustment == $adjustment[$i] && $old_adj->reason eq $reason[$i] && $old_adj->budget_id == $budget_id[$i] && $old_adj->encumber_open == $e_open{$adjustment_id[$i]} && $old_adj->note eq $note[$i] ){
$old_adj->timestamp(undef);
$old_adj->adjustment( $adjustment[$i] );
push @budgets_loop, \%line;
}
-my $adjustments = Koha::InvoiceAdjustments->search({ invoiceid => $details->{'invoiceid'} });
+my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({ invoiceid => $details->{'invoiceid'} });
if ( $adjustments ) { $template->param( adjustments => $adjustments ); }
$template->param(
use CGI qw ( -utf8 );
use C4::Auth;
use C4::Output;
-use Koha::InvoiceAdjustments;
+use Koha::Acquisition::Invoice::Adjustments;
my $dbh = C4::Context->dbh;
my $input = new CGI;
}
}
-my $adjustments = Koha::InvoiceAdjustments->search({budget_id => $fund_id, closedate => undef, encumber_open => 1 }, { join => 'invoiceid' } );
+my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $fund_id, closedate => undef, encumber_open => 1 }, { join => 'invoiceid' } );
while ( my $adj = $adjustments->next ){
$total += $adj->adjustment;
}
use C4::Output;
use Modern::Perl;
use CGI qw ( -utf8 );
-use Koha::InvoiceAdjustments;
+use Koha::Acquisition::Invoice::Adjustments;
my $dbh = C4::Context->dbh;
my $input = new CGI;
}
$sth->finish;
-my $adjustments = Koha::InvoiceAdjustments->search({budget_id => $bookfund, closedate => { '!=' => undef } }, { join => 'invoiceid' } );
+my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $bookfund, closedate => { '!=' => undef } }, { join => 'invoiceid' } );
while ( my $adj = $adjustments->next ){
$total += $adj->adjustment;
}
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
$dbh->do( "
- CREATE TABLE IF NOT EXISTS invoice_adjustments (
+ CREATE TABLE IF NOT EXISTS aqinvoice_adjustments (
adjustment_id int(11) NOT NULL AUTO_INCREMENT,
invoiceid int(11) NOT NULL,
adjustment decimal(28,6),
encumber_open smallint(1) NOT NULL default 1,
timestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (adjustment_id),
- CONSTRAINT invoice_adjustments_fk_invoiceid FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT invoice_adjustments_fk_budget_id FOREIGN KEY (budget_id) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
+ CONSTRAINT aqinvoice_adjustments_fk_invoiceid FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT aqinvoice_adjustments_fk_budget_id FOREIGN KEY (budget_id) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
" );
$dbh->do("INSERT IGNORE INTO authorised_value_categories (category_name) VALUES ('ADJ_REASON')");
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
--- Table structure for table 'invoice_adjustments'
---
-
-DROP TABLE IF EXISTS invoice_adjustments;
-CREATE TABLE IF NOT EXISTS invoice_adjustments (
- adjustment_id int(11) NOT NULL AUTO_INCREMENT, -- primary key for adjustments
- invoiceid int(11) NOT NULL, -- foreign key to link an adjustment to an invoice
- adjustment decimal(28,6), -- amount of adjustment
- reason varchar(80) default NULL, -- reason for adjustment defined by authorised values in ADJ_REASON category
- note mediumtext default NULL, -- text to explain adjustment
- budget_id int(11) default NULL, -- optional link to budget to apply adjustment to
- encumber_open smallint(1) NOT NULL default 1, -- whether or not to encumber the finds when invoice is still open, 1 = yes, 0 = no
- timestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- timestamp of last adjustment to adjustment
- PRIMARY KEY (adjustment_id),
- CONSTRAINT invoice_adjustments_fk_invoiceid FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT invoice_adjustments_fk_budget_id FOREIGN KEY (budget_id) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
---
-- Table structure for table `issuingrules`
--
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
+-- Table structure for table 'aqinvoice_adjustments'
+--
+
+DROP TABLE IF EXISTS aqinvoice_adjustments;
+CREATE TABLE IF NOT EXISTS aqinvoice_adjustments (
+ adjustment_id int(11) NOT NULL AUTO_INCREMENT, -- primary key for adjustments
+ invoiceid int(11) NOT NULL, -- foreign key to link an adjustment to an invoice
+ adjustment decimal(28,6), -- amount of adjustment
+ reason varchar(80) default NULL, -- reason for adjustment defined by authorised values in ADJ_REASON category
+ note mediumtext default NULL, -- text to explain adjustment
+ budget_id int(11) default NULL, -- optional link to budget to apply adjustment to
+ encumber_open smallint(1) NOT NULL default 1, -- whether or not to encumber the finds when invoice is still open, 1 = yes, 0 = no
+ timestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- timestamp of last adjustment to adjustment
+ PRIMARY KEY (adjustment_id),
+ CONSTRAINT aqinvoice_adjustments_fk_invoiceid FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT aqinvoice_adjustments_fk_budget_id FOREIGN KEY (budget_id) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+--
-- Table structure for table `aqorders`
--
<form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
<fieldset class="rows">
<input type="hidden" name="invoiceid" value="[% invoiceid %]" />
- [% IF (adjustments.count > 0) %]
+ [% IF (adjustments && adjustments.count > 0) %]
<table id="invoice_adj_table">
<tr>
<th>Id</th>
[% END %]
</tbody>
<tfoot>
- [% IF ( adjustments.count > 0 ) %]
+ [% IF ( adjustments && adjustments.count > 0 ) %]
[% FOREACH adjustment IN adjustments %]
<tr>
<td></td>
[% END %]
<tfoot>
- [% IF shipmentcosts.size || ( adjustments.count > 0 ) %]
+ [% IF shipmentcosts.size || ( adjustments && adjustments.count > 0 ) %]
<tr valign="top">
<td colspan="9"> Sub total </td>
<td class="data"> [% subtotal %] </td>
</tr>
[% END %]
[% END %]
- [% IF ( adjustments.count > 0 ) %]
+ [% IF ( adjustments && adjustments.count > 0 ) %]
[% FOREACH adjustment IN adjustments %]
<tr>
<td></td>
is( $ordered, 0, "New budget, no orders/invoices, should be nothing ordered");
my $inv_adj_1 = $builder->build({
- source => 'InvoiceAdjustment',
+ source => 'AqinvoiceAdjustment',
value => {
invoiceid => $invoice->{invoiceid},
adjustment => 3,
is( $ordered, 0, "After adding invoice adjustment on open invoice not encumbered, should be nothing ordered");
my $inv_adj_2 = $builder->build({
- source => 'InvoiceAdjustment',
+ source => 'AqinvoiceAdjustment',
value => {
invoiceid => $invoice->{invoiceid},
adjustment => 3,
}
});
my $inv_adj_3 = $builder->build({
- source => 'InvoiceAdjustment',
+ source => 'AqinvoiceAdjustment',
value => {
invoiceid => $invoice_2->{invoiceid},
adjustment => 3,
}
});
my $inv_adj_4 = $builder->build({
- source => 'InvoiceAdjustment',
+ source => 'AqinvoiceAdjustment',
value => {
invoiceid => $invoice_2->{invoiceid},
adjustment => 3,
}
});
my $inv_adj_5 = $builder->build({
- source => 'InvoiceAdjustment',
+ source => 'AqinvoiceAdjustment',
value => {
invoiceid => $invoice->{invoiceid},
adjustment => 3,
}
});
my $inv_adj_6 = $builder->build({
- source => 'InvoiceAdjustment',
+ source => 'AqinvoiceAdjustment',
value => {
invoiceid => $invoice_2->{invoiceid},
adjustment => 3,