dyne / reflow-os

Base scripts to run Reflow OS
7 stars 2 forks source link

accountingQuantity and onhandQuantity are `null` on raise economicEvent #22

Open sbocconi opened 2 years ago

sbocconi commented 2 years ago
mutation($event:EconomicEventCreateParams!, $newInventoriedResource:EconomicResourceCreateParams) {
                createEconomicEvent(event:$event, newInventoriedResource:$newInventoriedResource) {
                    economicEvent {
                        id
                        provider {
                            id
                            name
                            note
                        }
                        resourceQuantity {
                            hasNumericalValue
                            hasUnit {
                                label
                                symbol
                            }
                        }
                        toResourceInventoriedAs {
                            id
                            name
                            onhandQuantity {
                                hasNumericalValue
                                hasUnit {
                                    label
                                    symbol
                                }
                            }
                            accountingQuantity {
                                hasNumericalValue
                                hasUnit {
                                    label
                                    symbol
                                }
                            }
                        }
                    }
            }
}

with variables;

{
        "event": {
            "note": "update event",
            "action": "raise",
            "provider": "01FP094V38QGMK08N6VEM8HREN", 
            "receiver": "01FP094V38QGMK08N6VEM8HREN", 
            "resourceInventoriedAs": "http://cleanlease.nl/zs/6663",
            "resourceQuantity": {
              "hasUnit": "01FRTRG75V5WDG8GQ8A81MJ8D5", 
              "hasNumericalValue": 1 
            }
        },
        "newInventoriedResource": { 
            "name": "Gown"
        }
    }

I get the following output:

{
  "data": {
    "createEconomicEvent": {
      "economicEvent": {
        "id": "01FRTSNWDTCH7AKPYH2RPW6PQH",
        "provider": {
          "id": "01FP094V38QGMK08N6VEM8HREN",
          "name": "AGENT_OLVG",
          "note": "Simulation Agent"
        },
        "resourceQuantity": {
          "hasNumericalValue": 1,
          "hasUnit": {
            "label": "u_piece",
            "symbol": "om2:one"
          }
        },
        "toResourceInventoriedAs": {
          "accountingQuantity": null,
          "id": "01FRTSNWCSHJVPW5R026GTMXN1",
          "name": "Gown",
          "onhandQuantity": null
        }
      }
    }
  }
}

Is it normal that accountingQuantity and onhandQuantity are null?

fosterlynn commented 2 years ago

Is it normal that accountingQuantity and onhandQuantity are null?

No, at least accountingQuantity on a resource should be a quantity, even if it is zero something. But if I am following correctly, you are using raise with toResourceInventoriedAs? If so, the problem could be that raise (and most event actions) assume resourceInventoriedAs. Just a guess.

sbocconi commented 2 years ago

Hi @fosterlynn, thank you for your reply.

I use toResourceInventoriedAs because resourceInventoriedAs returns null (or maybe I am using it wrongly).

This call

mutation($event:EconomicEventCreateParams!, $newInventoriedResource:EconomicResourceCreateParams) {
                createEconomicEvent(event:$event, newInventoriedResource:$newInventoriedResource) {
                    economicEvent {
                        id
                        provider {
                            id
                            name
                            note
                        }
                        resourceQuantity {
                            hasNumericalValue
                            hasUnit {
                                label
                                symbol
                            }
                        }
                        toResourceInventoriedAs {
                            id
                            name
                            onhandQuantity {
                                hasNumericalValue
                                hasUnit {
                                    label
                                    symbol
                                }
                            }
                            accountingQuantity {
                                hasNumericalValue
                                hasUnit {
                                    label
                                    symbol
                                }
                            }
                        }
                        resourceInventoriedAs {
                            id
                            name
                            onhandQuantity {
                                hasNumericalValue
                                hasUnit {
                                    label
                                    symbol
                                }
                            }
                            accountingQuantity {
                                hasNumericalValue
                                hasUnit {
                                    label
                                    symbol
                                }
                            }
                        }
                    }
            }
}

with variables:

{
        "event": {
            "note": "update event",
            "action": "raise",
            "provider": "01FP094V38QGMK08N6VEM8HREN", 
            "receiver": "01FP094V38QGMK08N6VEM8HREN", 
            "resourceInventoriedAs": "http://cleanlease.nl/zs/6663",
            "resourceQuantity": {
              "hasUnit": "01FRTRG75V5WDG8GQ8A81MJ8D5", 
              "hasNumericalValue": 1 
            }
        },
        "newInventoriedResource": { 
            "name": "Gown"
        }
    }

returns the following:

{
  "data": {
    "createEconomicEvent": {
      "economicEvent": {
        "id": "01FS6SP3TCNC9VWXZJJTB3HV8E",
        "provider": {
          "id": "01FP094V38QGMK08N6VEM8HREN",
          "name": "AGENT_OLVG",
          "note": "Simulation Agent"
        },
        "resourceInventoriedAs": null,
        "resourceQuantity": {
          "hasNumericalValue": 1,
          "hasUnit": {
            "label": "u_piece",
            "symbol": "om2:one"
          }
        },
        "toResourceInventoriedAs": {
          "accountingQuantity": null,
          "id": "01FS6SP3SC1QFS3GK7GMG3Q9P5",
          "name": "Gown",
          "onhandQuantity": null
        }
      }
    }
  }
}

so resourceInventoriedAs is just null. I guess this is not the expected behaviour.