Sage / SData-2.0

Contains documents pertaining to the SData 2.0 developments
33 stars 10 forks source link

Service Operations #72

Closed kieronmoran closed 6 years ago

kieronmoran commented 7 years ago

Hi,

Does anyone have a working example consuming a Service Operation? I am specifically interested in the computeSimplePrice Operation.

Thanks,

Kieron

darroncockram commented 7 years ago

I'm not aware of any Sdata adapter that currently implements a service operation called computeSimplePrice. The Sage 50 Accounts adapter has a service operation called ComputePrice so maybe this is what you are referring to? The Sdata docs do mention it as an example http://sage.github.io/SData-2.0/pages/core/1107/ but it is just an example. That page does include an example payload but just to stress again that is a fictional service operation and contract so isn't a real world working example.

kieronmoran commented 7 years ago

Hi Darren,

Thanks for the VERY quick reply :-)

Looking at the documentation, I have been trying the example on this page http://sage.github.io/SData-2.0/pages/core/1102/ and here, http://sage.github.io/SData-2.0/pages/core/1104/.

Do you have a working example of the computePrice operation?

Everything I have tried has failed :-(

Kieron

kieronmoran commented 7 years ago

This is what I have so far:

URL: http://localhost:5493/sdata/accounts50/GCRM/{C4C463BE-B098-4A7D-A23B-D1A92B8DCB59}/computePrice

Payload:

<?xml version="1.0" encoding="utf-8"?>
<entry  
    xmlns="http://schemas.sage.com/crmErp/2008" 
    xmlns:atom="http://www.w3.org/2005/Atom" 
    xmlns:sdata="http://schemas.sage.com/sdata/2008/1" 
>
  <id>http://localhost:5493/sdata/accounts50/GCRM/{C4C463BE-B098-4A7D-A23B-D1A92B8DCB59}/$service/computePrice</id>
  <sdata:payload>
    <computePrice>
      <request>
        <productID>BOARD001</productID>
        <customerID>A1D001</customerID>
        <quantity>5.0</quantity>
      </request>
    </computePrice>
  </sdata:payload>
</entry>

Trying with the above I get: POST operation failed - Invalid Name

darroncockram commented 7 years ago

Something like this should work. Just make sure to replace the UUIDs with valid ones from your dataset:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns="http://www.w3.org/2005/Atom" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:sme="http://schemas.sage.com/sdata/sme/2007" xmlns:sdatasync="http://schemas.sage.com/sdata/sync/2008/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdata="http://schemas.sage.com/sdata/2008/1" xmlns:http="http://schemas.sage.com/sdata/http/2008/1">
  <author />
  <sdata:payload>
    <computePrice xmlns="http://schemas.sage.com/crmErp/2008">
      <request>
        <tradingAccount sdata:url="http://localhost:5493/sdata/Accounts50/GCRM/{C4C463BE-B098-4A7D-A23B-D1A92B8DCB59}/tradingAccountCustomer(be33197f-03c1-46e3-b789-5e078562b0c0)?format=atomentry" sdata:uuid="be33197f-03c1-46e3-b789-5e078562b0c0">
        </tradingAccount>
         <pricingDocumentLines>
          <pricingDocumentLine>
            <uuid xsi:nil="true" />
            <commodity sdata:url="http://localhost:5493/sdata/Accounts50/GCRM/{C4C463BE-B098-4A7D-A23B-D1A92B8DCB59}/commodities(ff991dcf-bd25-4d20-95db-813cc8dc86b9)?format=atomentry" sdata:uuid="ff991dcf-bd25-4d20-95db-813cc8dc86b9">
            </commodity>
            <quantity>10.00</quantity>
            </pricingDocumentLine>
        </pricingDocumentLines>
      </request>
      <response xsi:nil="true" />
    </computePrice>
  </sdata:payload>
</entry>

Hope that helps.

darroncockram commented 7 years ago

And just in case it's any value here's the code I used that resulted in that request (I've edited the above payload example to remove extraneous data).

computePriceFeedEntry priceCheck = new computePriceFeedEntry();
priceCheck.request = new computePriceRequestFeedEntry();

// Find the customer to check  prices for
tradingAccountFeedEntry account = GetCustomer();
if (account == null)
{
    Console.WriteLine("Unable to find a customer record");
    return;
}

// Lookup a commodity to check the price for
commodityFeedEntry commodity = GetCommodity();
if (commodity == null)
{
    Console.WriteLine("Unable to find a commodity record");
    return;
}

// Set up the check price request
priceCheck.request.tradingAccount = account;

priceCheck.request.pricingDocumentLines = new pricingDocumentLineFeed();

pricingDocumentLineFeedEntry line = new pricingDocumentLineFeedEntry();
line.quantity = 10;
line.commodity = commodity;
priceCheck.request.pricingDocumentLines.Entries.Add(line);

//Further lines may be added as necessary

Sage.Common.Syndication.SDataUri computePriceUri = new Sage.Common.Syndication.SDataUri();
computePriceUri.BuildLocalPath("Accounts50", "GCRM", "-", "computePrice");
computePriceUri.ServiceMethod = "ComputePrice";
SDataRequest request = new SDataRequest(computePriceUri.Uri, (Sage.Common.Syndication.FeedEntry)priceCheck, RequestVerb.POST);
request.Username = "MANAGER";
request.Password = "";

computePriceFeedEntry computePriceResult = new computePriceFeedEntry();
request.RequestFeedEntry<computePriceFeedEntry>(computePriceResult);

// Issue the request
if (request.IsStatusValidForVerb)
{
    foreach (pricingDocumentLineFeedEntry item in computePriceResult.response.pricingDocumentLines.Entries)
    {
        Console.WriteLine("Computed price for item {0} is {1}", item.commodity.reference, item.initialPrice);
    }
}
else
{
    // There was a problem
    Console.WriteLine("Request failed. Response was {0}", request.HttpStatusCode.ToString());
    if (request.Diagnoses != null)
    {
        foreach (Diagnosis diagnosis in request.Diagnoses)
            Console.WriteLine(diagnosis.Message);
    }
}
kieronmoran commented 7 years ago

Your code above helped me massively.

For future reference the documentation led me completely the wrong way. Having implemented it using your code above as a starting point, the POST Url is built up as http://localhost:5493/sdata/Accounts50/GCRM/-/computePrice/$service/ComputePrice whereas the github documentation is completely different.

Thanks Darren!!!

kieronmoran commented 7 years ago

Hi Darren,

Sorry to reopen this issue but I think I need come clarification on the ComputePrice service operation.

I have run some tests and it seems to return discounts associated with supplier accounts but NOT for Customers.

Would you be able to confirm that this operation should calculate prices based on Price List and Discounts applied for Customers?

Many thanks in advance,

Kieron

darroncockram commented 7 years ago

The computePrice service method should work for both customers and suppliers. It calls the same underlying code as the Sage 50 Accounts UI does so the whole range of discounts should be available using it.

kieronmoran commented 7 years ago

Hi Darren,

Thanks for the quick response.

I have tried various different sData calls but do not seem to be able to get a discounted price.

The url I am posting to is http://localhost:5493/sdata/Accounts50/GCRM/-/computePrice/$service/ComputePrice?exclude=request&include=computePrice&select=response/netTotal,response/grossTotal,response/netTotal,response/taxTotal,response/discountTotal,response/discountType,response/discountAmount,response/discountPercent&_includeContent=false

The Payload is `<?xml version="1.0" encoding="utf-8"?> <entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns="http://www.w3.org/2005/Atom" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:sme="http://schemas.sage.com/sdata/sme/2007" xmlns:sdatasync="http://schemas.sage.com/sdata/sync/2008/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdata="http://schemas.sage.com/sdata/2008/1" xmlns:http="http://schemas.sage.com/sdata/http/2008/1">

100.00 ` and the response is ` 2017-05-31T23:09:59.178+01:00 2017-05-31T23:09:59.178+01:00 201 Percent 0.00 0.00 4900.00 0.00 980.00 5880.00 ` I am testing with the stationary & Mart Demo Company. Any ideas where I am going wrong? Thanks in advance, Kieron
darroncockram commented 7 years ago

That response does not look right tom me a there are no pricingDocumentLines in it. Here's a working example using the Stationary & Computer Mart demo data. I've included the full tradingAccount and commodity details in the request which is not necessary (it is only the UUID that matters) but this way you can see the exact records I am testing with and you should be able to replicate this using the UUID's of the equivalent records in your copy of the demo data:


<?xml version="1.0" encoding="utf-8"?>
<entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns="http://www.w3.org/2005/Atom" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:sme="http://schemas.sage.com/sdata/sme/2007" xmlns:sdatasync="http://schemas.sage.com/sdata/sync/2008/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdata="http://schemas.sage.com/sdata/2008/1" xmlns:http="http://schemas.sage.com/sdata/http/2008/1">
  <author />
  <sdata:payload>
    <computePrice xmlns="http://schemas.sage.com/crmErp/2008">
      <request>
        <tradingAccount sdata:url="http://localhost:5493/sdata/Accounts50/GCRM/{C4C463BE-B098-4A7D-A23B-D1A92B8DCB59}/tradingAccountCustomer(be33197f-03c1-46e3-b789-5e078562b0c0)?format=atomentry" sdata:uuid="be33197f-03c1-46e3-b789-5e078562b0c0">
          <active>true</active>
          <customerSupplierFlag>Customer</customerSupplierFlag>
          <companyPersonFlag>Company</companyPersonFlag>
          <invoiceTradingAccount xsi:nil="true" />
          <openedDate>2013-01-02</openedDate>
          <reference>A1D001</reference>
          <reference2 xsi:nil="true" />
          <status>Open</status>
          <name>A1 Design ServicesX9</name>
          <shortName xsi:nil="true" />
          <type>Unknown</type>
          <registeredAddress xsi:nil="true" />
          <postalAddresses xsi:nil="true" />
          <shippingAddresses xsi:nil="true" />
          <billingAddresses xsi:nil="true" />
          <phones xsi:nil="true" />
          <emails xsi:nil="true" />
          <website>www.sage.co.uk</website>
          <contacts xsi:nil="true" />
          <deliveryContact xsi:nil="true" />
          <salesPersons xsi:nil="true" />
          <deliveryMethod xsi:nil="true" />
          <deliveryRule>true</deliveryRule>
          <currency>GBP</currency>
          <taxCode xsi:nil="true" />
          <taxReference>GB238 3839 38</taxReference>
          <taxationCountry>GB</taxationCountry>
          <useTaxInclusivePrices xsi:nil="true" />
          <financeBalance>12.98</financeBalance>
          <financeLimit>1000.00</financeLimit>
          <financeBalanceDate xsi:nil="true" />
          <financeStatusFlag>false</financeStatusFlag>
          <financeStatusText>Open</financeStatusText>
          <settlementDiscountType>Percent</settlementDiscountType>
          <settlementDiscountAmount xsi:nil="true" />
          <settlementDiscountPercent>2.50</settlementDiscountPercent>
          <settlementDiscountTerms>15</settlementDiscountTerms>
          <settlementDiscountTermsCommencement xsi:nil="true" />
          <settlementDiscountIncludedInTotal>true</settlementDiscountIncludedInTotal>
          <paymentTerms>30</paymentTerms>
          <paymentTermsCommencement xsi:nil="true" />
          <orderDiscountType xsi:nil="true" />
          <orderDiscountAmount xsi:nil="true" />
          <orderDiscountPercent xsi:nil="true" />
          <orderText1 xsi:nil="true" />
          <orderText2 xsi:nil="true" />
          <orderLineDiscountType xsi:nil="true" />
          <orderLineDiscountAmount xsi:nil="true" />
          <orderLineDiscountPercent>0.00</orderLineDiscountPercent>
          <orderLineText1 xsi:nil="true" />
          <orderLineText2 xsi:nil="true" />
          <invoiceDiscountType xsi:nil="true" />
          <invoiceDiscountAmount xsi:nil="true" />
          <invoiceDiscountPercent>0.00</invoiceDiscountPercent>
          <invoiceText1 xsi:nil="true" />
          <invoiceText2 xsi:nil="true" />
          <bankAccounts xsi:nil="true" />
          <tenderType xsi:nil="true" />
          <defaultFulfillmentLocation xsi:nil="true" />
          <pricelists xsi:nil="true" />
          <pricingOverride xsi:nil="true" />
          <accountingType xsi:nil="true" />
          <financialAccounts xsi:nil="true" />
          <primacyIndicator>true</primacyIndicator>
          <opportunities xsi:nil="true" />
          <salesQuotations xsi:nil="true" />
          <salesOrders xsi:nil="true" />
          <salesOrderDeliveries xsi:nil="true" />
          <salesInvoices xsi:nil="true" />
          <salesCredits xsi:nil="true" />
          <purchaseOrders xsi:nil="true" />
          <purchaseOrderDeliveries xsi:nil="true" />
          <receipts xsi:nil="true" />
          <interactions xsi:nil="true" />
          <projects xsi:nil="true" />
        </tradingAccount>
        <pricingDocumentID xsi:nil="true" />
        <pricingDocumentType xsi:nil="true" />
        <pricingDocumentDate xsi:nil="true" />
        <pricingDocumentStatus xsi:nil="true" />
        <pricingDocumentCurrency xsi:nil="true" />
        <pricingList xsi:nil="true" />
        <pricingShippingAddress xsi:nil="true" />
        <carrierTradingAccount xsi:nil="true" />
        <carrierNetPrice xsi:nil="true" />
        <carrierTaxPrice xsi:nil="true" />
        <carrierGrossPrice xsi:nil="true" />
        <carrierReference xsi:nil="true" />
        <salesPerson xsi:nil="true" />
        <buyer xsi:nil="true" />
        <taxCode xsi:nil="true" />
        <doNotChangePrice xsi:nil="true" />
        <discountType xsi:nil="true" />
        <discountAmount xsi:nil="true" />
        <discountPercent xsi:nil="true" />
        <settlementDiscountType xsi:nil="true" />
        <settlementDiscountPercent xsi:nil="true" />
        <additionalDiscount1Type xsi:nil="true" />
        <additionalDiscount1Amount xsi:nil="true" />
        <additionalDiscount1Percent xsi:nil="true" />
        <additionalDiscount2Type xsi:nil="true" />
        <additionalDiscount2Amount xsi:nil="true" />
        <additionalDiscount2Percent xsi:nil="true" />
        <netTotal xsi:nil="true" />
        <discountTotal xsi:nil="true" />
        <taxTotal xsi:nil="true" />
        <grossTotal xsi:nil="true" />
        <costTotal xsi:nil="true" />
        <profitTotal xsi:nil="true" />
        <additionalText xsi:nil="true" />
        <pricingDocumentLines>
          <pricingDocumentLine>
            <uuid xsi:nil="true" />
            <commodity sdata:url="http://localhost:5493/sdata/Accounts50/GCRM/{C4C463BE-B098-4A7D-A23B-D1A92B8DCB59}/commodities(ff991dcf-bd25-4d20-95db-813cc8dc86b9)?format=atomentry" sdata:uuid="ff991dcf-bd25-4d20-95db-813cc8dc86b9">
              <active>true</active>
              <commodityGroup xsi:nil="true" />
              <commodityIdentifierType>Total</commodityIdentifierType>
              <commodityIdentifiers xsi:nil="true" />
              <reference>BOARD001</reference>
              <reference2 xsi:nil="true" />
              <status xsi:nil="true" />
              <name>Whiteboard - Drywipe (900 x 1200)</name>
              <shortName xsi:nil="true" />
              <description xsi:nil="true" />
              <alternativeDescription1>Whiteboard - Drywipe (900 x 1200)</alternativeDescription1>
              <alternativeDescription2 xsi:nil="true" />
              <type>Presentation Supplies</type>
              <unitOfMeasure xsi:nil="true" />
              <buyingAllowedFlag>true</buyingAllowedFlag>
              <buyingUnitOfMeasure xsi:nil="true" />
              <buyingUnitOfMeasureNumber xsi:nil="true" />
              <sellingAllowedFlag>true</sellingAllowedFlag>
              <sellingUnitOfMeasure xsi:nil="true" />
              <sellingUnitOfMeasureNumber xsi:nil="true" />
              <packingUnitOfMeasure xsi:nil="true" />
              <packingUnitOfMeasureNumber xsi:nil="true" />
              <catalogueNumber>U143</catalogueNumber>
              <supplierTradingAccount xsi:nil="true" />
              <supplierReference>UNI001</supplierReference>
              <manufacturerCompany />
              <manufacturerReference xsi:nil="true" />
              <material xsi:nil="true" />
              <countryOfOrigin xsi:nil="true" />
              <weight>0.00</weight>
              <weightKg xsi:nil="true" />
              <classification />
              <taxCodes xsi:nil="true" />
              <financialAccounts xsi:nil="true" />
              <dutyApplicableFlag xsi:nil="true" />
              <dutyRate xsi:nil="true" />
              <tradeIdentificationNumber xsi:nil="true" />
              <replacement xsi:nil="true" />
              <replacementDate xsi:nil="true" />
              <leadTime xsi:nil="true" />
              <cost>25.00</cost>
              <associatedChildCommodities xsi:nil="true" />
              <associatedParentCommodity xsi:nil="true" />
              <version xsi:nil="true" />
              <commissionType xsi:nil="true" />
              <commissionAmount xsi:nil="true" />
              <commissionPercent xsi:nil="true" />
              <interactions xsi:nil="true" />
              <opportunities xsi:nil="true" />
              <salesQuotationLines xsi:nil="true" />
              <salesOrderLines xsi:nil="true" />
              <salesOrderDeliveryLines xsi:nil="true" />
              <salesInvoiceLines xsi:nil="true" />
              <salesCreditLines xsi:nil="true" />
              <purchaseOrderLines xsi:nil="true" />
              <purchaseOrderDeliveryLines xsi:nil="true" />
              <pricelists xsi:nil="true" />
              <prices xsi:nil="true" />
              <inStock>2.00</inStock>
              <allocated>57.00</allocated>
              <freeStock>-55.00</freeStock>
              <onOrder>0.00</onOrder>
              <salesPrice>20.00</salesPrice>
            </commodity>
            <commodityVariant xsi:nil="true" />
            <commodityDimension xsi:nil="true" />
            <quantity>10.00</quantity>
            <unitOfMeasure xsi:nil="true" />
            <pricingDocumentLineType xsi:nil="true" />
            <fulfillmentLocation xsi:nil="true" />
            <description xsi:nil="true" />
            <enteredPrice xsi:nil="true" />
            <initialPrice xsi:nil="true" />
            <actualPrice xsi:nil="true" />
            <discountType xsi:nil="true" />
            <discountAmount xsi:nil="true" />
            <discountPercent xsi:nil="true" />
            <subtotalDiscountType xsi:nil="true" />
            <subtotalDiscountAmount xsi:nil="true" />
            <subtotalDiscountPercent xsi:nil="true" />
            <netTotal xsi:nil="true" />
            <chargesTotal xsi:nil="true" />
            <discountTotal xsi:nil="true" />
            <taxCode xsi:nil="true" />
            <priceTax xsi:nil="true" />
            <taxTotal xsi:nil="true" />
            <grossTotal xsi:nil="true" />
            <costTotal xsi:nil="true" />
            <profitTotal xsi:nil="true" />
            <reference xsi:nil="true" />
            <priceChangeStatus xsi:nil="true" />
            <shortText xsi:nil="true" />
            <longText xsi:nil="true" />
          </pricingDocumentLine>
        </pricingDocumentLines>
      </request>
      <response xsi:nil="true" />
    </computePrice>
  </sdata:payload>
</entry>

And here's the response:

```xml
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns="http://www.w3.org/2005/Atom" xmlns:sdatasync="http://schemas.sage.com/sdata/sync/2008/1" xmlns:sdata="http://schemas.sage.com/sdata/2008/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:sme="http://schemas.sage.com/sdata/sme/2007" xmlns:http="http://schemas.sage.com/sdata/http/2008/1" xmlns:sc="http://schemas.sage.com/sc/2009" xmlns:crm="http://schemas.sage.com/crmErp/2008">
  <author />
  <content type="html"><![CDATA[<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body style="font-family: Verdana;">
    <table cellpadding="4" cellspacing="0" style="background-color: white; font-family: Arial;border: 1px solid darkgray;font-size: x-small;">
      <tr style="background-color: lavender;">
        <td nowrap style="font-weight: bold;text-align: right;vertical-align: top;">Request</td>
        <td style=";vertical-align: top;" nowrap><a href=""></a></td>
        <td colspan="32">&#x00A0;</td></tr><tr style="background-color: white;"><td nowrap style="font-weight: bold;text-align: right;vertical-align: top;">Response</td>
        <td style=";vertical-align: top;" nowrap><a href=""></a></td>
        <td colspan="32">&#x00A0;</td>
      </tr>
    </table>
  </body>
</html>]]></content>
  <published>2017-06-02T07:38:31.112+01:00</published>
  <updated>2017-06-02T07:38:31.112+01:00</updated>
  <http:httpStatus>201</http:httpStatus>
  <sdata:payload>
    <crm:computePrice sdata:uuid="e60182b9-c113-4fdc-b2cb-5d66b4828a53">
      <crm:request sdata:uuid="eb3392eb-5425-45df-aedf-47f914688171">
        <crm:tradingAccount sdata:url="http://localhost:5493/sdata/Accounts50/GCRM/{C4C463BE-B098-4A7D-A23B-D1A92B8DCB59}/tradingAccountCustomer(be33197f-03c1-46e3-b789-5e078562b0c0)?format=atomentry" sdata:uuid="be33197f-03c1-46e3-b789-5e078562b0c0">
          <crm:active>true</crm:active>
          <crm:customerSupplierFlag>Customer</crm:customerSupplierFlag>
          <crm:companyPersonFlag>Company</crm:companyPersonFlag>
          <crm:invoiceTradingAccount xsi:nil="true" />
          <crm:openedDate>2013-01-02</crm:openedDate>
          <crm:reference>A1D001</crm:reference>
          <crm:reference2 xsi:nil="true" />
          <crm:status>Open</crm:status>
          <crm:name>A1 Design Services</crm:name>
          <crm:shortName xsi:nil="true" />
          <crm:type>Unknown</crm:type>
          <crm:registeredAddress xsi:nil="true" />
          <crm:postalAddresses xsi:nil="true" />
          <crm:shippingAddresses xsi:nil="true" />
          <crm:billingAddresses xsi:nil="true" />
          <crm:phones xsi:nil="true" />
          <crm:emails xsi:nil="true" />
          <crm:website>www.sage.co.uk</crm:website>
          <crm:contacts xsi:nil="true" />
          <crm:deliveryContact xsi:nil="true" />
          <crm:salesPersons xsi:nil="true" />
          <crm:deliveryMethod xsi:nil="true" />
          <crm:deliveryRule>true</crm:deliveryRule>
          <crm:currency>GBP</crm:currency>
          <crm:taxCode xsi:nil="true" />
          <crm:taxReference>GB238 3839 38</crm:taxReference>
          <crm:taxationCountry>GB</crm:taxationCountry>
          <crm:useTaxInclusivePrices xsi:nil="true" />
          <crm:financeBalance>12.98</crm:financeBalance>
          <crm:financeLimit>1000.00</crm:financeLimit>
          <crm:financeBalanceDate xsi:nil="true" />
          <crm:financeStatusFlag>false</crm:financeStatusFlag>
          <crm:financeStatusText>Open</crm:financeStatusText>
          <crm:settlementDiscountType>Percent</crm:settlementDiscountType>
          <crm:settlementDiscountAmount xsi:nil="true" />
          <crm:settlementDiscountPercent>2.50</crm:settlementDiscountPercent>
          <crm:settlementDiscountTerms>15</crm:settlementDiscountTerms>
          <crm:settlementDiscountTermsCommencement xsi:nil="true" />
          <crm:settlementDiscountIncludedInTotal>true</crm:settlementDiscountIncludedInTotal>
          <crm:paymentTerms>30</crm:paymentTerms>
          <crm:paymentTermsCommencement xsi:nil="true" />
          <crm:orderDiscountType xsi:nil="true" />
          <crm:orderDiscountAmount xsi:nil="true" />
          <crm:orderDiscountPercent xsi:nil="true" />
          <crm:orderText1 xsi:nil="true" />
          <crm:orderText2 xsi:nil="true" />
          <crm:orderLineDiscountType xsi:nil="true" />
          <crm:orderLineDiscountAmount xsi:nil="true" />
          <crm:orderLineDiscountPercent>0.00</crm:orderLineDiscountPercent>
          <crm:orderLineText1 xsi:nil="true" />
          <crm:orderLineText2 xsi:nil="true" />
          <crm:invoiceDiscountType xsi:nil="true" />
          <crm:invoiceDiscountAmount xsi:nil="true" />
          <crm:invoiceDiscountPercent>0.00</crm:invoiceDiscountPercent>
          <crm:invoiceText1 xsi:nil="true" />
          <crm:invoiceText2 xsi:nil="true" />
          <crm:bankAccounts xsi:nil="true" />
          <crm:tenderType xsi:nil="true" />
          <crm:defaultFulfillmentLocation xsi:nil="true" />
          <crm:pricelists xsi:nil="true" />
          <crm:pricingOverride xsi:nil="true" />
          <crm:accountingType xsi:nil="true" />
          <crm:financialAccounts xsi:nil="true" />
          <crm:primacyIndicator>true</crm:primacyIndicator>
          <crm:opportunities xsi:nil="true" />
          <crm:salesQuotations xsi:nil="true" />
          <crm:salesOrders xsi:nil="true" />
          <crm:salesOrderDeliveries xsi:nil="true" />
          <crm:salesInvoices xsi:nil="true" />
          <crm:salesCredits xsi:nil="true" />
          <crm:purchaseOrders xsi:nil="true" />
          <crm:purchaseOrderDeliveries xsi:nil="true" />
          <crm:receipts xsi:nil="true" />
          <crm:interactions xsi:nil="true" />
          <crm:projects xsi:nil="true" />
        </crm:tradingAccount>
        <crm:pricingDocumentID xsi:nil="true" />
        <crm:pricingDocumentType xsi:nil="true" />
        <crm:pricingDocumentDate xsi:nil="true" />
        <crm:pricingDocumentStatus xsi:nil="true" />
        <crm:pricingDocumentCurrency xsi:nil="true" />
        <crm:pricingList xsi:nil="true" />
        <crm:pricingShippingAddress xsi:nil="true" />
        <crm:carrierTradingAccount xsi:nil="true" />
        <crm:carrierNetPrice xsi:nil="true" />
        <crm:carrierTaxPrice xsi:nil="true" />
        <crm:carrierGrossPrice xsi:nil="true" />
        <crm:carrierReference xsi:nil="true" />
        <crm:salesPerson xsi:nil="true" />
        <crm:buyer xsi:nil="true" />
        <crm:taxCode xsi:nil="true" />
        <crm:doNotChangePrice>false</crm:doNotChangePrice>
        <crm:discountType>Percent</crm:discountType>
        <crm:discountAmount>0.00</crm:discountAmount>
        <crm:discountPercent>0.00</crm:discountPercent>
        <crm:settlementDiscountType xsi:nil="true" />
        <crm:settlementDiscountPercent>0.00</crm:settlementDiscountPercent>
        <crm:additionalDiscount1Type xsi:nil="true" />
        <crm:additionalDiscount1Amount xsi:nil="true" />
        <crm:additionalDiscount1Percent xsi:nil="true" />
        <crm:additionalDiscount2Type xsi:nil="true" />
        <crm:additionalDiscount2Amount xsi:nil="true" />
        <crm:additionalDiscount2Percent xsi:nil="true" />
        <crm:netTotal>190.00</crm:netTotal>
        <crm:discountTotal>0.00</crm:discountTotal>
        <crm:taxTotal>38.00</crm:taxTotal>
        <crm:grossTotal>228.00</crm:grossTotal>
        <crm:costTotal>250.00</crm:costTotal>
        <crm:profitTotal>-60.00</crm:profitTotal>
        <crm:additionalText xsi:nil="true" />
        <crm:pricingDocumentLines>
          <crm:pricingDocumentLine sdata:uuid="de2bb730-51b4-4d0b-968c-181fe0c43a01">
            <crm:uuid xsi:nil="true" />
            <crm:commodity sdata:url="http://localhost:5493/sdata/Accounts50/GCRM/{C4C463BE-B098-4A7D-A23B-D1A92B8DCB59}/commodities(ff991dcf-bd25-4d20-95db-813cc8dc86b9)?format=atomentry" sdata:uuid="ff991dcf-bd25-4d20-95db-813cc8dc86b9">
              <crm:active>true</crm:active>
              <crm:commodityGroup xsi:nil="true" />
              <crm:commodityIdentifierType>Total</crm:commodityIdentifierType>
              <crm:commodityIdentifiers xsi:nil="true" />
              <crm:reference>BOARD001</crm:reference>
              <crm:reference2 xsi:nil="true" />
              <crm:status xsi:nil="true" />
              <crm:name>Whiteboard - Drywipe (900 x 1200)</crm:name>
              <crm:shortName xsi:nil="true" />
              <crm:description xsi:nil="true" />
              <crm:alternativeDescription1>Whiteboard - Drywipe (900 x 1200)</crm:alternativeDescription1>
              <crm:alternativeDescription2 xsi:nil="true" />
              <crm:type>Presentation Supplies</crm:type>
              <crm:unitOfMeasure xsi:nil="true" />
              <crm:buyingAllowedFlag>true</crm:buyingAllowedFlag>
              <crm:buyingUnitOfMeasure xsi:nil="true" />
              <crm:buyingUnitOfMeasureNumber xsi:nil="true" />
              <crm:sellingAllowedFlag>true</crm:sellingAllowedFlag>
              <crm:sellingUnitOfMeasure xsi:nil="true" />
              <crm:sellingUnitOfMeasureNumber xsi:nil="true" />
              <crm:packingUnitOfMeasure xsi:nil="true" />
              <crm:packingUnitOfMeasureNumber xsi:nil="true" />
              <crm:catalogueNumber>U143</crm:catalogueNumber>
              <crm:supplierTradingAccount xsi:nil="true" />
              <crm:supplierReference>UNI001</crm:supplierReference>
              <crm:manufacturerCompany />
              <crm:manufacturerReference xsi:nil="true" />
              <crm:material xsi:nil="true" />
              <crm:countryOfOrigin xsi:nil="true" />
              <crm:weight>0.00</crm:weight>
              <crm:weightKg xsi:nil="true" />
              <crm:classification />
              <crm:taxCodes xsi:nil="true" />
              <crm:financialAccounts xsi:nil="true" />
              <crm:dutyApplicableFlag xsi:nil="true" />
              <crm:dutyRate xsi:nil="true" />
              <crm:tradeIdentificationNumber xsi:nil="true" />
              <crm:replacement xsi:nil="true" />
              <crm:replacementDate xsi:nil="true" />
              <crm:leadTime xsi:nil="true" />
              <crm:cost>25.00</crm:cost>
              <crm:associatedChildCommodities xsi:nil="true" />
              <crm:associatedParentCommodity xsi:nil="true" />
              <crm:version xsi:nil="true" />
              <crm:commissionType xsi:nil="true" />
              <crm:commissionAmount xsi:nil="true" />
              <crm:commissionPercent xsi:nil="true" />
              <crm:interactions xsi:nil="true" />
              <crm:opportunities xsi:nil="true" />
              <crm:salesQuotationLines xsi:nil="true" />
              <crm:salesOrderLines xsi:nil="true" />
              <crm:salesOrderDeliveryLines xsi:nil="true" />
              <crm:salesInvoiceLines xsi:nil="true" />
              <crm:salesCreditLines xsi:nil="true" />
              <crm:purchaseOrderLines xsi:nil="true" />
              <crm:purchaseOrderDeliveryLines xsi:nil="true" />
              <crm:pricelists xsi:nil="true" />
              <crm:prices xsi:nil="true" />
            </crm:commodity>
            <crm:commodityVariant xsi:nil="true" />
            <crm:commodityDimension xsi:nil="true" />
            <crm:quantity>10.00</crm:quantity>
            <crm:unitOfMeasure xsi:nil="true" />
            <crm:pricingDocumentLineType xsi:nil="true" />
            <crm:fulfillmentLocation xsi:nil="true" />
            <crm:description xsi:nil="true" />
            <crm:enteredPrice xsi:nil="true" />
            <crm:initialPrice>19.00</crm:initialPrice>
            <crm:actualPrice>19.00</crm:actualPrice>
            <crm:discountType xsi:nil="true" />
            <crm:discountAmount>0.00</crm:discountAmount>
            <crm:discountPercent>0.00</crm:discountPercent>
            <crm:subtotalDiscountType xsi:nil="true" />
            <crm:subtotalDiscountAmount xsi:nil="true" />
            <crm:subtotalDiscountPercent xsi:nil="true" />
            <crm:netTotal>190.00</crm:netTotal>
            <crm:chargesTotal>0.00</crm:chargesTotal>
            <crm:discountTotal>0.00</crm:discountTotal>
            <crm:taxCode xsi:nil="true" />
            <crm:priceTax>3.80</crm:priceTax>
            <crm:taxTotal>38.00</crm:taxTotal>
            <crm:grossTotal>228.00</crm:grossTotal>
            <crm:costTotal>250.00</crm:costTotal>
            <crm:profitTotal>-60.00</crm:profitTotal>
            <crm:reference xsi:nil="true" />
            <crm:priceChangeStatus xsi:nil="true" />
            <crm:shortText xsi:nil="true" />
            <crm:longText xsi:nil="true" />
          </crm:pricingDocumentLine>
        </crm:pricingDocumentLines>
      </crm:request>
      <crm:response sdata:uuid="eb3392eb-5425-45df-aedf-47f914688171">
        <crm:tradingAccount sdata:url="http://localhost:5493/sdata/Accounts50/GCRM/{C4C463BE-B098-4A7D-A23B-D1A92B8DCB59}/tradingAccountCustomer(be33197f-03c1-46e3-b789-5e078562b0c0)?format=atomentry" sdata:uuid="be33197f-03c1-46e3-b789-5e078562b0c0">
          <crm:active>true</crm:active>
          <crm:customerSupplierFlag>Customer</crm:customerSupplierFlag>
          <crm:companyPersonFlag>Company</crm:companyPersonFlag>
          <crm:invoiceTradingAccount xsi:nil="true" />
          <crm:openedDate>2013-01-02</crm:openedDate>
          <crm:reference>A1D001</crm:reference>
          <crm:reference2 xsi:nil="true" />
          <crm:status>Open</crm:status>
          <crm:name>A1 Design Services</crm:name>
          <crm:shortName xsi:nil="true" />
          <crm:type>Unknown</crm:type>
          <crm:registeredAddress xsi:nil="true" />
          <crm:postalAddresses xsi:nil="true" />
          <crm:shippingAddresses xsi:nil="true" />
          <crm:billingAddresses xsi:nil="true" />
          <crm:phones xsi:nil="true" />
          <crm:emails xsi:nil="true" />
          <crm:website>www.sage.co.uk</crm:website>
          <crm:contacts xsi:nil="true" />
          <crm:deliveryContact xsi:nil="true" />
          <crm:salesPersons xsi:nil="true" />
          <crm:deliveryMethod xsi:nil="true" />
          <crm:deliveryRule>true</crm:deliveryRule>
          <crm:currency>GBP</crm:currency>
          <crm:taxCode xsi:nil="true" />
          <crm:taxReference>GB238 3839 38</crm:taxReference>
          <crm:taxationCountry>GB</crm:taxationCountry>
          <crm:useTaxInclusivePrices xsi:nil="true" />
          <crm:financeBalance>12.98</crm:financeBalance>
          <crm:financeLimit>1000.00</crm:financeLimit>
          <crm:financeBalanceDate xsi:nil="true" />
          <crm:financeStatusFlag>false</crm:financeStatusFlag>
          <crm:financeStatusText>Open</crm:financeStatusText>
          <crm:settlementDiscountType>Percent</crm:settlementDiscountType>
          <crm:settlementDiscountAmount xsi:nil="true" />
          <crm:settlementDiscountPercent>2.50</crm:settlementDiscountPercent>
          <crm:settlementDiscountTerms>15</crm:settlementDiscountTerms>
          <crm:settlementDiscountTermsCommencement xsi:nil="true" />
          <crm:settlementDiscountIncludedInTotal>true</crm:settlementDiscountIncludedInTotal>
          <crm:paymentTerms>30</crm:paymentTerms>
          <crm:paymentTermsCommencement xsi:nil="true" />
          <crm:orderDiscountType xsi:nil="true" />
          <crm:orderDiscountAmount xsi:nil="true" />
          <crm:orderDiscountPercent xsi:nil="true" />
          <crm:orderText1 xsi:nil="true" />
          <crm:orderText2 xsi:nil="true" />
          <crm:orderLineDiscountType xsi:nil="true" />
          <crm:orderLineDiscountAmount xsi:nil="true" />
          <crm:orderLineDiscountPercent>0.00</crm:orderLineDiscountPercent>
          <crm:orderLineText1 xsi:nil="true" />
          <crm:orderLineText2 xsi:nil="true" />
          <crm:invoiceDiscountType xsi:nil="true" />
          <crm:invoiceDiscountAmount xsi:nil="true" />
          <crm:invoiceDiscountPercent>0.00</crm:invoiceDiscountPercent>
          <crm:invoiceText1 xsi:nil="true" />
          <crm:invoiceText2 xsi:nil="true" />
          <crm:bankAccounts xsi:nil="true" />
          <crm:tenderType xsi:nil="true" />
          <crm:defaultFulfillmentLocation xsi:nil="true" />
          <crm:pricelists xsi:nil="true" />
          <crm:pricingOverride xsi:nil="true" />
          <crm:accountingType xsi:nil="true" />
          <crm:financialAccounts xsi:nil="true" />
          <crm:primacyIndicator>true</crm:primacyIndicator>
          <crm:opportunities xsi:nil="true" />
          <crm:salesQuotations xsi:nil="true" />
          <crm:salesOrders xsi:nil="true" />
          <crm:salesOrderDeliveries xsi:nil="true" />
          <crm:salesInvoices xsi:nil="true" />
          <crm:salesCredits xsi:nil="true" />
          <crm:purchaseOrders xsi:nil="true" />
          <crm:purchaseOrderDeliveries xsi:nil="true" />
          <crm:receipts xsi:nil="true" />
          <crm:interactions xsi:nil="true" />
          <crm:projects xsi:nil="true" />
        </crm:tradingAccount>
        <crm:pricingDocumentID xsi:nil="true" />
        <crm:pricingDocumentType xsi:nil="true" />
        <crm:pricingDocumentDate xsi:nil="true" />
        <crm:pricingDocumentStatus xsi:nil="true" />
        <crm:pricingDocumentCurrency xsi:nil="true" />
        <crm:pricingList xsi:nil="true" />
        <crm:pricingShippingAddress xsi:nil="true" />
        <crm:carrierTradingAccount xsi:nil="true" />
        <crm:carrierNetPrice xsi:nil="true" />
        <crm:carrierTaxPrice xsi:nil="true" />
        <crm:carrierGrossPrice xsi:nil="true" />
        <crm:carrierReference xsi:nil="true" />
        <crm:salesPerson xsi:nil="true" />
        <crm:buyer xsi:nil="true" />
        <crm:taxCode xsi:nil="true" />
        <crm:doNotChangePrice>false</crm:doNotChangePrice>
        <crm:discountType>Percent</crm:discountType>
        <crm:discountAmount>0.00</crm:discountAmount>
        <crm:discountPercent>0.00</crm:discountPercent>
        <crm:settlementDiscountType xsi:nil="true" />
        <crm:settlementDiscountPercent>0.00</crm:settlementDiscountPercent>
        <crm:additionalDiscount1Type xsi:nil="true" />
        <crm:additionalDiscount1Amount xsi:nil="true" />
        <crm:additionalDiscount1Percent xsi:nil="true" />
        <crm:additionalDiscount2Type xsi:nil="true" />
        <crm:additionalDiscount2Amount xsi:nil="true" />
        <crm:additionalDiscount2Percent xsi:nil="true" />
        <crm:netTotal>190.00</crm:netTotal>
        <crm:discountTotal>0.00</crm:discountTotal>
        <crm:taxTotal>38.00</crm:taxTotal>
        <crm:grossTotal>228.00</crm:grossTotal>
        <crm:costTotal>250.00</crm:costTotal>
        <crm:profitTotal>-60.00</crm:profitTotal>
        <crm:additionalText xsi:nil="true" />
        <crm:pricingDocumentLines>
          <crm:pricingDocumentLine sdata:uuid="de2bb730-51b4-4d0b-968c-181fe0c43a01">
            <crm:uuid xsi:nil="true" />
            <crm:commodity sdata:url="http://localhost:5493/sdata/Accounts50/GCRM/{C4C463BE-B098-4A7D-A23B-D1A92B8DCB59}/commodities(ff991dcf-bd25-4d20-95db-813cc8dc86b9)?format=atomentry" sdata:uuid="ff991dcf-bd25-4d20-95db-813cc8dc86b9">
              <crm:active>true</crm:active>
              <crm:commodityGroup xsi:nil="true" />
              <crm:commodityIdentifierType>Total</crm:commodityIdentifierType>
              <crm:commodityIdentifiers xsi:nil="true" />
              <crm:reference>BOARD001</crm:reference>
              <crm:reference2 xsi:nil="true" />
              <crm:status xsi:nil="true" />
              <crm:name>Whiteboard - Drywipe (900 x 1200)</crm:name>
              <crm:shortName xsi:nil="true" />
              <crm:description xsi:nil="true" />
              <crm:alternativeDescription1>Whiteboard - Drywipe (900 x 1200)</crm:alternativeDescription1>
              <crm:alternativeDescription2 xsi:nil="true" />
              <crm:type>Presentation Supplies</crm:type>
              <crm:unitOfMeasure xsi:nil="true" />
              <crm:buyingAllowedFlag>true</crm:buyingAllowedFlag>
              <crm:buyingUnitOfMeasure xsi:nil="true" />
              <crm:buyingUnitOfMeasureNumber xsi:nil="true" />
              <crm:sellingAllowedFlag>true</crm:sellingAllowedFlag>
              <crm:sellingUnitOfMeasure xsi:nil="true" />
              <crm:sellingUnitOfMeasureNumber xsi:nil="true" />
              <crm:packingUnitOfMeasure xsi:nil="true" />
              <crm:packingUnitOfMeasureNumber xsi:nil="true" />
              <crm:catalogueNumber>U143</crm:catalogueNumber>
              <crm:supplierTradingAccount xsi:nil="true" />
              <crm:supplierReference>UNI001</crm:supplierReference>
              <crm:manufacturerCompany />
              <crm:manufacturerReference xsi:nil="true" />
              <crm:material xsi:nil="true" />
              <crm:countryOfOrigin xsi:nil="true" />
              <crm:weight>0.00</crm:weight>
              <crm:weightKg xsi:nil="true" />
              <crm:classification />
              <crm:taxCodes xsi:nil="true" />
              <crm:financialAccounts xsi:nil="true" />
              <crm:dutyApplicableFlag xsi:nil="true" />
              <crm:dutyRate xsi:nil="true" />
              <crm:tradeIdentificationNumber xsi:nil="true" />
              <crm:replacement xsi:nil="true" />
              <crm:replacementDate xsi:nil="true" />
              <crm:leadTime xsi:nil="true" />
              <crm:cost>25.00</crm:cost>
              <crm:associatedChildCommodities xsi:nil="true" />
              <crm:associatedParentCommodity xsi:nil="true" />
              <crm:version xsi:nil="true" />
              <crm:commissionType xsi:nil="true" />
              <crm:commissionAmount xsi:nil="true" />
              <crm:commissionPercent xsi:nil="true" />
              <crm:interactions xsi:nil="true" />
              <crm:opportunities xsi:nil="true" />
              <crm:salesQuotationLines xsi:nil="true" />
              <crm:salesOrderLines xsi:nil="true" />
              <crm:salesOrderDeliveryLines xsi:nil="true" />
              <crm:salesInvoiceLines xsi:nil="true" />
              <crm:salesCreditLines xsi:nil="true" />
              <crm:purchaseOrderLines xsi:nil="true" />
              <crm:purchaseOrderDeliveryLines xsi:nil="true" />
              <crm:pricelists xsi:nil="true" />
              <crm:prices xsi:nil="true" />
            </crm:commodity>
            <crm:commodityVariant xsi:nil="true" />
            <crm:commodityDimension xsi:nil="true" />
            <crm:quantity>10.00</crm:quantity>
            <crm:unitOfMeasure xsi:nil="true" />
            <crm:pricingDocumentLineType xsi:nil="true" />
            <crm:fulfillmentLocation xsi:nil="true" />
            <crm:description xsi:nil="true" />
            <crm:enteredPrice xsi:nil="true" />
            **<crm:initialPrice>19.00</crm:initialPrice>
            <crm:actualPrice>19.00</crm:actualPrice>**
            <crm:discountType xsi:nil="true" />
            <crm:discountAmount>0.00</crm:discountAmount>
            <crm:discountPercent>0.00</crm:discountPercent>
            <crm:subtotalDiscountType xsi:nil="true" />
            <crm:subtotalDiscountAmount xsi:nil="true" />
            <crm:subtotalDiscountPercent xsi:nil="true" />
            <crm:netTotal>190.00</crm:netTotal>
            <crm:chargesTotal>0.00</crm:chargesTotal>
            <crm:discountTotal>0.00</crm:discountTotal>
            <crm:taxCode xsi:nil="true" />
            <crm:priceTax>3.80</crm:priceTax>
            <crm:taxTotal>38.00</crm:taxTotal>
            <crm:grossTotal>228.00</crm:grossTotal>
            <crm:costTotal>250.00</crm:costTotal>
            <crm:profitTotal>-60.00</crm:profitTotal>
            <crm:reference xsi:nil="true" />
            <crm:priceChangeStatus xsi:nil="true" />
            <crm:shortText xsi:nil="true" />
            <crm:longText xsi:nil="true" />
          </crm:pricingDocumentLine>
        </crm:pricingDocumentLines>
      </crm:response>
    </crm:computePrice>
  </sdata:payload>
</entry>

Hope that helps
kieronmoran commented 7 years ago

Hi Darren,

Can you highlight in the response where the Discount amounts/types have been returned?

Thanks,

Kieron

p.s. the reason the response probably doesn't look right is that I have stripped out all the unnecessary elements in the URL.

darroncockram commented 7 years ago

Looks like the markup here does not allow highlighting to be mixed with XML formatting (or at least I could not find a way to do it). I've added formatting to my original reply but it has just come out as asterisks.

The service does not return the discount amount or type. It returns a re-priced result based on the data submitted so it will be the initialPrice and actualPrice fields that you are likely interested in.

One thing I just realised is that in my copy of the demo data I had added A1 Design Services in to TRADEA price list. As this is not in there by default you may not be seeing the discount result that I do.

kieronmoran commented 7 years ago

Hi Darren,

Thanks for the response.

I may again be missing something but in your example the initialPrice and actualPrice are identical.

19.00 19.00 Are you able to provide and example post and response whereby discounts are being applied? Many thanks, Kieron
darroncockram commented 7 years ago

The above request and response example is one that has a discount. Possibly what is confusing is that the response from the Accounts adapter does not contain the actual discount amount. Rather that the initial and actual price contain the discounted value i.e. the amount that would be due for that line after all the discounting rules have been applied.

In the above data the non-discounted list price for the commodity is £20.00 but after discounts have been applied based on the customer, price lists, net value discounts, etc the price is £19.00.

Hope that helps.

kieronmoran commented 7 years ago

Thanks Darren,

We have investigated further and it appears that this service method ONLY returns the PriceList Price, it does NOT return any additional discounts (i.e DiscountA, DiscountB etc...).

I have attached a zip file showing our demo system setup (Customer, Price List, Discounts and an Example Order). In addition there is a text file showing our responses for different Order Line Quantities.

Can you check to make sure that the Compute Price operation factors in Discounts based on quantity ordered?

It may be that I am missing something in my post so for completeness, the URLis: http://localhost:5493/sdata/Accounts50/GCRM/-/computePrice/$service/ComputePrice?exclude=request&include=computePrice,pricingDocumentLines&select=response/netTotal,response/grossTotal,response/netTotal,response/taxTotal,response/discountTotal,response/discountType,response/discountAmount,response/discountPercent,response/pricingDocumentLines/initialPrice,response/pricingDocumentLines/actualPrice&_includeContent=false

and the payload is: `<?xml version="1.0" encoding="utf-8"?> <entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns="http://www.w3.org/2005/Atom" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:sme="http://schemas.sage.com/sdata/sme/2007" xmlns:sdatasync="http://schemas.sage.com/sdata/sync/2008/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdata="http://schemas.sage.com/sdata/2008/1" xmlns:http="http://schemas.sage.com/sdata/http/2008/1">

100 ` Many thanks, Kieron [Supporting Files.zip](https://github.com/Sage/SData-2.0/files/1108206/Supporting.Files.zip)
darroncockram commented 7 years ago

The Accounts 50 adapter calls the same underlying code as the UI so it definitely does handle the full range of discount options available in the main application. If you aren't seeing the additional discounts reflected in the actual price in the response the most likely thing will be that the discounts are not setup as desired in the main application.

The specifics of setting up discounting models in Accounts is somewhat off topic for this forum but my guess would be that you may not have selected the appropriate additional discount level on the customer record.

The best way to confirm that the discounts are setup correctly is to manually create an invoice in the UI using the same customer and commodities. The discounts calculated in the UI should be reflected in an equivalent request to the compute price method in the Sdata adapter.

kieronmoran commented 7 years ago

Hi Darren

In my last post I attached a zip file with screenshots showing the customer discounts set up, the price list setup, the discounts setup and an order in Sgae50 with the discounts applied.

In addition there is a text file showing the responses received for the same quantities, product and customer account when calling the computePrice operation.

These clearly show a correct setup in Sage 50 whereas the sdata response do not show the discounts that the application does.

Did you see the zip file and the screenshots?

darroncockram commented 7 years ago

Apologies I had not spotted the attachment previously. However I'll have to play the 'works on my machine' card here though as I do see the expected actual price reflected in the response to the computePrice request using the same discount settings as you are.

Does the UUID for the trading account in your request definitely refer to the customer record from the screen shot?

kieronmoran commented 7 years ago

Hi Darren,

I have checked and double checked the UUID's and also the Sage50 Settings and still no joy :-( This is what I have tried:

  1. Remove all price lists and discount settings for a Customer: The Selling Price is returned which is correct..
  2. Set a Price List to the Customer: The Price List price is returned which is correct.
  3. Set a Discount % value to the Customer: The Price Lists price with the Discount % applied is returned which is correct.
  4. Set an Additional Discount against the Customer (in this case Discount A, which has discounts based on quantity): The price from Set 3 is returned with no additional discounts applied based on quantity. This is incorrect. If I repeat the same but exclude step 3, then the Price List price is returned with no additional discounts applied based on quantity. This is incorrect.

Rather than going round in circles, would it be possible to have a call and you remote connect to my machine so you can see what I see and we can run through it together?

We have quite a large prospective customer that requires this functionality and it could be a deal breaker :-(

Many thanks in advance,

Kieron

darroncockram commented 7 years ago

The only support that Sage offers for the SIF and Sdata adapters is is via this forum I'm afraid.

Can't think of a good reason why you would not see the additional discount coming through but I do. What version of Accounts are you testing this with?

kieronmoran commented 7 years ago

I'm testing with v23 (2016 I think).

kieronmoran commented 7 years ago

Hi Darren,

What settings do you have against the Customer Account for Pricing and Discounting?

I have my additional discount set to "DiscountA".

Strangely, if I set this to "Invoice Value", then I do get the Invoice Value Discounts applied (found in Customer Defaults).

When this is set, I also see a different value in the response for actualPrice:

18.50 15.73 In your earlier examples, these values were always the same suggesting that no additional discount was being applied based on quantity. Are you able to replicate this on your system? Kieron
darroncockram commented 7 years ago

v23 is the 2017 version of Accounts. I've tried with that version as well as v22 (2016) and the much older version v18 (2012). In all cases I am seeing the expected discounts reflected in the response from the computePrice request.

I am really struggling to explain why you do not see the discounts. I'm not doing anything special. I simply applying the same options as you show in your screen shots.

kieronmoran commented 7 years ago

Hi Darren

It is a mystery inst it :-(

In your responses are you getting a different Initial Price and Actual Price when a customer has DiscountA set as the additional discount value?

This would indicate it is working for the additional discounts. If you set the additional discount to Invoice Value, then you do get different values.

The way I proved this to myself was that when DiscountA was selected and an Order raised in Sage 50, then the prices changed based on quantity as you would expect however when computing price using sdata, the price shown was only ever the price list price.

Regards

Kieron

Thanks

Kieron

darroncockram commented 7 years ago

In your responses are you getting a different Initial Price and Actual Price when a customer has DiscountA set as the additional discount value?

Yes, this is how I know the discounting is working correctly. The actualPrice holds the expected value based on the various discounting rules. This always has the value I expect whatever additional discount settings are configured.

the price shown was only ever the price list price.

Are you looking at the right field? The initialPrice will always be the list price (which may have come from a price list or directly from the product), the actualPrice contains the price after any discounts are applied.

kieronmoran commented 7 years ago

Hi Darron,

What am I missing????

Can you post a response where you are getting a visibly discounted price? (all the examples above do not show different prices).

Could you also post the Payload you are sending to the Service Operation endpoint?

many thanks,

Kieron

darroncockram commented 7 years ago

There is a request and response example in my post above. Obviously the UUIDs will be different in your dataset. I did not have an additional discount set on the customer when I captured that request/response but it would not change anything about the request, the only differences would be in the initial and actual prices that are returned.