cancel
Showing results for 
Search instead for 
Did you mean: 

Supplier Invoice Tax using OData

former_member648217
Participant
0 Kudos

Hi Expert,


Can you help me where will i put tax code in my oData. It seems I can not find it in the oData Editor. Below are the field i need to populate in my request body.

regards,

wilson

former_member648217
Participant
0 Kudos

Hi Expert,

a little help please. been stock here for 3 days.

View Entire Topic
YatseaLi
Product and Topic Expert
Product and Topic Expert

Hi Wilson,

You could have helped yourself with step below:

1.Checking the OData configuration of supplier invoice to find out for what node it may be for the tax on item, guess it is not so difficult to spot on node ItemTaxCalculation as below, and its navigation from ItemTaxCalculation to Item, vice versa, if you look at the node Item, you should be able to find a navigation from Item to ItemTaxCalculation.

Alternatively, checking the SupplierInvoice object from the repository explorer of CAS, you can find out the relationship of nodes: SupplierInvoice(Root) > Item > ItemTaxCalculation

Unfortunately, the CountryCode and TaxationCode are not writable for Creation, only can be updated. Therefore, you need one post to SupplierInvoiceCollection for create supplier invoice with item, then patch to ItemTaxCalculationCollection for update the TaxationCode and CountryCode.

, as indicated, WithholdingTaxCode in not allowed for write in both create and update.

Alternatively, checking the metadata of the odata by search with keyword "tax". Then you should be able to find some relevant EntityType named "ItemTaxCalcuation"

2.Retrieving a supplier invoice with ODdata for reference. In this case, to see a supplier invoice with ItemTaxCalucation, please use the "expand" keyword

GET https://{{TenantHostname}}/sap/byd/odata/cust/v1/khsupplierinvoice/SupplierInvoiceCollection?$format...

The returned sample OData of supplier invoice

{
    "d": {
        "results": [
            {
                "__metadata": {
                    "uri": "https://my343094.sapbydesign.com/sap/byd/odata/cust/v1/khsupplierinvoice/SupplierInvoiceCollection('0000000000011DDFBEF224521117667A')",
                    "type": "cust.SupplierInvoice"
                },
                "ObjectID": "0000000000011DDFBEF224521117667A",
                "ID": "131",
                "UUID": "00000000-0001-1DDF-BEF2-24521117667A",
                "TypeCode": "004",
                "TypeCodeText": "Invoice",
                "CancellationDocumentIndicator": false,
                "DataOriginTypeCode": "1",
                "DataOriginTypeCodeText": "Manual data entry",
                "ItemsGrossAmountIndicator": false,
                "InvoiceDescription": "",
                "CreationDateTime": "/Date(1291018884000)/",
                ...
                "Item": [
                    {
                        "__metadata": {
                            "uri": "https://my343094.sapbydesign.com/sap/byd/odata/cust/v1/khsupplierinvoice/ItemCollection('0000000000011DDFBEF22752180F267A')",
                            "type": "cust.Item"
                        },
                        "ObjectID": "0000000000011DDFBEF22752180F267A",
                        "ParentObjectID": "0000000000011DDFBEF224521117667A",
                        "ID": "1",
                        "UUID": "00000000-0001-1DDF-BEF2-2752180F267A",
                        "TypeCode": "002",
                        "TypeCodeText": "Invoice Item",
                        "ProductID": "S200101",
                        "ProductTypeCode": "2",
                        "ProductTypeCodeText": "Service",
                        "ProductCategoryInternalID": "130",
                        "Description": "Senior Consultancy",
                        "DirectMaterialIndicator": false,
                        "Quantity": "750.00000000000000",
                        "QuantityUnitCode": "HUR",
                        "QuantityUnitCodeText": "Hour(s)",
                        "NetUnitPriceAmount": "150.000000",
                        "NetUnitPriceCurrencyCode": "USD",
                        "NetUnitPriceBaseQuantity": "1.00000000000000",
                        "NetUnitPriceBaseUnitCode": "HUR",
                        ...
                        "ItemTaxCalculation": {
                            "__metadata": {
                                "uri": "https://my343094.sapbydesign.com/sap/byd/odata/cust/v1/khsupplierinvoice/ItemTaxCalculationCollection('0000000000011DDFBEF22752180F267A')",
                                "type": "cust.ItemTaxCalculation"
                            },
                            "ObjectID": "0000000000011DDFBEF22752180F267A",
                            "ParentObjectID": "0000000000011DDFBEF224521117667A",
                            "CountryCode": "US",
                            "CountryCodeText": "United States",
                            "TaxJurisdictionCode": "",
                            "TaxJurisdictionCodeText": "",
                            "TaxationCode": "2",
                            "TaxationCodeText": "",
                            "WithholdingTaxCode": "",
                            "WithholdingTaxCodeText": "",
                       }
                  }
               ]
            }
        ]
    }
}

3.Ok, Here list the steps I have tried to create a supplier invoice with OData

1).Post a supplier invoices with payload below

However, I have encounter an very weir error 404 , "The server has not found any resource matching the Data Services Request URI", which I can get the supplier inovice with the same endpoint. I have to stop my test here.It might be related to my tenant.

It worths a go by yourself. You may need adjust the sample payload below per tenant.

If success, please note down the ObjectID and ParentID of node ItemTaxCalculation in the response, then go to step 3) to patch ItemTaxCalcuation.

POST https://{{TenantHostname}}/sap/byd/odata/cust/v1/khsupplierinvoice/SupplierInvoiceCollection

{
    "DataOriginTypeCode": "1",
    "InvoiceDescription": "Created via OData",
    "SellerParty": {
        "PartyID": "S200100"
    },
    "Item": [{
        "ProductID": "P100202",
        "Quantity": "1.00",
        "QuantityUnitCode": "EA",
        "NetUnitPriceAmount": "99.00"
    }]
}

2).If the response of POST supplier invoice only return the root node, then you will need a GET to retrieve node ItemTaxCalculation.

GET https:///sap/byd/odata/cust/v1/khsupplierinvoice/SupplierInvoiceCollection('***ObjectID*****')?$format=json&$expand=Item/ItemTaxCalculation

3).Update TaxCode and Country Code on Item

For each line of Item, please update its ItemTaxCalculation as below

PATCH https://my343094.sapbydesign.com/sap/byd/odata/cust/v1/khsupplierinvoice/ItemTaxCalculationCollection('**ObjectID of ItemTaxCalc*')
{
     "CountryCode": "US",
     "TaxationCode": "2"
}

If there is no ItemTaxCalcuation node on Item in step 2), then you can post to create one empty, then patch as above

PATCH https://my343094.sapbydesign.com/sap/byd/odata/cust/v1/khsupplierinvoice/ItemTaxCalculationCollectio...
{
     "ParentObjectID": "***ObjectID of Item node instance****"
}

Last but no list, have you also tried my last suggestion to manully modify the wsdl of ManageSupplierInvoice?

Kind Regards, Yatsea

x27lu
Explorer
0 Kudos

Hi Yatsea, I just came across my thread on my research for sending tax code. You mentioned that TaxationCode is not writable for creation. I edited the OData XML to allow it to be writable for creation, and I see the checkbox ticked for Create in OData Services, but it still won't let me do it. Is this a system limitation overriding the OData configurations?