openapi: 3.1.0
info:
  title: Tango Sales Inbound — File
  version: "0.9"
  description: |
    SFTP file-based inbound. Client drops a pipe-delimited file with monthly
    sales / exclusion rows. Tango picks the file up, applies Percent Rent
    calculations, and moves the file to Processed/.

    Each row is one business operation's turnover (or one exclusion) for a
    specific period. Send sales as positive amounts and exclusions as negative
    amounts. Data received for the same month overwrites the previous run.
  x-direction: inbound
  x-source: Client System
  x-destination: Tango
  x-transport: sftp
  x-file-format: pipe-delimited text (.txt)
  x-file-naming-convention: "{ClientCode}_sales_MMDDYYYYHHMMSS.txt"
servers:
  - url: sftp://sftp.tangoanalytics.com
    description: Production SFTP
    x-environment: production
    x-path: inbound/sales/
  - url: sftp://sftpdev.tangoanalytics.com
    description: Test SFTP (SIT/UAT)
    x-environment: test
    x-path: inbound/sales/
tags:
  - name: Sales Inbound File
paths:
  /inbound/sales:
    post:
      summary: Drop sales file at SFTP path
      operationId: deliverSalesInboundFile
      tags: [Sales Inbound File]
      requestBody:
        required: true
        content:
          text/plain:
            schema:
              type: string
              format: binary
              x-record-schema:
                $ref: "#/components/schemas/SalesInboundRow"
      responses:
        "200":
          description: File received and queued.
components:
  securitySchemes:
    sftpUserPassword:
      type: http
      scheme: basic
  schemas:
    SalesInboundRow:
      type: object
      required:
        - STORE_NUMBER
        - CALENDAR_MONTH
        - CALENDAR_YEAR
        - SALES_CATEGORY
        - SALES_EXCLUSION
        - PERIOD_AMOUNT
        - ACTUAL_FORECAST
      properties:
        STORE_NUMBER:
          type: string
          description: Mandatory store number.
        LEASE_NUMBER:
          type: string
        CALENDAR_MONTH:
          type: number
          description: Calendar period MM.
        CALENDAR_YEAR:
          type: string
          description: Calendar year YYYY (per the source data-mapping table).
        EFFECTIVE_FROM_DATE:
          type: string
          description: "MM/DD/YYYY. Auto-populated by Tango if omitted."
        EFFECTIVE_TO_DATE:
          type: string
          description: "MM/DD/YYYY. Auto-populated by Tango if omitted."
        SALES_CODE:
          type: string
          description: Validate against lookup `PERCENT_RENT_SALES_CODE`.
        SALES_CATEGORY:
          type: string
          description: Validate against lookup `PERCENT_RENT_SALES_CATEGORY`.
        SALES_EXCLUSION:
          type: string
          description: Validate against lookup `PERCENT_RENT_SALES_EXCLUSION`.
        PERIOD_AMOUNT:
          type: number
          description: Sales positive; exclusions negative.
        ACTUAL_FORECAST:
          type: string
          enum: [ACTUAL, FORECAST]
security:
  - sftpUserPassword: []
