Generate Invoice

POST /api/billing/invoice/yard/{yardId}/carrier/{carrierId}/periodCode/{periodCode}

Generates the invoice for the provided yard, carrier and period. This can take long if the number of movements is high. If an invoice already exists for the given parameters, an error will be returned

Path parameters

  • carrierId integer(int64) Required
  • periodCode string Required
  • yardId integer(int64) Required

Responses

  • 200 application/json

    OK

    Hide response attributes Show response attributes object
    • id integer(int64)

      Invoice ID

    • yard_id integer(int64)

      Yard ID

    • carrier_id integer(int64)

      Carrier ID

    • invoice_number string

      Invoice number

    • invoice_date Required

      Date the invoice was issued

    • period_code string Required

      Code representing the billing period

    • period_start Required

      Start of the billing period

    • period_end Required

      End of the billing period

    • truck_config object Required

      Configuration for a billable item (currently a vehicle) within a specific Carrier in a Yard

      Additional properties are allowed.

      Hide truck_config attributes Show truck_config attributes object
      • rate_type Required

        Type of rate applied to the carrier configuration

      • flat_billing object

        Billing options for rate type FLAT. (It will be ignored if the rate type is not FLAT)

        Additional properties are allowed.

        Hide flat_billing attributes Show flat_billing attributes object
        • rate_per_month string Required

          Rate charged per month. Json type must be string and not number to prevent rounding errors when there are decimals

        • spots integer(int32)

          The number of spots included in the flat rate before overage charges apply

        • overage_rate_per_day_and_spot string

          Overage rate charged per day for each spot beyond the included number of spots. Json type must be string and not number to prevent rounding errors when there are decimals

        • grace_period string

          ISO8606 Duration (eg. 30 minutes='PT30M', 1 hour='PT1H'). Set to null for no grace period

        • day_calculation

          Day calculation mode

      • daily_billing object

        Billing options for rate type DAILY (It will be ignored if the rate type is not DAILY)

        Additional properties are allowed.

        Hide daily_billing attributes Show daily_billing attributes object
        • rate_per_day string Required

          Rate charged per day. Json type must be string and not number to prevent rounding errors when there are decimals

        • grace_period string

          ISO8606 Duration (eg. 30 minutes='PT30M', 1 hour='PT1H'). Set to null for no grace period

        • day_calculation

          Day calculation mode

    • trucks_section object Required

      Summary of an invoice section for a specific vehicle type

      Additional properties are allowed.

      Hide trucks_section attributes Show trucks_section attributes object
      • rate_type Required

        Type of configuration rate

      • daily_billing object

        Summary of daily billing for a specific vehicle type

        Additional properties are allowed.

        Hide daily_billing attributes Show daily_billing attributes object
        • invoice_lines array[object] Required

          List of vehicle invoice lines

          Details of an individual line in the invoice for a specific vehicle

          Hide invoice_lines attributes Show invoice_lines attributes object
          • vehicle_number string Required

            Vehicle number

          • check_in_before_billing_period boolean Required

            Whether the vehicle was checked in before the billing period

          • check_in_date_time Required

            Check-in timestamp for the vehicle

          • check_out_date_time

            Check-out timestamp for the vehicle

          • check_out_after_billing_period boolean Required

            Whether the vehicle checked out after the billing period

          • billable_start_date_time Required

            Start of the billable period for this vehicle

          • billable_end_date_time Required

            End of the billable period for this vehicle

          • grace_period Required

            Grace period info

          • billable_days integer(int32) Required

            Number of days the vehicle is billable in Yard. It takes account for the grace period. Note that in rate type FLAT overageDays represents the actual days the vehicle will be billed, taken into account the time it was on a reserved spot

          • spot_number integer(int32)

            Only when rate type is FLAT: Reserved spot number if applicable

          • overage_days integer(int32)

            Only when rate type is FLAT: The actual days the vehicle will be billed using the overage rate

          • took_reserved_spot_at_check_in boolean

            Only when rate type is FLAT: Flag to indicate if vehicle claimed a reserved spot upon check-in

          • took_reserved_spot_that_became_available_while_in_yard boolean

            Only when rate type is FLAT: Flag to indicate if vehicle claimed a reserved spot that became available while it was in yard.

          • vehicle_number_that_left string

            Only when rate type is FLAT: Vehicle number of the vehicle that left, facilitating this vehicle to take a reserved spot in yard.

          • check_out_movement_id_of_vehicle_that_left integer(int64)

            Only when rate type is FLAT: Checkout movement ID of the vehicle that left, facilitating this vehicle to take a reserved spot in yard.

        • billable_days integer(int32) Required

          Total number of days billed across all vehicle visits

      • flat_billing object

        Summary of flat billing for a specific vehicle type

        Additional properties are allowed.

        Hide flat_billing attributes Show flat_billing attributes object
        • invoice_lines array[object] Required

          List of vehicle invoice lines

          Details of an individual line in the invoice for a specific vehicle

          Hide invoice_lines attributes Show invoice_lines attributes object
          • vehicle_number string Required

            Vehicle number

          • check_in_before_billing_period boolean Required

            Whether the vehicle was checked in before the billing period

          • check_in_date_time Required

            Check-in timestamp for the vehicle

          • check_out_date_time

            Check-out timestamp for the vehicle

          • check_out_after_billing_period boolean Required

            Whether the vehicle checked out after the billing period

          • billable_start_date_time Required

            Start of the billable period for this vehicle

          • billable_end_date_time Required

            End of the billable period for this vehicle

          • grace_period Required

            Grace period info

          • billable_days integer(int32) Required

            Number of days the vehicle is billable in Yard. It takes account for the grace period. Note that in rate type FLAT overageDays represents the actual days the vehicle will be billed, taken into account the time it was on a reserved spot

          • spot_number integer(int32)

            Only when rate type is FLAT: Reserved spot number if applicable

          • overage_days integer(int32)

            Only when rate type is FLAT: The actual days the vehicle will be billed using the overage rate

          • took_reserved_spot_at_check_in boolean

            Only when rate type is FLAT: Flag to indicate if vehicle claimed a reserved spot upon check-in

          • took_reserved_spot_that_became_available_while_in_yard boolean

            Only when rate type is FLAT: Flag to indicate if vehicle claimed a reserved spot that became available while it was in yard.

          • vehicle_number_that_left string

            Only when rate type is FLAT: Vehicle number of the vehicle that left, facilitating this vehicle to take a reserved spot in yard.

          • check_out_movement_id_of_vehicle_that_left integer(int64)

            Only when rate type is FLAT: Checkout movement ID of the vehicle that left, facilitating this vehicle to take a reserved spot in yard.

        • amount_flat_only number Required

          Amount charged for flat billing

        • overage_days integer(int32) Required

          Number of days exceeding the flat rate across all vehicle visits

        • overage_amount number Required

          Amount charged for exceeding flat rate

      • amount number Required

        The total amount applicable for this vehicle type

    • trucks_missing_checkin_section object

      Section with all registered check outs without a check ins for a specific vehicle type

      Additional properties are allowed.

      Hide trucks_missing_checkin_section attribute Show trucks_missing_checkin_section attribute object
      • missing_checkin_invoice_lines array[object]

        List of vehicles with a registered check outs without a check in

        Details of an individual line in the invoice for a specific vehicle

        Hide missing_checkin_invoice_lines attributes Show missing_checkin_invoice_lines attributes object
        • check_out_date_time Required

          Check-out timestamp for the vehicle without a Check in

        • vehicle_number string Required

          Vehicle number

    • trailer_config object Required

      Configuration for a billable item (currently a vehicle) within a specific Carrier in a Yard

      Additional properties are allowed.

      Hide trailer_config attributes Show trailer_config attributes object
      • rate_type Required

        Type of rate applied to the carrier configuration

      • flat_billing object

        Billing options for rate type FLAT. (It will be ignored if the rate type is not FLAT)

        Additional properties are allowed.

        Hide flat_billing attributes Show flat_billing attributes object
        • rate_per_month string Required

          Rate charged per month. Json type must be string and not number to prevent rounding errors when there are decimals

        • spots integer(int32)

          The number of spots included in the flat rate before overage charges apply

        • overage_rate_per_day_and_spot string

          Overage rate charged per day for each spot beyond the included number of spots. Json type must be string and not number to prevent rounding errors when there are decimals

        • grace_period string

          ISO8606 Duration (eg. 30 minutes='PT30M', 1 hour='PT1H'). Set to null for no grace period

        • day_calculation

          Day calculation mode

      • daily_billing object

        Billing options for rate type DAILY (It will be ignored if the rate type is not DAILY)

        Additional properties are allowed.

        Hide daily_billing attributes Show daily_billing attributes object
        • rate_per_day string Required

          Rate charged per day. Json type must be string and not number to prevent rounding errors when there are decimals

        • grace_period string

          ISO8606 Duration (eg. 30 minutes='PT30M', 1 hour='PT1H'). Set to null for no grace period

        • day_calculation

          Day calculation mode

    • trailers_section object Required

      Summary of an invoice section for a specific vehicle type

      Additional properties are allowed.

      Hide trailers_section attributes Show trailers_section attributes object
      • rate_type Required

        Type of configuration rate

      • daily_billing object

        Summary of daily billing for a specific vehicle type

        Additional properties are allowed.

        Hide daily_billing attributes Show daily_billing attributes object
        • invoice_lines array[object] Required

          List of vehicle invoice lines

          Details of an individual line in the invoice for a specific vehicle

          Hide invoice_lines attributes Show invoice_lines attributes object
          • vehicle_number string Required

            Vehicle number

          • check_in_before_billing_period boolean Required

            Whether the vehicle was checked in before the billing period

          • check_in_date_time Required

            Check-in timestamp for the vehicle

          • check_out_date_time

            Check-out timestamp for the vehicle

          • check_out_after_billing_period boolean Required

            Whether the vehicle checked out after the billing period

          • billable_start_date_time Required

            Start of the billable period for this vehicle

          • billable_end_date_time Required

            End of the billable period for this vehicle

          • grace_period Required

            Grace period info

          • billable_days integer(int32) Required

            Number of days the vehicle is billable in Yard. It takes account for the grace period. Note that in rate type FLAT overageDays represents the actual days the vehicle will be billed, taken into account the time it was on a reserved spot

          • spot_number integer(int32)

            Only when rate type is FLAT: Reserved spot number if applicable

          • overage_days integer(int32)

            Only when rate type is FLAT: The actual days the vehicle will be billed using the overage rate

          • took_reserved_spot_at_check_in boolean

            Only when rate type is FLAT: Flag to indicate if vehicle claimed a reserved spot upon check-in

          • took_reserved_spot_that_became_available_while_in_yard boolean

            Only when rate type is FLAT: Flag to indicate if vehicle claimed a reserved spot that became available while it was in yard.

          • vehicle_number_that_left string

            Only when rate type is FLAT: Vehicle number of the vehicle that left, facilitating this vehicle to take a reserved spot in yard.

          • check_out_movement_id_of_vehicle_that_left integer(int64)

            Only when rate type is FLAT: Checkout movement ID of the vehicle that left, facilitating this vehicle to take a reserved spot in yard.

        • billable_days integer(int32) Required

          Total number of days billed across all vehicle visits

      • flat_billing object

        Summary of flat billing for a specific vehicle type

        Additional properties are allowed.

        Hide flat_billing attributes Show flat_billing attributes object
        • invoice_lines array[object] Required

          List of vehicle invoice lines

          Details of an individual line in the invoice for a specific vehicle

          Hide invoice_lines attributes Show invoice_lines attributes object
          • vehicle_number string Required

            Vehicle number

          • check_in_before_billing_period boolean Required

            Whether the vehicle was checked in before the billing period

          • check_in_date_time Required

            Check-in timestamp for the vehicle

          • check_out_date_time

            Check-out timestamp for the vehicle

          • check_out_after_billing_period boolean Required

            Whether the vehicle checked out after the billing period

          • billable_start_date_time Required

            Start of the billable period for this vehicle

          • billable_end_date_time Required

            End of the billable period for this vehicle

          • grace_period Required

            Grace period info

          • billable_days integer(int32) Required

            Number of days the vehicle is billable in Yard. It takes account for the grace period. Note that in rate type FLAT overageDays represents the actual days the vehicle will be billed, taken into account the time it was on a reserved spot

          • spot_number integer(int32)

            Only when rate type is FLAT: Reserved spot number if applicable

          • overage_days integer(int32)

            Only when rate type is FLAT: The actual days the vehicle will be billed using the overage rate

          • took_reserved_spot_at_check_in boolean

            Only when rate type is FLAT: Flag to indicate if vehicle claimed a reserved spot upon check-in

          • took_reserved_spot_that_became_available_while_in_yard boolean

            Only when rate type is FLAT: Flag to indicate if vehicle claimed a reserved spot that became available while it was in yard.

          • vehicle_number_that_left string

            Only when rate type is FLAT: Vehicle number of the vehicle that left, facilitating this vehicle to take a reserved spot in yard.

          • check_out_movement_id_of_vehicle_that_left integer(int64)

            Only when rate type is FLAT: Checkout movement ID of the vehicle that left, facilitating this vehicle to take a reserved spot in yard.

        • amount_flat_only number Required

          Amount charged for flat billing

        • overage_days integer(int32) Required

          Number of days exceeding the flat rate across all vehicle visits

        • overage_amount number Required

          Amount charged for exceeding flat rate

      • amount number Required

        The total amount applicable for this vehicle type

    • trailers_missing_checkin_section object

      Section with all registered check outs without a check ins for a specific vehicle type

      Additional properties are allowed.

      Hide trailers_missing_checkin_section attribute Show trailers_missing_checkin_section attribute object
      • missing_checkin_invoice_lines array[object]

        List of vehicles with a registered check outs without a check in

        Details of an individual line in the invoice for a specific vehicle

        Hide missing_checkin_invoice_lines attributes Show missing_checkin_invoice_lines attributes object
        • check_out_date_time Required

          Check-out timestamp for the vehicle without a Check in

        • vehicle_number string Required

          Vehicle number

    • adjustments_section object

      Summary of adjustments applied to the invoice

      Additional properties are allowed.

      Hide adjustments_section attributes Show adjustments_section attributes object
      • adjustments array[object]

        List of adjustments made to the invoice

        Details of an individual adjustment in the invoice

        Hide adjustments attributes Show adjustments attributes object
        • id integer(int64)

          Unique identifier for the adjustment

        • period_code string

          Code representing the billing period in which the adjustment was made. (null means a global adjustment)

        • description string

          Detailed description of the adjustment

        • amount number

          Total amount adjusted in this individual adjustment

      • amount number

        The total amount adjusted in the invoice

    • total_amount number

      The total amount billed in this invoice

    • currency string

      The currency used in this invoice

  • 400 application/json

    Bad Request already exists, eg. tried to generate an invoice for a yard, carrier and period when it already exists (Use PUT method if you want to automatically replace it)

  • 412 application/json

    Bad Request Conflict, eg. tried to generate an invoice for a yard when is disabled by config

  • 409 application/json

    Bad Request Precondition Failed, eg. tried to generate an invoice for a yard/carrier when config is missing

  • 401

    Not Authorized

  • 403

    Not Allowed

