|
20 | 20 | CURRENCY_EUROS = 4 |
21 | 21 |
|
22 | 22 | # we need to use _preload_content=False here so we can access the metadata properly |
23 | | -response = items_client.read_items(cat=1, limit=9999, _preload_content=False) |
| 23 | +response = items_client.read_items(cat=RESOURCE_CATEGORY_ID, limit=9999, _preload_content=False) |
24 | 24 | items = json.loads(response.data.decode('utf-8')) |
25 | 25 | for item in items: |
26 | 26 | metadata = item.get('metadata', None) |
|
31 | 31 | meta = json.loads(metadata) |
32 | 32 | extra_fields = meta.get('extra_fields', None) |
33 | 33 | if extra_fields is not None: |
34 | | - proc_pack_qty = extra_fields.get("Quantity", 1).get("value") |
35 | | - proc_price_notax = extra_fields.get("Price", 0.00).get("value") |
| 34 | + proc_pack_qty = extra_fields.get("Quantity", {"value": "1"}).get("value") |
| 35 | + proc_price_notax = extra_fields.get("Price", {"value": "0.00"}).get("value") |
| 36 | + # ensure we have a dot separator and a string |
| 37 | + proc_price_notax = str(proc_price_notax).replace(",",".") |
| 38 | + # ensure empty value is 0.00 |
| 39 | + if proc_price_notax == "": |
| 40 | + proc_price_notax = "0.00" |
36 | 41 | proc_price_tax = float(proc_price_notax) * 1.2 |
37 | 42 | # no patch the item with these values |
38 | 43 | print(f"INFO: Patching item with id {item.get('id')}") |
|
0 commit comments