Skip to content

Commit 73d6672

Browse files
jmaPascalRepond
andcommitted
primeng: acquistion (in progress)
Co-Authored-by: Johnny Mariéthoz <[email protected]> Co-Authored-by: Pascal Repond <[email protected]>
1 parent 2f09105 commit 73d6672

File tree

35 files changed

+111
-352
lines changed

35 files changed

+111
-352
lines changed

Dockerfile.base

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FROM python:3.9-slim-bullseye
2020
# require debian packages
2121
RUN apt-get update -y && apt-get upgrade -y
2222
RUN apt-get install --no-install-recommends -y git vim-tiny curl gcc gnupg libc6-dev procps imagemagick && rm -rf /var/lib/apt/lists/*
23-
RUN pip install --upgrade setuptools wheel pip poetry
23+
RUN pip install --upgrade setuptools wheel pip poetry && poetry self add poetry-plugin-shell
2424

2525
# # uwsgi uwsgitop uwsgi-tools
2626

INSTALL.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ among other things.
5858
$ pyenv install 3.9.7
5959
$ cd rero-ils
6060
$ pyenv local 3.9.7
61-
$ sudo pip install poetry
61+
$ curl -sSL https://install.python-poetry.org | python3 -
62+
$ optional: poetry self add poetry-plugin-shell
63+
64+
See: https://python-poetry.org/docs#installation for more detail.
6265

6366
Next, ``cd`` into the project directory and bootstrap the instance (this will install
6467
all Python dependencies and build all static assets):

data/acq_order_lines.json

+9-28
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"priority": 0,
55
"quantity": 3,
66
"amount": 25,
7-
"exchange_rate": 1,
87
"notes": [
98
{
109
"type": "staff_note",
@@ -23,15 +22,13 @@
2322
"library": {
2423
"$ref": "https://bib.rero.ch/api/libraries/1"
2524
},
26-
"is_cancelled": false,
27-
"send_now": true
25+
"is_cancelled": false
2826
},
2927
{
3028
"pid": "2",
3129
"priority": 0,
3230
"quantity": 15,
3331
"amount": 5,
34-
"exchange_rate": 1,
3532
"notes": [
3633
{
3734
"type": "staff_note",
@@ -50,15 +47,13 @@
5047
"library": {
5148
"$ref": "https://bib.rero.ch/api/libraries/1"
5249
},
53-
"is_cancelled": false,
54-
"send_now": true
50+
"is_cancelled": false
5551
},
5652
{
5753
"pid": "3",
5854
"priority": 0,
5955
"quantity": 2,
6056
"amount": 100,
61-
"exchange_rate": 1,
6257
"notes": [
6358
{
6459
"type": "staff_note",
@@ -77,15 +72,13 @@
7772
"library": {
7873
"$ref": "https://bib.rero.ch/api/libraries/1"
7974
},
80-
"is_cancelled": false,
81-
"send_now": true
75+
"is_cancelled": false
8276
},
8377
{
8478
"pid": "4",
8579
"priority": 0,
8680
"quantity": 5,
8781
"amount": 10,
88-
"exchange_rate": 1,
8982
"acq_account": {
9083
"$ref": "https://bib.rero.ch/api/acq_accounts/7"
9184
},
@@ -98,15 +91,13 @@
9891
"library": {
9992
"$ref": "https://bib.rero.ch/api/libraries/2"
10093
},
101-
"is_cancelled": false,
102-
"send_now": true
94+
"is_cancelled": false
10395
},
10496
{
10597
"pid": "5",
10698
"priority": 5,
10799
"quantity": 1,
108100
"amount": 100,
109-
"exchange_rate": 1,
110101
"notes": [
111102
{
112103
"type": "staff_note",
@@ -125,15 +116,13 @@
125116
"library": {
126117
"$ref": "https://bib.rero.ch/api/libraries/2"
127118
},
128-
"is_cancelled": false,
129-
"send_now": true
119+
"is_cancelled": false
130120
},
131121
{
132122
"pid": "6",
133123
"priority": 1,
134124
"quantity": 5,
135125
"amount": 7,
136-
"exchange_rate": 1,
137126
"acq_account": {
138127
"$ref": "https://bib.rero.ch/api/acq_accounts/14"
139128
},
@@ -146,15 +135,13 @@
146135
"library": {
147136
"$ref": "https://bib.rero.ch/api/libraries/3"
148137
},
149-
"is_cancelled": false,
150-
"send_now": true
138+
"is_cancelled": false
151139
},
152140
{
153141
"pid": "7",
154142
"priority": 1,
155143
"quantity": 15,
156144
"amount": 12,
157-
"exchange_rate": 1,
158145
"acq_account": {
159146
"$ref": "https://bib.rero.ch/api/acq_accounts/20"
160147
},
@@ -167,15 +154,13 @@
167154
"library": {
168155
"$ref": "https://bib.rero.ch/api/libraries/4"
169156
},
170-
"is_cancelled": false,
171-
"send_now": true
157+
"is_cancelled": false
172158
},
173159
{
174160
"pid": "8",
175161
"priority": 1,
176162
"quantity": 10,
177163
"amount": 20,
178-
"exchange_rate": 1,
179164
"acq_account": {
180165
"$ref": "https://bib.rero.ch/api/acq_accounts/4"
181166
},
@@ -188,15 +173,13 @@
188173
"library": {
189174
"$ref": "https://bib.rero.ch/api/libraries/1"
190175
},
191-
"is_cancelled": false,
192-
"send_now": true
176+
"is_cancelled": false
193177
},
194178
{
195179
"pid": "9",
196180
"priority": 0,
197181
"quantity": 3,
198182
"amount": 22,
199-
"exchange_rate": 1,
200183
"acq_account": {
201184
"$ref": "https://bib.rero.ch/api/acq_accounts/2"
202185
},
@@ -216,7 +199,6 @@
216199
"priority": 0,
217200
"quantity": 3,
218201
"amount": 25,
219-
"exchange_rate": 1,
220202
"notes": [
221203
{
222204
"type": "staff_note",
@@ -235,7 +217,6 @@
235217
"library": {
236218
"$ref": "https://bib.rero.ch/api/libraries/1"
237219
},
238-
"is_cancelled": false,
239-
"order_date": "2021-07-20"
220+
"is_cancelled": false
240221
}
241222
]

data/acq_orders.json

+6-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{
33
"pid": "1",
44
"reference": "AOSTE-CANT1-POL-1",
5-
"type": "monograph",
65
"currency": "EUR",
76
"notes": [
87
{
@@ -18,12 +17,12 @@
1817
},
1918
"organisation": {
2019
"$ref": "https://bib.rero.ch/api/organisations/1"
21-
}
20+
},
21+
"send_now": true
2222
},
2323
{
2424
"pid": "2",
2525
"reference": "AOSTE-CANT1-POL-2",
26-
"type": "monograph",
2726
"currency": "EUR",
2827
"notes": [
2928
{
@@ -39,12 +38,12 @@
3938
},
4039
"organisation": {
4140
"$ref": "https://bib.rero.ch/api/organisations/1"
42-
}
41+
},
42+
"send_now": true
4343
},
4444
{
4545
"pid": "3",
4646
"reference": "AOSTE-CANT2-POL-1",
47-
"type": "monograph",
4847
"currency": "EUR",
4948
"notes": [
5049
{
@@ -65,7 +64,6 @@
6564
{
6665
"pid": "4",
6766
"reference": "AOSTE-AVISE-POL-1",
68-
"type": "monograph",
6967
"currency": "EUR",
7068
"notes": [
7169
{
@@ -86,7 +84,6 @@
8684
{
8785
"pid": "5",
8886
"reference": "AOSTE-LYCEE-POL-1",
89-
"type": "monograph",
9087
"currency": "EUR",
9188
"notes": [
9289
{
@@ -107,7 +104,6 @@
107104
{
108105
"pid": "6",
109106
"reference": "AOSTE-CANT1-POL-6",
110-
"type": "monograph",
111107
"currency": "EUR",
112108
"library": {
113109
"$ref": "https://bib.rero.ch/api/libraries/1"
@@ -122,7 +118,6 @@
122118
{
123119
"pid": "7",
124120
"reference": "AOSTE-CANT1-POL-2021-1",
125-
"type": "monograph",
126121
"currency": "EUR",
127122
"notes": [
128123
{
@@ -138,6 +133,7 @@
138133
},
139134
"organisation": {
140135
"$ref": "https://bib.rero.ch/api/organisations/1"
141-
}
136+
},
137+
"send_now": true
142138
}
143139
]

data/acq_receipts.json

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"$ref": "https://bib.rero.ch/api/acq_orders/1"
66
},
77
"reference": "AOSTE-CANT1-POL-1",
8-
"exchange_rate": 1,
98
"notes": [
109
{
1110
"type": "staff_note",
@@ -25,7 +24,6 @@
2524
"$ref": "https://bib.rero.ch/api/acq_orders/7"
2625
},
2726
"reference": "AOSTE-CANT1-POL-2021-1",
28-
"exchange_rate": 1,
2927
"notes": [
3028
{
3129
"type": "staff_note",

rero_ils/modules/acquisition/acq_accounts/serializers/json.py

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
class AcqAccountJSONSerializer(ACQJSONSerializer):
2727
"""Serializer for RERO-ILS `AcqAccount` records as JSON."""
2828

29+
def _postprocess_search_hit(self, hit: dict) -> None:
30+
"""Post-process each hit of a search result."""
31+
hit["metadata"]["number_of_children"] = (
32+
AcqAccountsSearch()
33+
.filter("term", parent__pid=hit["metadata"]["pid"])
34+
.count()
35+
)
36+
super()._postprocess_search_hit(hit)
37+
2938
def preprocess_record(self, pid, record, links_factory=None, **kwargs):
3039
"""Prepare a record and persistent identifier for serialization."""
3140
# Add some ES stored keys into response

rero_ils/modules/acquisition/acq_order_lines/api.py

+1-21
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
"""API for manipulating Acquisition Order Line."""
2020

2121
from copy import deepcopy
22-
from datetime import datetime
2322
from functools import partial
2423

2524
from flask_babel import gettext as _
26-
from werkzeug.utils import cached_property
2725

2826
from rero_ils.modules.acquisition.api import AcquisitionIlsRecord
2927
from rero_ils.modules.api import IlsRecordsIndexer, IlsRecordsSearch
@@ -149,11 +147,6 @@ def order(self):
149147
"""Shortcut to the order of the order line."""
150148
return extracted_data_from_ref(self.get("acq_order"), data="record")
151149

152-
@property
153-
def order_date(self):
154-
"""Shortcut for acquisition order send date."""
155-
return self.get("order_date")
156-
157150
@property
158151
def is_cancelled(self):
159152
"""Shortcut for acquisition order is_cancelled falg."""
@@ -223,19 +216,6 @@ def unreceived_quantity(self):
223216
"""Get quantity of unreceived ordered_items for a line order."""
224217
return self.quantity - self.received_quantity
225218

226-
@cached_property
227-
def receipt_date(self):
228-
"""Get the first reception date for one item of this order line."""
229-
from rero_ils.modules.acquisition.acq_receipt_lines.api import (
230-
AcqReceiptLinesSearch,
231-
)
232-
233-
search = AcqReceiptLinesSearch().filter("term", acq_order_line__pid=self.pid)
234-
search.aggs.metric("min_receipt_date", "min", field="receipt_date")
235-
results = search.execute()
236-
epoch = results.aggregations.min_receipt_date.value / 1000
237-
return datetime.fromtimestamp(epoch)
238-
239219
@property
240220
def status(self):
241221
"""Calculate the order line status.
@@ -252,7 +232,7 @@ def status(self):
252232
return AcqOrderLineStatus.CANCELLED
253233
status = (
254234
AcqOrderLineStatus.ORDERED
255-
if self.order_date
235+
if self.order.get("order_date")
256236
else AcqOrderLineStatus.APPROVED
257237
)
258238

rero_ils/modules/acquisition/acq_order_lines/dumpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def dump(self, record, data):
4242
:param data: The initial dump data passed in by ``record.dumps()``.
4343
"""
4444
# Keep only some attributes from AcqOrderLine object initial dump.
45-
for attr in ["pid", "status", "order_date", "quantity"]:
45+
for attr in ["pid", "status", "quantity"]:
4646
if value := record.get(attr):
4747
data.update({attr: value})
4848

0 commit comments

Comments
 (0)