Skip to content

Commit

Permalink
ACQUI-141: Rename fiscal year to fiscal period
Browse files Browse the repository at this point in the history
  • Loading branch information
mblenk committed Jun 20, 2024
1 parent ba81f15 commit c4b73d5
Show file tree
Hide file tree
Showing 27 changed files with 258 additions and 258 deletions.
8 changes: 4 additions & 4 deletions Koha/Plugin/Acquire.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ BEGIN {
require Koha::Schema::Result::KohaPluginAcquireWorkflowTask;
Koha::Schema->register_class( KohaPluginAcquireWorkflowTask => 'Koha::Schema::Result::KohaPluginAcquireWorkflowTask' );

require Koha::Acquire::Funds::FiscalYears;
require Koha::Schema::Result::KohaPluginAcquireFiscalYear;
Koha::Schema->register_class( KohaPluginAcquireFiscalYear => 'Koha::Schema::Result::KohaPluginAcquireFiscalYear' );
require Koha::Acquire::Funds::FiscalPeriods;
require Koha::Schema::Result::KohaPluginAcquireFiscalPeriod;
Koha::Schema->register_class( KohaPluginAcquireFiscalPeriod => 'Koha::Schema::Result::KohaPluginAcquireFiscalPeriod' );

require Koha::Acquire::Funds::Ledgers;
require Koha::Schema::Result::KohaPluginAcquireLedger;
Expand Down Expand Up @@ -99,7 +99,7 @@ sub install {
table_name_mappings => {
settings => $self->get_qualified_table_name('settings'),
workflow_tasks => $self->get_qualified_table_name('workflow_tasks'),
fiscal_year => $self->get_qualified_table_name('fiscal_year'),
fiscal_period => $self->get_qualified_table_name('fiscal_period'),
ledgers => $self->get_qualified_table_name('ledgers'),
funds => $self->get_qualified_table_name('funds'),
sub_funds => $self->get_qualified_table_name('sub_funds'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Koha::Plugin::Acquire::Controllers::FundManagement::FiscalYears;
package Koha::Plugin::Acquire::Controllers::FundManagement::FiscalPeriods;

# Copyright 2024 PTFS Europe

Expand All @@ -23,8 +23,8 @@ use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON qw(decode_json);
use Try::Tiny;

use Koha::Acquire::Funds::FiscalYear;
use Koha::Acquire::Funds::FiscalYears;
use Koha::Acquire::Funds::FiscalPeriod;
use Koha::Acquire::Funds::FiscalPeriods;

use Koha::Plugin::Acquire::Controllers::ControllerUtils;

Expand All @@ -42,14 +42,14 @@ sub list {
my $c = shift->openapi->valid_input or return;

return try {
my $fiscal_years_set = Koha::Acquire::Funds::FiscalYears->new;
my $fiscal_years = $c->objects->search($fiscal_years_set);
my $fiscal_periods_set = Koha::Acquire::Funds::FiscalPeriods->new;
my $fiscal_periods = $c->objects->search($fiscal_periods_set);

my $filtered_fiscal_years = Koha::Plugin::Acquire::Controllers::ControllerUtils->filter_data_by_group({
dataset => $fiscal_years
my $filtered_fiscal_periods = Koha::Plugin::Acquire::Controllers::ControllerUtils->filter_data_by_group({
dataset => $fiscal_periods
});

return $c->render( status => 200, openapi => $filtered_fiscal_years );
return $c->render( status => 200, openapi => $filtered_fiscal_periods );
} catch {
$c->unhandled_exception($_);
};
Expand All @@ -64,22 +64,22 @@ sub get {
my $c = shift->openapi->valid_input or return;

return try {
my $fiscal_years_set = Koha::Acquire::Funds::FiscalYears->new;
my $fiscal_year = $c->objects->find( $fiscal_years_set, $c->param('id') );
my $fiscal_periods_set = Koha::Acquire::Funds::FiscalPeriods->new;
my $fiscal_period = $c->objects->find( $fiscal_periods_set, $c->param('id') );

unless ($fiscal_year) {
unless ($fiscal_period) {
return $c->render(
status => 404,
openapi => { error => "Fiscal year not found" }
openapi => { error => "Fiscal period not found" }
);
}

$fiscal_year =
Koha::Plugin::Acquire::Controllers::ControllerUtils->add_lib_group_data( { data => $fiscal_year } );
$fiscal_period =
Koha::Plugin::Acquire::Controllers::ControllerUtils->add_lib_group_data( { data => $fiscal_period } );

return $c->render(
status => 200,
openapi => $fiscal_year
openapi => $fiscal_period
);
} catch {
$c->unhandled_exception($_);
Expand All @@ -100,12 +100,12 @@ sub add {
my $body = $c->req->json;
delete $body->{lib_groups} if $body->{lib_groups};

my $fiscal_year = Koha::Acquire::Funds::FiscalYear->new_from_api($body)->store;
my $fiscal_period = Koha::Acquire::Funds::FiscalPeriod->new_from_api($body)->store;

$c->res->headers->location( $c->req->url->to_string . '/' . $fiscal_year->fiscal_yr_id );
$c->res->headers->location( $c->req->url->to_string . '/' . $fiscal_period->fiscal_yr_id );
return $c->render(
status => 201,
openapi => $fiscal_year->to_api
openapi => $fiscal_period->to_api
);
}
);
Expand All @@ -116,19 +116,19 @@ sub add {

=head3 update
Controller function that handles updating a Koha::Acquire::Funds::FiscalYear object
Controller function that handles updating a Koha::Acquire::Funds::FiscalPeriod object
=cut

sub update {
my $c = shift->openapi->valid_input or return;

my $fiscal_year = Koha::Acquire::Funds::FiscalYears->find( $c->param('id') );
my $fiscal_period = Koha::Acquire::Funds::FiscalPeriods->find( $c->param('id') );

unless ($fiscal_year) {
unless ($fiscal_period) {
return $c->render(
status => 404,
openapi => { error => "Fiscal year not found" }
openapi => { error => "Fiscal period not found" }
);
}

Expand All @@ -141,17 +141,17 @@ sub update {
delete $body->{lib_groups} if $body->{lib_groups};
delete $body->{last_updated} if $body->{last_updated};

$fiscal_year->set_from_api($body)->store;
$fiscal_period->set_from_api($body)->store;

$c->res->headers->location( $c->req->url->to_string . '/' . $fiscal_year->fiscal_yr_id );
$c->res->headers->location( $c->req->url->to_string . '/' . $fiscal_period->fiscal_yr_id );
return $c->render(
status => 200,
openapi => $fiscal_year->to_api
openapi => $fiscal_period->to_api
);
}
);
} catch {
my $to_api_mapping = Koha::Acquire::Funds::FiscalYear->new->to_api_mapping;
my $to_api_mapping = Koha::Acquire::Funds::FiscalPeriod->new->to_api_mapping;

if ( blessed $_ ) {
if ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) {
Expand Down Expand Up @@ -183,16 +183,16 @@ sub update {
sub delete {
my $c = shift->openapi->valid_input or return;

my $fiscal_year = Koha::Acquire::Funds::FiscalYears->find( $c->param('id') );
unless ($fiscal_year) {
my $fiscal_period = Koha::Acquire::Funds::FiscalPeriods->find( $c->param('id') );
unless ($fiscal_period) {
return $c->render(
status => 404,
openapi => { error => "Fiscal year not found" }
openapi => { error => "Fiscal period not found" }
);
}

return try {
$fiscal_year->delete;
$fiscal_period->delete;
return $c->render(
status => 204,
openapi => q{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ sub update {
my $body = $c->req->json;

delete $body->{lib_groups} if $body->{lib_groups};
delete $body->{fiscal_year} if $body->{fiscal_year};
delete $body->{fiscal_period} if $body->{fiscal_period};
delete $body->{last_updated} if $body->{last_updated};

$fund_allocation->set_from_api($body)->store;
Expand Down
2 changes: 1 addition & 1 deletion Koha/Plugin/Acquire/Controllers/FundManagement/Ledgers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ sub update {
my $body = $c->req->json;

delete $body->{lib_groups} if $body->{lib_groups};
delete $body->{fiscal_year} if $body->{fiscal_year};
delete $body->{fiscal_period} if $body->{fiscal_period};
delete $body->{last_updated} if $body->{last_updated};

$ledger->set_from_api($body)->store;
Expand Down
50 changes: 25 additions & 25 deletions Koha/Plugin/Acquire/api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,11 @@
}
}
},
"/fiscal_years": {
"/fiscal_periods": {
"get": {
"x-mojo-to": "Acquire::Controllers::FundManagement::FiscalYears#list",
"operationId": "AcquireGetFiscalYears",
"description": "Retrieves the fiscal years for the Acquisitions plugin module",
"x-mojo-to": "Acquire::Controllers::FundManagement::FiscalPeriods#list",
"operationId": "AcquireGetFiscalPeriods",
"description": "Retrieves the fiscal periods for the Acquisitions plugin module",
"tags": [
"Acquire"
],
Expand Down Expand Up @@ -756,7 +756,7 @@
],
"responses": {
"200": {
"description": "Fiscal year data",
"description": "Fiscal period data",
"schema": {
"type": "array"
}
Expand Down Expand Up @@ -791,8 +791,8 @@
}
},
"post": {
"x-mojo-to": "Acquire::Controllers::FundManagement::FiscalYears#add",
"operationId": "AcquireStoreFiscalYear",
"x-mojo-to": "Acquire::Controllers::FundManagement::FiscalPeriods#add",
"operationId": "AcquireStoreFiscalPeriod",
"tags": [
"Acquire"
],
Expand All @@ -801,7 +801,7 @@
],
"responses": {
"201": {
"description": "FiscalYear",
"description": "FiscalPeriod",
"schema": {
"type": "object"
}
Expand Down Expand Up @@ -836,19 +836,19 @@
}
}
},
"/fiscal_years/{id}": {
"/fiscal_periods/{id}": {
"get": {
"x-mojo-to": "Acquire::Controllers::FundManagement::FiscalYears#get",
"operationId": "getFiscalYear",
"x-mojo-to": "Acquire::Controllers::FundManagement::FiscalPeriods#get",
"operationId": "getFiscalPeriod",
"tags": [
"acquire"
],
"description": "Get a single fiscal year",
"description": "Get a single fiscal period",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of fiscal year to fetch",
"description": "ID of fiscal period to fetch",
"required": true,
"type": "integer"
},
Expand All @@ -874,7 +874,7 @@
],
"responses": {
"200": {
"description": "Fiscal year",
"description": "Fiscal period",
"schema": {
"type": "object"
}
Expand Down Expand Up @@ -960,24 +960,24 @@
}
},
"put": {
"x-mojo-to": "Acquire::Controllers::FundManagement::FiscalYears#update",
"operationId": "updateFiscalYear",
"x-mojo-to": "Acquire::Controllers::FundManagement::FiscalPeriods#update",
"operationId": "updateFiscalPeriod",
"tags": [
"acquire"
],
"description": "Update a fiscal year",
"description": "Update a fiscal period",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of fiscal year to update",
"description": "ID of fiscal period to update",
"required": true,
"type": "integer"
},
{
"name": "body",
"in": "body",
"description": "Fiscal year object that needs to be added",
"description": "Fiscal period object that needs to be added",
"required": true,
"schema": {
"type": "object"
Expand All @@ -989,7 +989,7 @@
],
"responses": {
"200": {
"description": "Fiscal year",
"description": "Fiscal period",
"schema": {
"type": "object"
}
Expand Down Expand Up @@ -1075,17 +1075,17 @@
}
},
"delete": {
"x-mojo-to": "Acquire::Controllers::FundManagement::FiscalYears#delete",
"operationId": "deleteFiscalYear",
"x-mojo-to": "Acquire::Controllers::FundManagement::FiscalPeriods#delete",
"operationId": "deleteFiscalPeriod",
"tags": [
"acquire"
],
"description": "Delete a fiscal year",
"description": "Delete a fiscal period",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of fiscal year to delete",
"description": "ID of fiscal period to delete",
"required": true,
"type": "integer"
}
Expand All @@ -1095,7 +1095,7 @@
],
"responses": {
"204": {
"description": "Fiscal year",
"description": "Fiscal period",
"schema": {
"type": "string"
}
Expand Down
14 changes: 7 additions & 7 deletions Koha/Plugin/Acquire/installer/config/schemaToUI.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"type": "string"
}
},
"fiscalYear": {
"fiscalPeriod": {
"code": {
"label": "Code",
"type": "string"
Expand Down Expand Up @@ -101,11 +101,11 @@
"type": "string"
},
"fiscal_yr_id": {
"label": "Fiscal year",
"label": "Fiscal period",
"type": "link",
"dataType": "fiscal_yr",
"linkId": "fiscal_yr_id",
"linkSlug": "fiscal_year",
"linkSlug": "fiscal_period",
"linkName": "code"
},
"owner": {
Expand Down Expand Up @@ -183,11 +183,11 @@
"type": "string"
},
"fiscal_yr_id": {
"label": "Fiscal year",
"label": "Fiscal period",
"type": "link",
"dataType": "fiscal_yr",
"linkId": "fiscal_yr_id",
"linkSlug": "fiscal_year",
"linkSlug": "fiscal_period",
"linkName": "code"
},
"ledger_id": {
Expand Down Expand Up @@ -260,11 +260,11 @@
"type": "string"
},
"fiscal_yr_id": {
"label": "Fiscal year",
"label": "Fiscal period",
"type": "link",
"dataType": "fiscal_yr",
"linkId": "fiscal_yr_id",
"linkSlug": "fiscal_year",
"linkSlug": "fiscal_period",
"linkName": "code"
},
"ledger_id": {
Expand Down
Loading

0 comments on commit c4b73d5

Please sign in to comment.