Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # frozen_string_literal: true
- require "swagger_helper"
- describe "Shop API relocations" do
- before :all do
- @password = Faker::Internet.password(10, 20, true)
- @user = create(:user, password: @password)
- @company = create(:company)
- @shop = create(:shop, company_id: @company.id)
- @user_company = create(:user_company, user_id: @user.id, company_id: @company.id)
- @user_shop = create(:user_shop, user_id: @user.id, shop_id: @shop.id)
- @user.set_company_admin_accesses(@company.id)
- end
- ### INDEX ###
- path "/companies/{company_id}/shops/{shop_id}/relocations" do
- get "Get relocations list" do
- tags "Relocations"
- security [bearerAuth: {}]
- consumes "application/json"
- parameter name: :company_id, in: :path, type: :string, format: :uuid
- parameter name: :shop_id, in: :path, type: :string, format: :uuid
- parameter name: :status, in: :query, type: :string, enum: ["saved", "deleted"]
- parameter name: :from_date, in: :query, type: :string, format: :date
- parameter name: :to_date, in: :query, type: :string, format: :date
- parameter name: :sender_stock_id, in: :query, type: :string, format: :uuid
- parameter name: :receiver_stock_id, in: :query, typr: :string, format: :uuid
- parameter name: :user_id, in: :query, type: :string, format: :uuid
- parameter name: :sort, in: :query, type: :string, enum: ["created_at", "number"]
- parameter name: :asc, in: :query, type: :string, enum: ["1", "0"]
- parameter name: :page, in: :query, type: :integer
- response "200", "List of relocations" do
- schema type: :object,
- required: [:data],
- properties: {
- data: {
- type: :object,
- required: [:relocations, :total, :total_cost, :total_additional_cost],
- properties: {
- relocations: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :number, :date, :user_id, :user_name, :sender_stock_id, :sender_stock_name, :receiver_stock_id, :receiver_stock_name, :total_cost, :additional_cost, :total],
- properties: {
- id: { type: :string, format: :uuid },
- number: { type: :string },
- date: { type: :string, format: "date-time" },
- user_id: { type: :string, format: :uuid },
- user_name: { type: :string },
- sender_stock_id: { type: :string, format: :uuid },
- sender_stock_name: { type: :string },
- receiver_stock_id: { type: :string, format: :uuid },
- receiver_stock_name: { type: :string },
- total_cost: { type: :number, format: :float },
- additional_cost: { type: :number, format: :float },
- total: { type: :number, format: :float }
- }
- }
- },
- total: { type: :number, format: :float },
- total_cost: { type: :number, format: :float },
- total_additional_cost: { type: :number, format: :float },
- meta: {
- type: :object,
- required: [:current_page, :total_pages, :limit_value, :total_items, :mapping_id, :mapping_columns],
- properties: {
- current_page: { type: :integer, format: :int32 },
- total_pages: { type: :integer, format: :int32 },
- limit_value: { type: :integer, format: :int32 },
- total_items: { type: :integer, format: :int32 },
- mapping_id: { type: :string },
- mapping_columns: {
- type: :array,
- items: {
- type: :object,
- required: [:prop, :width, :visible],
- properties: {
- prop: { type: :string },
- width: { type: :number, format: :float },
- visible: { type: :boolean }
- }
- }
- }
- }
- }
- }
- }
- }
- it "get list of relocations" do
- headers = { "Accept" => "application/json", "Content-Type" => "application/json" }
- auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, @user)
- get "/v1/companies/#{@company.id}/shops/#{@shop.id}/relocations?sort=created_at&asc=1", headers: auth_headers
- expect(response).to have_http_status(200)
- end
- end
- end
- end
- ### NEW ###
- path "/companies/{company_id}/shops/{shop_id}/relocations/new" do
- get "info for create relocation " do
- tags "Relocations"
- security [bearerAuth: {}]
- consumes "application/json"
- parameter name: :company_id, in: :path, type: :string, format: :uuid
- parameter name: :shop_id, in: :path, type: :string, format: :uuid
- response "200", "info for create" do
- schema type: :object,
- required: [:data],
- properties: {
- data: {
- type: :object,
- required: [:stocks, :meta],
- properties: {
- stocks: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :name],
- properties: {
- id: { type: :string, format: :uuid },
- name: { type: :string }
- }
- }
- },
- meta: {
- type: :object,
- required: [:mapping_id, :mapping_columns],
- properties: {
- mapping_id: { type: :string },
- mapping_columns: {
- type: :array,
- items: {
- type: :object,
- required: [:prop, :width, :visible],
- properties: {
- prop: { type: :string },
- width: { type: :number, format: :float },
- visible: { type: :boolean }
- }
- }
- }
- }
- }
- }
- }
- }
- it "info for create" do
- headers = { "Accept" => "application/json", "Content-Type" => "application/json" }
- auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, @user)
- get "/v1/companies/#{@company.id}/shops/#{@shop.id}/relocations/new", headers: auth_headers
- expect(response).to have_http_status(200)
- end
- end
- end
- end
- ### SEARCH ###
- path "/companies/{company_id}/shops/{shop_id}/relocations/search" do
- get "Search variants" do
- tags "Relocations"
- security [bearerAuth: {}]
- consumes "application/json"
- parameter name: :company_id, in: :path, type: :string, format: :uuid
- parameter name: :shop_id, in: :path, type: :string, format: :uuid
- parameter name: :date, in: :query, type: :string, format: :date
- parameter name: :sender_stock_id, in: :query, type: :string, format: :uuid
- parameter name: :q, in: :query, type: :string
- response "200", "Search variants" do
- schema type: :object,
- required: [:data],
- properties: {
- data: {
- type: :object,
- required: [:variants],
- properties: {
- variants: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :product_id, :name, :sku, :unit_id, :category_id, :shop_tax_id, :product_vendor_codes, :product_barcodes, :product_packs, :active_invoices],
- properties: {
- id: { type: :string, format: :uuid },
- product_id: { type: :string, format: :uuid },
- name: { type: :string },
- sku: { type: :string },
- unit_id: { type: :string, format: :uuid },
- category_id: { type: :string, format: :uuid },
- shop_tax_id: { type: :string, format: :uuid },
- product_vendor_codes: {
- type: :array,
- items: {
- type: :object,
- required: [:vendor_code],
- properties: {
- vendor_code: { type: :string }
- }
- }
- },
- product_barcodes: {
- type: :array,
- items: {
- type: :object,
- required: [ :barcode_type, :barcode ],
- properties: {
- barcode_type: { type: :string },
- barcode: { type: :string }
- }
- }
- },
- product_packs: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :name, :count],
- properties: {
- id: { type: :string, format: :uuid },
- name: { type: :string },
- count: { type: :number, format: :float }
- }
- }
- },
- active_invoices: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :stock_id, :price, :balance, :expiration_date, :document_date, :document_number, :document_type],
- properties: {
- id: { type: :string, format: :uuid },
- stock_id: { type: :string, format: :uuid },
- price: { type: :number, format: :float },
- balance: { type: :number, format: :float },
- expiration_date: { type: :string, format: "date-time" },
- document_date: { type: :string, format: "date-time" },
- document_number: { type: :integer, format: :int32 },
- document_type: { type: :string, enum: ["relocation", "inventory", "invoice"] }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- it "get list of variant by search query" do
- headers = { "Accept" => "application/json", "Content-Type" => "application/json" }
- auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, @user)
- get "/v1/companies/#{@company.id}/shops/#{@shop.id}/relocations/search", headers: auth_headers
- expect(response).to have_http_status(200)
- end
- end
- end
- end
- ### CREATE ###
- path "/companies/{company_id}/shops/{shop_id}/relocations" do
- post "Create relocation " do
- tags "Relocations"
- security [bearerAuth: {}]
- consumes "application/json"
- parameter name: :company_id, in: :path, type: :string, format: :uuid
- parameter name: :shop_id, in: :path, type: :string, format: :uuid
- parameter name: :body, in: :body, schema: {
- type: :object,
- required: [:relocation],
- properties: {
- relocation: {
- type: :object,
- required: [:date, :sender_stock_id, :receiver_stock_id, :note, :relocation_products],
- properties: {
- date: { type: :string, format: "date-time" },
- sender_stock_id: { type: :string, format: :uuid },
- receiver_stock_id: { type: :string, format: :uuid },
- note: { type: :string },
- relocation_products: {
- type: :array,
- items: {
- type: :object,
- required: [:variant_id, :object_product_id, :count, :additional_cost],
- properties: {
- variant_id: { type: :string, format: :uuid },
- object_product_id: { type: :string, format: :uuid },
- product_pack_id: { type: :string, format: :uuid },
- count: { type: :number, format: :float },
- additional_cost: { type: :number, format: :float }
- }
- }
- }
- }
- }
- }
- }
- response "201", "create relocation" do
- schema type: :object,
- required: [:data],
- properties: {
- data: {
- type: :object,
- required: [:relocation],
- properties: {
- relocation: {
- type: :object,
- required: [:id, :number, :sender_stock_id, :sender_stock_name, :receiver_stock_id, :receiver_stock_name, :date, :user_id, :user_name, :status, :total_cost, :additional_cost, :total, :note, :relocation_products],
- properties: {
- id: { type: :string, format: :uuid },
- number: { type: :integer },
- sender_stock_id: { type: :string, format: :uuid },
- sender_stock_name: { type: :string },
- receiver_stock_id: { type: :string, format: :uuid },
- receiver_stock_name: { type: :string },
- date: { type: :string, format: "date-time" },
- user_id: { type: :string, format: :uuid },
- user_name: { type: :string },
- status: { type: :string },
- total_cost: { type: :number, format: :float },
- additional_cost: { type: :number, format: :float },
- total: { type: :number, format: :float },
- note: { type: :string },
- relocation_products: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :variant_id, :product_id, :name, :sku, :unit_id, :category_id, :shop_tax_id, :product_pack_id, :count, :amount, :purchase_price, :additional_cost, :document_price, :currency_id, :expiration_date, :balance, :product_vendor_codes, :product_barcodes, :product_packs],
- properties: {
- id: { type: :string, format: :uuid },
- variant_id: { type: :string, format: :uuid },
- product_id: { type: :string, format: :uuid },
- name: { type: :string },
- sku: { type: :string },
- unit_id: { type: :string, format: :uuid },
- category_id: { type: :string, format: :uuid },
- shop_tax_id: { type: :string, format: :uuid },
- product_pack_id: { type: :string, format: :uuid },
- count: { type: :number, format: :float },
- amount: { type: :number, format: :float },
- purchase_price: { type: :number, format: :float },
- additional_cost: { type: :number, format: :float },
- document_price: { type: :number, format: :float },
- currency_id: { type: :string, format: :uuid },
- expiration_date: { type: :string, format: "date-time" },
- balance: { type: :number, format: :float },
- product_vendor_codes: {
- type: :array,
- items: {
- type: :object,
- required: [:vendor_code],
- properties: {
- vendor_code: { type: :string }
- }
- }
- },
- product_barcodes: {
- type: :array,
- items: {
- type: :object,
- required: [:barcode_type, :barcode],
- properties: {
- barcode_type: { type: :string },
- barcode: { type: :string }
- }
- }
- },
- product_packs: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :name, :count],
- properties: {
- id: { type: :string, format: :uuid },
- name: { type: :string },
- count: { type: :integer }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- it "create relocation " do
- headers = { "Accept" => "application/json", "Content-Type" => "application/json" }
- auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, @user)
- # post "/v1/companies/#{@company.id}/shops/#{@shop.id}/relocations", headers: auth_headers
- # expect(response).to have_http_status(200)
- end
- end
- response "code 453", "invoice object not found" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:object_product_id],
- properties: {
- object_product_id: { type: :string, format: :uuid }
- }
- }
- }
- }
- }
- }
- it "returns code 453" do
- end
- end
- response "code 454", "count couldn't be less than 1" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:object_product_id],
- properties: {
- object_product_id: { type: :string, format: :uuid }
- }
- }
- }
- }
- }
- }
- it "returns code 454" do
- end
- end
- response "code 455", "balance less than requested value" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:invoice_number, :invoice_date, :object_product_id, :balance ],
- properties: {
- invoice_number: { type: :integer, format: :int32 },
- invoice_date: { type: :string, format: "date-time" },
- object_product_id: { type: :string, format: :uuid },
- balance: { type: :number, format: :float }
- }
- }
- }
- }
- }
- }
- it "returns code 455" do
- end
- end
- response "code 456", "variant not found" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:variant_id ],
- properties: {
- variant_id: { type: :string, format: :uuid }
- }
- }
- }
- }
- }
- }
- it "returns code 456" do
- end
- end
- response "code 457", "relocation couldn't be before shop created" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object
- }
- }
- }
- }
- }
- it "returns code 457" do
- end
- end
- response "code 458", "broduct-batch not unique" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:variant_id, :object_product_id ],
- properties: {
- variant_id: { type: :string, format: :uuid },
- object_product_id: { type: :string, format: :uuid }
- }
- }
- }
- }
- }
- }
- it "returns code 458" do
- end
- end
- end
- end
- ### SHOW ###
- path "/companies/{company_id}/shops/{shop_id}/relocations/{id}" do
- get "relocation info" do
- tags "Relocations"
- security [bearerAuth: {}]
- consumes "application/json"
- parameter name: :company_id, in: :path, type: :string, format: :uuid
- parameter name: :shop_id, in: :path, type: :string, format: :uuid
- parameter name: :id, in: :path, type: :string, format: :uuid
- response "200", "relocation info" do
- schema type: :object,
- required: [:data],
- properties: {
- data: {
- type: :object,
- required: [:write_off, :meta],
- properties: {
- relocation: {
- type: :object,
- required: [:id, :number, :sender_stock_id, :sender_stock_name, :receiver_stock_id, :receiver_stock_name, :date, :user_id, :user_name, :status, :total_cost, :additional_cost, :total, :note, :relocation_products],
- properties: {
- id: { type: :string, format: :uuid },
- number: { type: :integer },
- sender_stock_id: { type: :string, format: :uuid },
- sender_stock_name: { type: :string },
- receiver_stock_id: { type: :string, format: :uuid },
- receiver_stock_name: { type: :string },
- date: { type: :string, format: "date-time" },
- user_id: { type: :string, format: :uuid },
- user_name: { type: :string },
- status: { type: :string },
- total_cost: { type: :number, format: :float },
- additional_cost: { type: :number, format: :float },
- total: { type: :number, format: :float },
- note: { type: :string },
- relocation_products: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :variant_id, :product_id, :name, :sku, :unit_id, :category_id, :shop_tax_id, :product_pack_id, :count, :amount, :purchase_price, :additional_cost, :document_price, :currency_id, :expiration_date, :balance, :product_vendor_codes, :product_barcodes, :product_packs],
- properties: {
- id: { type: :string, format: :uuid },
- variant_id: { type: :string, format: :uuid },
- product_id: { type: :string, format: :uuid },
- name: { type: :string },
- sku: { type: :string },
- unit_id: { type: :string, format: :uuid },
- category_id: { type: :string, format: :uuid },
- shop_tax_id: { type: :string, format: :uuid },
- product_pack_id: { type: :string, format: :uuid },
- count: { type: :number, format: :float },
- amount: { type: :number, format: :float },
- purchase_price: { type: :number, format: :float },
- additional_cost: { type: :number, format: :float },
- document_price: { type: :number, format: :float },
- currency_id: { type: :string, format: :uuid },
- expiration_date: { type: :string, format: "date-time" },
- balance: { type: :number, format: :float },
- product_vendor_codes: {
- type: :array,
- items: {
- type: :object,
- required: [:vendor_code],
- properties: {
- vendor_code: { type: :string }
- }
- }
- },
- product_barcodes: {
- type: :array,
- items: {
- type: :object,
- required: [:barcode_type, :barcode],
- properties: {
- barcode_type: { type: :string },
- barcode: { type: :string }
- }
- }
- },
- product_packs: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :name, :count],
- properties: {
- id: { type: :string, format: :uuid },
- name: { type: :string },
- count: { type: :integer }
- }
- }
- }
- }
- }
- }
- }
- },
- meta: {
- type: :object,
- required: [:mapping_id, :mapping_columns],
- properties: {
- mapping_id: { type: :string },
- mapping_columns: {
- type: :array,
- items: {
- type: :object,
- required: [:prop, :width, :visible],
- properties: {
- prop: { type: :string },
- width: { type: :number, format: :float },
- visible: { type: :boolean }
- }
- }
- }
- }
- }
- }
- }
- }
- it "relocation info" do
- headers = { "Accept" => "application/json", "Content-Type" => "application/json" }
- auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, @user)
- # get "/v1/companies/#{@company.id}/shops/#{@shop.id}/write_offs/#{@write_offf.id}", headers: auth_headers
- # expect(response).to have_http_status(200)
- end
- end
- end
- end
- ### UPDATE ###
- path "/companies/{company_id}/shops/{shop_id}/relocations/{id}" do
- put "Update relocation " do
- tags "Relocations"
- security [bearerAuth: {}]
- consumes "application/json"
- parameter name: :company_id, in: :path, type: :string, format: :uuid
- parameter name: :shop_id, in: :path, type: :string, format: :uuid
- parameter name: :id, in: :path, type: :string, format: :uuid
- parameter name: :body, in: :body, schema: {
- type: :object,
- required: [:relocation],
- properties: {
- relocation: {
- type: :object,
- required: [:date, :note, :relocation_products],
- properties: {
- date: { type: :string, format: "date-time" },
- note: { type: :string },
- relocation_products: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :variant_id, :object_product_id, :count, :additional_cost],
- properties: {
- id: { type: :string, format: :uuid },
- variant_id: { type: :string, format: :uuid },
- object_product_id: { type: :string, format: :uuid },
- product_pack_id: { type: :string, format: :uuid },
- count: { type: :number, format: :float },
- additional_cost: { type: :number, format: :float }
- }
- }
- }
- }
- }
- }
- }
- response "201", "update relocation" do
- schema type: :object,
- required: [:data],
- properties: {
- data: {
- type: :object,
- required: [:relocation],
- properties: {
- relocation: {
- type: :object,
- required: [:id, :number, :sender_stock_id, :sender_stock_name, :receiver_stock_id, :receiver_stock_name, :date, :user_id, :user_name, :status, :total_cost, :additional_cost, :total, :note, :relocation_products],
- properties: {
- id: { type: :string, format: :uuid },
- number: { type: :integer },
- sender_stock_id: { type: :string, format: :uuid },
- sender_stock_name: { type: :string },
- receiver_stock_id: { type: :string, format: :uuid },
- receiver_stock_name: { type: :string },
- date: { type: :string, format: "date-time" },
- user_id: { type: :string, format: :uuid },
- user_name: { type: :string },
- status: { type: :string },
- total_cost: { type: :number, format: :float },
- additional_cost: { type: :number, format: :float },
- total: { type: :number, format: :float },
- note: { type: :string },
- relocation_products: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :variant_id, :product_id, :name, :sku, :unit_id, :category_id, :shop_tax_id, :product_pack_id, :count, :amount, :purchase_price, :additional_cost, :document_price, :currency_id, :expiration_date, :balance, :product_vendor_codes, :product_barcodes, :product_packs],
- properties: {
- id: { type: :string, format: :uuid },
- variant_id: { type: :string, format: :uuid },
- product_id: { type: :string, format: :uuid },
- name: { type: :string },
- sku: { type: :string },
- unit_id: { type: :string, format: :uuid },
- category_id: { type: :string, format: :uuid },
- shop_tax_id: { type: :string, format: :uuid },
- product_pack_id: { type: :string, format: :uuid },
- count: { type: :number, format: :float },
- amount: { type: :number, format: :float },
- purchase_price: { type: :number, format: :float },
- additional_cost: { type: :number, format: :float },
- document_price: { type: :number, format: :float },
- currency_id: { type: :string, format: :uuid },
- expiration_date: { type: :string, format: "date-time" },
- balance: { type: :number, format: :float },
- product_vendor_codes: {
- type: :array,
- items: {
- type: :object,
- required: [:vendor_code],
- properties: {
- vendor_code: { type: :string }
- }
- }
- },
- product_barcodes: {
- type: :array,
- items: {
- type: :object,
- required: [:barcode_type, :barcode],
- properties: {
- barcode_type: { type: :string },
- barcode: { type: :string }
- }
- }
- },
- product_packs: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :name, :count],
- properties: {
- id: { type: :string, format: :uuid },
- name: { type: :string },
- count: { type: :integer }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- it "update relocation " do
- headers = { "Accept" => "application/json", "Content-Type" => "application/json" }
- auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, @user)
- # put "/v1/companies/#{@company.id}/shops/#{@shop.id}/relocations/#{@relocation.id}", headers: auth_headers
- # expect(response).to have_http_status(200)
- end
- end
- response "code 453", "invoice object not found" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:object_product_id],
- properties: {
- object_product_id: { type: :string, format: :uuid }
- }
- }
- }
- }
- }
- }
- it "returns code 453" do
- end
- end
- response "code 454", "count couldn't be less than 1" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:object_product_id],
- properties: {
- object_product_id: { type: :string, format: :uuid }
- }
- }
- }
- }
- }
- }
- it "returns code 454" do
- end
- end
- response "code 455", "balance less than requested value" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:invoice_number, :invoice_date, :object_product_id, :balance ],
- properties: {
- invoice_number: { type: :integer, format: :int32 },
- invoice_date: { type: :string, format: "date-time" },
- object_product_id: { type: :string, format: :uuid },
- balance: { type: :number, format: :float }
- }
- }
- }
- }
- }
- }
- it "returns code 455" do
- end
- end
- response "code 456", "variant not found" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:variant_id ],
- properties: {
- variant_id: { type: :string, format: :uuid }
- }
- }
- }
- }
- }
- }
- it "returns code 456" do
- end
- end
- response "code 457", "relocation couldn't be before shop created" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object
- }
- }
- }
- }
- }
- it "returns code 457" do
- end
- end
- response "code 458", "broduct-batch not unique" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:variant_id, :object_product_id ],
- properties: {
- variant_id: { type: :string, format: :uuid },
- object_product_id: { type: :string, format: :uuid }
- }
- }
- }
- }
- }
- }
- it "returns code 458" do
- end
- end
- response "code 459", "relocation object id not found" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:id],
- properties: {
- id: { type: :string, format: :uuid }
- }
- }
- }
- }
- }
- }
- it "returns code 459" do
- end
- end
- response "code 461", "can't delete relocation product balance is diferent from initial" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:balance, :count_in_units],
- properties: {
- balance: { type: :number, format: :float },
- count_in_units: { type: :number, format: :float }
- }
- }
- }
- }
- }
- }
- it "returns code 461" do
- end
- end
- response "code 463", "deleted relocation cannot be changed" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object
- }
- }
- }
- }
- }
- it "returns code 463" do
- end
- end
- end
- end
- ### DESTROY ###
- path "/companies/{company_id}/shops/{shop_id}/relocations/{id}" do
- delete "delete relocation" do
- tags "Relocations"
- security [bearerAuth: {}]
- consumes "application/json"
- parameter name: :company_id, in: :path, type: :string, format: :uuid
- parameter name: :shop_id, in: :path, type: :string, format: :uuid
- parameter name: :id, in: :path, type: :string, format: :uuid
- response "204", "delete relocation" do
- it "delete relocation" do
- headers = { "Accept" => "application/json", "Content-Type" => "application/json" }
- auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, @user)
- # delete "/v1/companies/#{@company.id}/shops/#{@shop.id}/relocations/#{@relocation.id}",
- # headers: auth_headers
- # expect(response).to have_http_status(204)
- end
- end
- response "code 451", "can't delete relocation products moved by another relocation/write off" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:document_type, :document_id, :document_date, :document_number ],
- properties: {
- document_type: { type: :string },
- document_id: { type: :string, format: :uuid },
- document_date: { type: :string, format: "date-time" },
- document_number: { type: :integer, format: :int32 }
- }
- }
- }
- }
- }
- }
- it "returns code 451" do
- end
- end
- response "code 452", "can't delete relocation balance is different from initial" do
- schema type: :object,
- required: [:errors],
- properties: {
- errors: {
- type: :array,
- items: {
- type: :object,
- required: [:id, :code, :title, :data],
- properties: {
- id: { type: :string },
- code: { type: :number },
- title: { type: :string },
- data: {
- type: :object,
- required: [:variant_id, :object_product_id, :balance, :unit_count ],
- properties: {
- variant_id: { type: :string, format: :uuid },
- object_product_id: { type: :string, format: :uuid },
- balance: { type: :number, format: :float },
- unit_count: { type: :number, format: :float }
- }
- }
- }
- }
- }
- }
- it "returns code 452" do
- end
- end
- end
- end
- ### EXPORT INDEX ###
- path "/companies/{company_id}/shops/{shop_id}/relocations/export" do
- get "export relocations" do
- tags "Relocations"
- security [bearerAuth: {}]
- consumes "application/json"
- parameter name: :company_id, in: :path, type: :string, format: :uuid
- parameter name: :shop_id, in: :path, type: :string, format: :uuid
- parameter name: :status, in: :query, type: :string, enum: ["saved", "deleted"]
- parameter name: :from_date, in: :query, type: :string, format: :date
- parameter name: :to_date, in: :query, type: :string, format: :date
- parameter name: :sender_stock_id, in: :query, type: :string, format: :uuid
- parameter name: :receiver_stock_id, in: :query, typr: :string, format: :uuid
- parameter name: :user_id, in: :query, type: :string, format: :uuid
- response "200", "export relocations" do
- schema type: :string, format: :binary
- it "export relocations" do
- headers = { "Accept" => "application/json", "Content-Type" => "application/json" }
- auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, @user)
- end
- end
- end
- end
- ### EXPORT ###
- path "/companies/{company_id}/shops/{shop_id}/relocations/{id}/export" do
- get "export relocation" do
- tags "Relocations"
- security [bearerAuth: {}]
- consumes "application/json"
- parameter name: :company_id, in: :path, type: :string, format: :uuid
- parameter name: :shop_id, in: :path, type: :string, format: :uuid
- parameter name: :id, in: :path, type: :string, format: :uuid
- response "200", "export relocation" do
- schema type: :string, format: :binary
- it "export relocation" do
- headers = { "Accept" => "application/json", "Content-Type" => "application/json" }
- auth_headers = Devise::JWT::TestHelpers.auth_headers(headers, @user)
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement