Koha/api/v1/swagger/definitions/order.json
Tomas Cohen Arazi ade441def4 Bug 20212: Add more embeddable objects to orders
This patch adds options to embed more related objects based on the needs
by parcel.tt.

For filtering by biblioitems fields (ISBN and EAN) I had to make the
'list' method a modified version of the objects->search helper. I
thought of doing it in a more generic way but I didn't find any other
use cases and it would certainly make an already complex piece of code
even more complex.

So this is quite similar, but at some steps the biblio.<biblioitem
field> gets translated into the proper relation names, and the same
happens for prefetching.

A new parameter is also added: only_active. It makes the controller use
Koha::Acquisition::Orders->filter_by_active, avoiding the need to build
complex queries in the UI.

The same handling is done when the order_id parameter is passed (outside
the q= parameters). In this case using Koha::Acquisition::Orders->filter_by_id_including_transfers

This is all respecting the C4::Acquisitions::SearchOrders behaviour.

TL;DR:

This patch adapts the code from the list() sub so it manipulates the
query parameters and the embed header so:
- the biblioitem relationship is prefetch
- any queries on biblio.isbn and biblio.ean are correctly translated into search on the
  biblioitems table.
- Adds an only_active parameter to the /acquisitions/orders route to
  easily request only the active orders.

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-01-28 16:44:11 +01:00

335 lines
8.7 KiB
JSON

{
"type": "object",
"properties": {
"order_id": {
"type": "integer",
"description": "Internally assigned order identifier"
},
"biblio_id": {
"type": [
"integer",
"null"
],
"description": "Identifier for the linked bibliographic record"
},
"created_by": {
"type": [
"integer",
"null"
],
"description": "Interal patron identifier of the order line creator"
},
"entry_date": {
"type": [
"string",
"null"
],
"format": "date",
"description": "Date the bib was added to the basket"
},
"quantity": {
"type": [
"integer",
"null"
],
"description": "Ordered quantity"
},
"currency": {
"type": [
"string",
"null"
],
"description": "Currency used for the purchase"
},
"list_price": {
"type": [
"number",
"null"
],
"description": "Vendor price for the line item"
},
"replacement_price": {
"type": [
"number",
"null"
],
"description": "Replacement cost for this item"
},
"date_received": {
"type": [
"string",
"null"
],
"format": "date",
"description": "Date the order was received"
},
"invoice_id": {
"type": [
"integer",
"null"
],
"description": "Id of the order invoice"
},
"shipping_cost": {
"type": [
"number",
"null"
],
"description": "Shipping cost"
},
"unit_price": {
"type": [
"number",
"null"
],
"description": "The actual cost entered when receiving this line item"
},
"unit_price_tax_excluded": {
"type": [
"number",
"null"
],
"description": "Unit price excluding tax (on receiving)"
},
"unit_price_tax_included": {
"type": [
"number",
"null"
],
"description": "Unit price including tax (on receiving)"
},
"quantity_received": {
"type": "integer",
"description": "Quantity received so far"
},
"cancellation_date": {
"type": [
"string",
"null"
],
"format": "date",
"description": "Date the line item was deleted"
},
"cancellation_reason": {
"type": [
"string",
"null"
],
"description": "Reason of cancellation"
},
"internal_note": {
"type": [
"string",
"null"
],
"description": "Notes related to this order line, made for staff"
},
"vendor_note": {
"type": [
"string",
"null"
],
"description": "Notes related to this order line, made for vendor"
},
"basket_id": {
"type": [
"integer",
"null"
],
"description": "Basket this order is linked to"
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "Date and time this order line was last modified"
},
"rrp": {
"type": [
"number",
"null"
],
"description": "Retail cost for this item"
},
"rrp_tax_excluded": {
"type": [
"number",
"null"
],
"description": "Replacement cost for this item (tax excluded)"
},
"rrp_tax_included": {
"type": [
"number",
"null"
],
"description": "Replacement cost for this item (tax included)"
},
"ecost": {
"type": [
"number",
"null"
],
"description": "Effective cost"
},
"ecost_tax_excluded": {
"type": [
"number",
"null"
],
"description": "Effective cost (tax excluded)"
},
"ecost_tax_included": {
"type": [
"number",
"null"
],
"description": "Effective cost (tax included)"
},
"tax_rate_on_ordering": {
"type": [
"number",
"null"
],
"description": "Tax rate on ordering (%)"
},
"tax_rate_on_receiving": {
"type": [
"number",
"null"
],
"description": "Tax rate on receiving (%)"
},
"tax_value_on_ordering": {
"type": [
"number",
"null"
],
"description": "Tax value on ordering"
},
"tax_value_on_receiving": {
"type": [
"number",
"null"
],
"description": "Tax value on receiving"
},
"discount_rate": {
"type": [
"number",
"null"
],
"description": "Discount rate"
},
"fund_id": {
"type": "integer",
"description": "Internal identifier for the fund this order goes against"
},
"statistics_1": {
"type": [
"string",
"null"
],
"description": "Statistical field"
},
"statistics_2": {
"type": [
"string",
"null"
],
"description": "Statistical field (2)"
},
"statistics_1_authcat": {
"type": [
"string",
"null"
],
"description": "Statistical category for this order"
},
"statistics_2_authcat": {
"type": [
"string",
"null"
],
"description": "Statistical category for this order (2)"
},
"uncertain_price": {
"type": "boolean",
"description": "If this price was uncertain"
},
"claims_count": {
"type": "integer",
"description": "Generated claim letters count"
},
"last_claim_date": {
"type": [
"string",
"null"
],
"format": "date",
"description": "Last date a claim letter was generated"
},
"subscription_id": {
"type": [
"integer",
"null"
],
"description": "Subscription ID linking the order to a subscription"
},
"parent_order_id": {
"type": [
"integer",
"null"
],
"description": "Order ID of parent order line if exists"
},
"status": {
"type": "string",
"enum": [
"new",
"ordered",
"partial",
"complete",
"cancelled"
],
"description": "The current order status"
},
"basket": {
"type": [
"object",
"null"
]
},
"biblio": {
"type": [
"object",
"null"
]
},
"current_item_level_holds_count": {
"type": "integer",
"description": "Current holds count for associated items"
},
"fund": {
"type": [
"object",
"null"
]
},
"invoice": {
"type": [
"object",
"null"
]
},
"items": {
"type": "array"
},
"subscription": {
"type": [
"object",
"null"
]
}
},
"additionalProperties": false
}