Browse Source

Bug 18731: Add API mappings to K::A::{Basket,Invoice}

This patch adds to_api_mapping definitions to the following classes:

- Koha::Acquisition::Basket
- Koha::Acquisition::Invoice

They are implemented following the proposed RFCs:
https://wiki.koha-community.org/wiki/Acquisitions_baskets_endpoint_RFC
https://wiki.koha-community.org/wiki/Acquisitions_invoices_endpoint_RFC

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
20.05.x
Tomás Cohen Arazi 4 years ago
committed by Martin Renvoize
parent
commit
5d8ae2e6c8
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 47
      Koha/Acquisition/Basket.pm
  2. 43
      Koha/Acquisition/Invoice.pm
  3. 4
      Koha/Schema/Result/Aqbasket.pm

47
Koha/Acquisition/Basket.pm

@ -71,6 +71,53 @@ sub effective_create_items {
return $self->create_items || C4::Context->preference('AcqCreateItem');
}
=head3 to_api
my $json = $basket->to_api;
Overloaded method that returns a JSON representation of the Koha::Acquisition::Basket object,
suitable for API output.
=cut
sub to_api {
my ( $self ) = @_;
my $json = $self->SUPER::to_api;
$json->{closed} = ( $self->closedate )
? Mojo::JSON->true
: Mojo::JSON->false;
return $json;
}
=head3 to_api_mapping
This method returns the mapping for representing a Koha::Acquisition::Basket object
on the API.
=cut
sub to_api_mapping {
return {
basketno => 'basket_id',
basketname => 'name',
booksellernote => 'vendor_note',
contractnumber => 'contract_id',
creationdate => 'creation_date',
closedate => 'close_date',
booksellerid => 'vendor_id',
authorisedby => 'authorised_by',
booksellerinvoicenumber => undef,
basketgroupid => 'basket_group_id',
deliveryplace => 'delivery_place',
billingplace => 'billing_place',
branch => 'library_id',
is_standing => 'standing'
};
}
=head2 Internal methods
=head3 _type

43
Koha/Acquisition/Invoice.pm

@ -27,6 +27,49 @@ Koha::Acquisition::Invoice object class
=head1 API
=head3 to_api
my $json = $invoice->to_api;
Overloaded method that returns a JSON representation of the Koha::Acquisition::Invoice object,
suitable for API output.
=cut
sub to_api {
my ( $self ) = @_;
my $json = $self->SUPER::to_api;
$json->{closed} = ( $self->closedate )
? Mojo::JSON->true
: Mojo::JSON->false;
return $json;
}
=head3 to_api_mapping
This method returns the mapping for representing a Koha::Acquisition::Invoice object
on the API.
=cut
sub to_api_mapping {
return {
invoiceid => 'invoice_id',
invoicenumber => 'invoice_number',
booksellerid => 'vendor_id',
shipmentdate => 'shipping_date',
billingdate => 'invoice_date',
closedate => 'close_date',
shipmentcost => 'shipping_cost',
shipmentcost_budgetid => 'shipping_cost_budget_id',
message_id => undef
};
}
=head2 Internal methods
=head3 _type

4
Koha/Schema/Result/Aqbasket.pm

@ -335,4 +335,8 @@ sub koha_objects_class {
'Koha::Acquisition::Baskets';
}
__PACKAGE__->add_columns(
'+is_standing' => { is_boolean => 1 }
);
1;

Loading…
Cancel
Save