> ## Documentation Index
> Fetch the complete documentation index at: https://help.lobyco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculate the discounts for a specified purchase



## OpenAPI

````yaml openapi/pos-discount-v1.json POST /v1/discounted-purchases
openapi: 3.0.4
info:
  title: Discount API 1.0
  version: '1.0'
servers:
  - url: https://{host}/pos-discount
    description: Your Lobyco environment
    variables:
      host:
        default: your-environment.lobyco.net
        description: >-
          The API host for your Lobyco environment. Replace it with the host you
          were given — this placeholder does not resolve.
security: []
paths:
  /v1/discounted-purchases:
    post:
      tags:
        - Service2Service
      summary: Calculate the discounts for a specified purchase
      operationId: POST Discount/CalculatePurchaseDiscounts
      parameters:
        - name: offerTypes
          in: query
          description: List of Offer types to consider during discount calculation
          schema:
            type: array
            items:
              type: string
        - name: excludedOfferTypes
          in: query
          description: List of Offer types to exclude during discount calculation
          schema:
            type: array
            items:
              type: string
        - name: skipReservation
          in: query
          description: >-
            When set tot true, coupons that granted discount/bonus will not be
            reserved
          schema:
            type: boolean
        - name: preserveExternalDiscounts
          in: query
          description: >-
            When set, controls whether external discounts are preserved in the
            response, overriding the PreserveExternalDiscounts feature flag
          schema:
            type: boolean
        - name: usePurchaseDateTime
          in: query
          description: >-
            If true, discount evaluation (including coupon eligibility) is
            performed using the request's PurchaseDateTimeUtc,

            retrieving only the coupons that were valid at that historical
            purchase time. If false, the current server time

            is used and only coupons valid "now" are considered.
          schema:
            type: boolean
            default: false
      requestBody:
        description: The specified purchase that the discounts need to be calculated for.
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/PurchaseLoad.Contract.Models.PurchaseLoadRequest
            examples:
              Purchase discounts:
                value:
                  receiptId: fb7eb632-886f-4a5b-92c8-c63943006cf2
                  storeId: '475'
                  memberId: '12396909'
                  currencyCode: DKK
                  totalAmount: 650
                  totalTaxAmount: 0
                  purchaseDateTimeUtc: '0001-01-01T00:00:00'
                  purchaseBusinessDateTime: '0001-01-01T00:00:00'
                  paymentMethods: []
                  products:
                    - id: d3ca42d7-b7ab-4c18-8293-1d39008a4e40
                      sequenceNumber: 1
                      categoryId: '1'
                      quantity:
                        unitOfMeasure: pcs
                        value: 2
                      originalPrice: 200
                      price: 200
                    - id: fd324399-ef53-4cba-8172-f855539e7a71
                      sequenceNumber: 2
                      categoryId: '1'
                      quantity:
                        unitOfMeasure: pcs
                        value: 3
                      originalPrice: 450
                      price: 450
                  discounts: []
                  taxes: []
          text/json:
            schema:
              $ref: >-
                #/components/schemas/PurchaseLoad.Contract.Models.PurchaseLoadRequest
            examples:
              Purchase discounts:
                value:
                  receiptId: fb7eb632-886f-4a5b-92c8-c63943006cf2
                  storeId: '475'
                  memberId: '12396909'
                  currencyCode: DKK
                  totalAmount: 650
                  totalTaxAmount: 0
                  purchaseDateTimeUtc: '0001-01-01T00:00:00'
                  purchaseBusinessDateTime: '0001-01-01T00:00:00'
                  paymentMethods: []
                  products:
                    - id: d3ca42d7-b7ab-4c18-8293-1d39008a4e40
                      sequenceNumber: 1
                      categoryId: '1'
                      quantity:
                        unitOfMeasure: pcs
                        value: 2
                      originalPrice: 200
                      price: 200
                    - id: fd324399-ef53-4cba-8172-f855539e7a71
                      sequenceNumber: 2
                      categoryId: '1'
                      quantity:
                        unitOfMeasure: pcs
                        value: 3
                      originalPrice: 450
                      price: 450
                  discounts: []
                  taxes: []
          application/*+json:
            schema:
              $ref: >-
                #/components/schemas/PurchaseLoad.Contract.Models.PurchaseLoadRequest
            examples:
              Purchase discounts:
                value:
                  receiptId: fb7eb632-886f-4a5b-92c8-c63943006cf2
                  storeId: '475'
                  memberId: '12396909'
                  currencyCode: DKK
                  totalAmount: 650
                  totalTaxAmount: 0
                  purchaseDateTimeUtc: '0001-01-01T00:00:00'
                  purchaseBusinessDateTime: '0001-01-01T00:00:00'
                  paymentMethods: []
                  products:
                    - id: d3ca42d7-b7ab-4c18-8293-1d39008a4e40
                      sequenceNumber: 1
                      categoryId: '1'
                      quantity:
                        unitOfMeasure: pcs
                        value: 2
                      originalPrice: 200
                      price: 200
                    - id: fd324399-ef53-4cba-8172-f855539e7a71
                      sequenceNumber: 2
                      categoryId: '1'
                      quantity:
                        unitOfMeasure: pcs
                        value: 3
                      originalPrice: 450
                      price: 450
                  discounts: []
                  taxes: []
      responses:
        '200':
          description: OK
          content:
            text/plain:
              schema:
                $ref: >-
                  #/components/schemas/PurchaseLoad.Contract.Models.PurchaseLoadResponse
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PurchaseLoad.Contract.Models.PurchaseLoadResponse
            text/json:
              schema:
                $ref: >-
                  #/components/schemas/PurchaseLoad.Contract.Models.PurchaseLoadResponse
components:
  schemas:
    PurchaseLoad.Contract.Models.PurchaseLoadRequest:
      required:
        - currencyCode
        - products
        - purchaseBusinessDateTime
        - purchaseDateTimeUtc
        - receiptId
        - storeId
        - totalAmount
        - totalTaxAmount
      type: object
      properties:
        receiptId:
          minLength: 1
          type: string
        storeId:
          minLength: 1
          type: string
        memberId:
          type: string
          nullable: true
        externalDiscountCardId:
          type: string
          nullable: true
        loyaltyCardId:
          type: string
          nullable: true
        orderId:
          type: string
          nullable: true
        currencyCode:
          maxLength: 3
          minLength: 3
          type: string
        totalAmount:
          type: number
          format: double
        amountForBonusCalculation:
          type: number
          format: double
          nullable: true
        totalTaxAmount:
          type: number
          format: double
        purchaseDateTimeUtc:
          type: string
          format: date-time
        purchaseBusinessDateTime:
          type: string
          format: date-time
        paymentMethods:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseLoad.Contract.Common.PaymentMethod'
          nullable: true
        products:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseLoad.Contract.Common.Product'
        discounts:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseLoad.Contract.Common.Discount'
          nullable: true
        taxes:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseLoad.Contract.Common.Tax'
          nullable: true
        shipping:
          $ref: '#/components/schemas/PurchaseLoad.Contract.Common.ShippingInfo'
        paymentLocation:
          type: string
          nullable: true
        checkoutType:
          $ref: '#/components/schemas/PurchaseLoad.Contract.Common.CheckoutType'
        metadata:
          type: object
          additionalProperties:
            nullable: true
          nullable: true
        posId:
          type: string
          nullable: true
        phone:
          type: string
          nullable: true
      additionalProperties: false
    PurchaseLoad.Contract.Models.PurchaseLoadResponse:
      required:
        - currencyCode
        - products
        - purchaseBusinessDateTime
        - purchaseDateTimeUtc
        - receiptId
        - storeId
        - totalAmount
        - totalTaxAmount
      type: object
      properties:
        receiptId:
          minLength: 1
          type: string
        storeId:
          minLength: 1
          type: string
        memberId:
          type: string
          nullable: true
        externalDiscountCardId:
          type: string
          nullable: true
        loyaltyCardId:
          type: string
          nullable: true
        currencyCode:
          maxLength: 3
          minLength: 3
          type: string
        totalAmount:
          type: number
          format: double
        amountForBonusCalculation:
          type: number
          format: double
          nullable: true
        totalTaxAmount:
          type: number
          format: double
        purchaseDateTimeUtc:
          type: string
          format: date-time
        purchaseBusinessDateTime:
          type: string
          format: date-time
        paymentMethods:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseLoad.Contract.Common.PaymentMethod'
          nullable: true
        products:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseLoad.Contract.Common.Product'
        discounts:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseLoad.Contract.Common.Discount'
          nullable: true
        taxes:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseLoad.Contract.Common.Tax'
          nullable: true
        shipping:
          $ref: '#/components/schemas/PurchaseLoad.Contract.Common.ShippingInfo'
        paymentLocation:
          type: string
          nullable: true
        metadata:
          type: object
          additionalProperties:
            nullable: true
          nullable: true
        posId:
          type: string
          nullable: true
        phone:
          type: string
          nullable: true
      additionalProperties: false
    PurchaseLoad.Contract.Common.PaymentMethod:
      type: object
      properties:
        amount:
          type: number
          format: double
        currencyCode:
          type: string
          nullable: true
        conversionRate:
          type: number
          format: double
          nullable: true
        paymentType:
          $ref: '#/components/schemas/PurchaseLoad.Contract.Common.PaymentType'
        cardPan:
          type: string
          nullable: true
        rounding:
          type: number
          format: double
          nullable: true
        displayName:
          type: string
          nullable: true
        metadata:
          type: object
          additionalProperties:
            nullable: true
          nullable: true
      additionalProperties: false
    PurchaseLoad.Contract.Common.Product:
      type: object
      properties:
        id:
          type: string
          nullable: true
        sequenceNumber:
          type: integer
          format: int32
        name:
          type: string
          nullable: true
        categoryId:
          type: string
          nullable: true
        originalReceiptId:
          type: string
          nullable: true
        disposalItem:
          $ref: '#/components/schemas/PurchaseLoad.Contract.Common.DisposalItem'
        unitPrice:
          type: number
          format: double
          nullable: true
        quantity:
          $ref: '#/components/schemas/PurchaseLoad.Contract.Common.Quantity'
        originalPrice:
          type: number
          format: double
        price:
          type: number
          format: double
        isReturned:
          type: boolean
          nullable: true
        isCancelled:
          type: boolean
          nullable: true
        taxIncludedInPrice:
          type: boolean
          nullable: true
        taxes:
          type: array
          items:
            $ref: '#/components/schemas/PurchaseLoad.Contract.Common.Tax'
          nullable: true
        metadata:
          type: object
          additionalProperties:
            nullable: true
          nullable: true
        discountAllocations:
          type: array
          items:
            $ref: >-
              #/components/schemas/PurchaseLoad.Contract.Common.DiscountAllocation
          nullable: true
      additionalProperties: false
    PurchaseLoad.Contract.Common.Discount:
      type: object
      properties:
        sequenceNumber:
          type: integer
          format: int32
          nullable: true
        name:
          type: string
          nullable: true
        totalDiscountAmount:
          type: number
          format: double
        couponId:
          type: string
          nullable: true
          deprecated: true
        couponIds:
          type: array
          items:
            type: string
          nullable: true
        appliedProducts:
          type: array
          items:
            type: integer
            format: int32
          nullable: true
        metadata:
          type: object
          additionalProperties:
            nullable: true
          nullable: true
      additionalProperties: false
    PurchaseLoad.Contract.Common.Tax:
      type: object
      properties:
        type:
          type: string
          nullable: true
        taxableAmount:
          type: number
          format: double
          nullable: true
        amount:
          type: number
          format: double
        percentage:
          type: number
          format: double
          nullable: true
      additionalProperties: false
    PurchaseLoad.Contract.Common.ShippingInfo:
      type: object
      properties:
        refundAsBonus:
          type: boolean
        totalAmount:
          type: number
          format: double
      additionalProperties: false
    PurchaseLoad.Contract.Common.CheckoutType:
      enum:
        - Pos
        - SelfCheckout
        - ScanAndPay
        - Online
      type: string
    PurchaseLoad.Contract.Common.PaymentType:
      enum:
        - Card
        - Cash
        - LoyaltyApp
        - Other
      type: string
    PurchaseLoad.Contract.Common.DisposalItem:
      type: object
      properties:
        name:
          type: string
          nullable: true
        unitPrice:
          type: number
          format: double
        quantity:
          $ref: '#/components/schemas/PurchaseLoad.Contract.Common.Quantity'
        totalAmount:
          type: number
          format: double
      additionalProperties: false
    PurchaseLoad.Contract.Common.Quantity:
      type: object
      properties:
        unitOfMeasure:
          type: string
          nullable: true
        value:
          type: number
          format: double
      additionalProperties: false
    PurchaseLoad.Contract.Common.DiscountAllocation:
      type: object
      properties:
        discountSequenceNumber:
          type: integer
          format: int32
        discountAmount:
          type: number
          format: double
      additionalProperties: false

````