My Products
Help
filip-yabieenterprise
CONTRIBUTOR *

Problem reading TaxAndAccountingGroups

by filip-yabieenterprise

Hi!

 

Since about a week ago, we have had problems reading out some TaxAndAccountingGroup information from the GraphQL api.

 

The reason we found out about this problem was when a join to include TaxAndAccountingGroup returned null when trying to list a product.

 

Example Query:

query GetTaxAndAccountGroups($cid: Int!) {
	useCompany(no : $cid) {  
		taxAndAccountingGroup {
      totalCount
      items {
        joindown_TaxAndAccountingInformation_via_TaxAndAccGroup {
          totalCount
          items {
            joinup_TaxCode_via_TaxCodeSales {
              joinup_Vat {
                rate
              }
            }
          }
        }
      }
    }
	}
}

Response we get:

{
  "data": {
    "useCompany": {
      "taxAndAccountingGroup": {
        "totalCount": 15,
        "items": null
      }
    }
  },
  "extensions": {
    "vbnxt-trace-id": "000000000000000050a3746391f40f0b"
  }
}

 

The expected response we would have wanted is to be able to read out the vat rates of all the TaxAndAccountingGroups.

 

We tried adding description to the query but it didn't help, it is still acting strange.

 

Example 2:

query GetTaxAndAccountGroups($cid: Int!) {
	useCompany(no : $cid) {  
		taxAndAccountingGroup {
      totalCount
      items {
        description
        joindown_TaxAndAccountingInformation_via_TaxAndAccGroup {
          totalCount
          items {
            description
            joinup_TaxCode_via_TaxCodeSales {
              joinup_Vat {
                rate
              }
            }
          }
        }
      }
    }
	}
}

Response 2:

{
  "data": {
    "useCompany": {
      "taxAndAccountingGroup": {
        "totalCount": 15,
        "items": [
          {
            "description": "RÃ¥varer over lager",
            "joindown_TaxAndAccountingInformation_via_TaxAndAccGroup": {
              "totalCount": 20,
              "items": [
                {
                  "description": "RÃ¥varer over lager",
                  "joinup_TaxCode_via_TaxCodeSales": null
                },
                {
                  "description": "RÃ¥varer over lager",
                  "joinup_TaxCode_via_TaxCodeSales": null
                }
              ]
            }
          },
//        ... More items returned but they all look the same as the first, with no vat rate
        ]
      }
    }
  },
  "extensions": {
    "vbnxt-trace-id": "0000000000000000350bd2bd24c7cf5c"
  }
}

 

If this is something we have done wrong, then please let me know. However, since this used to work, I feel like it's a bug?

 

2 REPLIES 2

by Marius Bancila

This is due to a change we did for performance improvement in GraphQL. Previously, we would be selecting entire rows, no matter now many fields you wanted from a table. Now, we are only selecting exactly what you ask for. However, if you ask for nothing, you get nothing. Therefore, you cannot have join-only fields in the schema, such as here:

taxAndAccountingGroup {
      items {
        joindown_TaxAndAccountingInformation_via_TaxAndAccGroup {
          items {
            joinup_TaxCode_via_TaxCodeSales {
              joinup_Vat {
                rate
              }
            }
          }
        }

As you figured it out, it works, if you add at least one field. But you did that do that with joinup_TaxCode_via_TaxCodeSales.

Here is a query that works:


query GetTaxAndAccountGroups($cid: Int!) {
  useCompany(no : $cid) {  
    taxAndAccountingGroup {
      totalCount
      items {
        taxAndAccountingGroupNo
        description
        
        joindown_TaxAndAccountingInformation_via_TaxAndAccGroup {          
          totalCount
          items {
            taxAndAccountingGroup
            description
            joinup_TaxCode_via_TaxCodeSales {
              taxCode
              joinup_Vat {
                rate
              }
            }
          }
        }
      }
    }
  }
} 

Result:

{
  "data": {
    "useCompany": {
      "taxAndAccountingInformation": {
        "totalCount": 8,
        "items": [
          {
            "taxAndAccountingGroup": 1,
            "description": "Avgiftspliktig høy sats",
            "joinup_TaxCode_via_TaxCodeSales": {
              "taxCode": 3,
              "description": "Utgående MVA - høy sats",
              "joinup_Vat": {
                "rate": 25
              }
            }
          },
          {
            "taxAndAccountingGroup": 2,
            "description": "Avgiftsfritt",
            "joinup_TaxCode_via_TaxCodeSales": {
              "taxCode": 4,
              "description": "Avgiftsfritt salg innland",
              "joinup_Vat": null
            }
          },

by Marius Bancila

Thank you for reporting. I am looking into it.