POST /api/billing/invoice/yard/{yardId}/carrier/{carrierId}/periodCode/{periodCode}
curl \
 --request POST 'https://api-dev.gatego.io/api/billing/invoice/yard/{yardId}/carrier/{carrierId}/periodCode/{periodCode}'
Response examples (200)
{
  "id": 12345,
  "yard_id": 67890,
  "carrier_id": 11223,
  "invoice_number": "IN23456",
  "invoice_date": "2022-01-01",
  "period_code": "202401",
  "period_start": "2022-01-01T00:00:00Z",
  "period_end": "2022-01-31T23:59:59Z",
  "truck_config": {
    "rate_type": "FLAT",
    "flat_billing": {
      "rate_per_month": "500.00",
      "spots": 8,
      "overage_rate_per_day_and_spot": "20.00",
      "grace_period": "PT1H",
      "day_calculation": "MODE_24HOUR_ROUNDING"
    },
    "daily_billing": {
      "rate_per_day": "20.00",
      "grace_period": "PT1H",
      "day_calculation": "MODE_24HOUR_ROUNDING"
    }
  },
  "trucks_section": {
    "daily_billing": {
      "invoice_lines": [
        {
          "vehicle_number": "VH12345",
          "check_in_before_billing_period": true,
          "check_in_date_time": "2022-01-01T08:00:00Z",
          "check_out_date_time": "2022-01-05T20:00:00Z",
          "check_out_after_billing_period": true,
          "billable_start_date_time": "2022-01-01T08:00:00Z",
          "billable_end_date_time": "2022-01-05T20:00:00Z",
          "billable_days": 5,
          "spot_number": 52,
          "overage_days": 0,
          "took_reserved_spot_at_check_in": true,
          "took_reserved_spot_that_became_available_while_in_yard": true,
          "vehicle_number_that_left": "string",
          "check_out_movement_id_of_vehicle_that_left": 42
        }
      ],
      "billable_days": 165
    },
    "flat_billing": {
      "invoice_lines": [
        {
          "vehicle_number": "VH12345",
          "check_in_before_billing_period": true,
          "check_in_date_time": "2022-01-01T08:00:00Z",
          "check_out_date_time": "2022-01-05T20:00:00Z",
          "check_out_after_billing_period": true,
          "billable_start_date_time": "2022-01-01T08:00:00Z",
          "billable_end_date_time": "2022-01-05T20:00:00Z",
          "billable_days": 5,
          "spot_number": 52,
          "overage_days": 0,
          "took_reserved_spot_at_check_in": true,
          "took_reserved_spot_that_became_available_while_in_yard": true,
          "vehicle_number_that_left": "string",
          "check_out_movement_id_of_vehicle_that_left": 42
        }
      ],
      "amount_flat_only": 5000.0,
      "overage_days": 62,
      "overage_amount": 500.0
    },
    "amount": 42.0
  },
  "trucks_missing_checkin_section": {
    "missing_checkin_invoice_lines": [
      {
        "check_out_date_time": "2022-01-05T20:00:00Z",
        "vehicle_number": "VH12345"
      }
    ]
  },
  "trailer_config": {
    "rate_type": "FLAT",
    "flat_billing": {
      "rate_per_month": "500.00",
      "spots": 8,
      "overage_rate_per_day_and_spot": "20.00",
      "grace_period": "PT1H",
      "day_calculation": "MODE_24HOUR_ROUNDING"
    },
    "daily_billing": {
      "rate_per_day": "20.00",
      "grace_period": "PT1H",
      "day_calculation": "MODE_24HOUR_ROUNDING"
    }
  },
  "trailers_section": {
    "daily_billing": {
      "invoice_lines": [
        {
          "vehicle_number": "VH12345",
          "check_in_before_billing_period": true,
          "check_in_date_time": "2022-01-01T08:00:00Z",
          "check_out_date_time": "2022-01-05T20:00:00Z",
          "check_out_after_billing_period": true,
          "billable_start_date_time": "2022-01-01T08:00:00Z",
          "billable_end_date_time": "2022-01-05T20:00:00Z",
          "billable_days": 5,
          "spot_number": 52,
          "overage_days": 0,
          "took_reserved_spot_at_check_in": true,
          "took_reserved_spot_that_became_available_while_in_yard": true,
          "vehicle_number_that_left": "string",
          "check_out_movement_id_of_vehicle_that_left": 42
        }
      ],
      "billable_days": 165
    },
    "flat_billing": {
      "invoice_lines": [
        {
          "vehicle_number": "VH12345",
          "check_in_before_billing_period": true,
          "check_in_date_time": "2022-01-01T08:00:00Z",
          "check_out_date_time": "2022-01-05T20:00:00Z",
          "check_out_after_billing_period": true,
          "billable_start_date_time": "2022-01-01T08:00:00Z",
          "billable_end_date_time": "2022-01-05T20:00:00Z",
          "billable_days": 5,
          "spot_number": 52,
          "overage_days": 0,
          "took_reserved_spot_at_check_in": true,
          "took_reserved_spot_that_became_available_while_in_yard": true,
          "vehicle_number_that_left": "string",
          "check_out_movement_id_of_vehicle_that_left": 42
        }
      ],
      "amount_flat_only": 5000.0,
      "overage_days": 62,
      "overage_amount": 500.0
    },
    "amount": 42.0
  },
  "trailers_missing_checkin_section": {
    "missing_checkin_invoice_lines": [
      {
        "check_out_date_time": "2022-01-05T20:00:00Z",
        "vehicle_number": "VH12345"
      }
    ]
  },
  "adjustments_section": {
    "adjustments": [
      {
        "id": 42,
        "period_code": "string",
        "description": "string",
        "amount": 42.0
      }
    ],
    "amount": 42.0
  },
  "total_amount": 42.0,
  "currency": "USD"
}
Response examples (400)
{
  "error_code": "bad-request-already-exists"
}
Response examples (412)
{
  "error_code": "bad-request-billing-config-disabled"
}
Response examples (409)
{
  "error_code": "bad-request-billing-config-missing"
}