Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Wiki Wiki
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 52
    • Issues 52
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CP - Planta
  • WikiWiki
  • Wiki
  • backend_stock

Last edited by ESKieroff Oct 20, 2024
Page history

backend_stock

Home Escopo Processo Design/Mockups Gerência Estudos Arquitetura Contratos BD Qualidade Configuração Instalação Instruções Utilização Analytics Infraestrutura Dicas

Stock - estoque de lotes

fields:

export class Stock {
  id: number;
  document_number: string;
  document_date: Date;
  stock_moviment: Stock_Moviment;
  stock_items: StockItem[];
}
export class StockItem {
  id: number;
  stock_id: number;
  sequence: number;
  product_id: number;
  quantity: number;
  unit_price: number;
  total_price: number;
  lote: string;
  expiration: Date;
  persons: number;
  costumers: number;
  stock_location_id: number;
  observation: string;
}

endpoints:

FindAll

GET http://localhost:3000/stock/

response:

[
  {
    "id": 1,
    "document_number": "NFE123",
    "document_date": "2024-09-01T09:00:00.000Z",
    "stock_moviment": "INPUT",
    "is_balance": false,
    "document_type": "nota entrada",
    "created_at": "18/10/2024",
    "updated_at": "18/10/2024",
    "created_by": null,
    "updated_by": null,
    "stock_items": [
      {
        "id": 1,
        "product_id": 1,
        "lote": "LoteA123",
        "quantity": 100,
        "stock_id": 1,
        "sequence": 1,
        "created_at": "2024-10-18T03:09:25.922Z",
        "updated_at": "2024-10-18T03:09:25.922Z"
      },
      {
        "id": 7,
        "product_id": 7,
        "lote": "LoteA123",
        "quantity": 100,
        "stock_id": 1,
        "sequence": 1,
        "created_at": "2024-10-18T03:09:25.922Z",
        "updated_at": "2024-10-18T03:09:25.922Z"
      }
    ]
  },
  {
    "id": 2,
    "document_number": "OP124",
    "document_date": "2024-09-02T10:00:00.000Z",
    "stock_moviment": "INPUT",
    "is_balance": false,
    "document_type": "ordem de produção",
    "created_at": "18/10/2024",
    "updated_at": "18/10/2024",
    "created_by": null,
    "updated_by": null,
    "stock_items": [
      {
        "id": 17,
        "product_id": 9,
        "lote": "LoteKK123",
        "quantity": 100,
        "stock_id": 2,
        "sequence": 1,
        "created_at": "2024-10-18T03:09:25.922Z",
        "updated_at": "2024-10-18T03:09:25.922Z"
      }
    ]
  },
  {
    "id": 3,
    "document_number": "DOC123",
    "document_date": "2024-09-01T09:00:00.000Z",
    "stock_moviment": "OUTPUT",
    "is_balance": false,
    "document_type": "documento entrada",
    "created_at": "18/10/2024",
    "updated_at": "18/10/2024",
    "created_by": null,
    "updated_by": null,
    "stock_items": [
      {
        "id": 9,
        "product_id": 1,
        "lote": "LoteA123",
        "quantity": 20,
        "stock_id": 3,
        "sequence": 1,
        "created_at": "2024-10-18T03:09:25.922Z",
        "updated_at": "2024-10-18T03:09:25.922Z"
      }
      {
        "id": 10,
        "product_id": 2,
        "lote": "LoteC123",
        "quantity": 20,
        "stock_id": 3,
        "sequence": 2,
        "created_at": "2024-10-18T03:09:25.922Z",
        "updated_at": "2024-10-18T03:09:25.922Z"
      }
    ]
  }
]

FindById

GET http://localhost:3000/stock/1

response:

{
  "id": 1,
  "document_number": "NFE123",
  "document_date": "2024-09-01T09:00:00.000Z",
  "stock_moviment": "INPUT",
  "is_balance": false,
  "document_type": "nota entrada",
  "created_at": "18/10/2024",
  "updated_at": "18/10/2024",
  "created_by": null,
  "updated_by": null,
  "stock_items": [
    {
      "id": 1,
      "sequence": 1,
      "products": {
        "id": 1,
        "description": "batata branca",
        "code": "CODE001",
        "sku": "SKU001"
      },
      "lote": "LoteA123",
      "expiration": "2024-12-31T23:59:59.000Z",
      "quantity": 100,
      "unit_price": 10,
      "total_price": 1000,
      "image_link": null,
      "suppliers": null,
      "stock_location": {
        "id": 1,
        "description": "Câmara Fria A"
      },
      "created_at": "2024-10-18T03:09:25.922Z",
      "updated_at": "2024-10-18T03:09:25.922Z"
    },
    {
      "id": 7,
      "sequence": 1,
      "products": {
        "id": 7,
        "description": "uva",
        "code": "CODE007",
        "sku": "SKU006"
      },
      "lote": "LoteA123",
      "expiration": "2024-12-31T23:59:59.000Z",
      "quantity": 100,
      "unit_price": 10,
      "total_price": 1000,
      "image_link": null,
      "suppliers": null,
      "stock_location": {
        "id": 1,
        "description": "Câmara Fria A"
      },
      "created_at": "2024-10-18T03:09:25.922Z",
      "updated_at": "2024-10-18T03:09:25.922Z"
    },
    {
      "id": 8,
      "sequence": 2,
      "products": {
        "id": 8,
        "description": "Batata cubinhos",
        "code": "CODE016",
        "sku": "SKU007"
      },
      "lote": "LoteC123",
      "expiration": "2024-12-31T23:59:59.000Z",
      "quantity": 100,
      "unit_price": 10,
      "total_price": 1000,
      "image_link": null,
      "suppliers": null,
      "stock_location": {
        "id": 1,
        "description": "Câmara Fria A"
      },
      "created_at": "2024-10-18T03:09:25.922Z",
      "updated_at": "2024-10-18T03:09:25.922Z"
    },
    {
      "id": 2,
      "sequence": 2,
      "products": {
        "id": 2,
        "description": "mix de folhas verdes",
        "code": "CODE002",
        "sku": "SKU015"
      },
      "lote": "LoteC123",
      "expiration": "2024-12-31T23:59:59.000Z",
      "quantity": 100,
      "unit_price": 10,
      "total_price": 1000,
      "image_link": null,
      "suppliers": null,
      "stock_location": {
        "id": 1,
        "description": "Câmara Fria A"
      },
      "created_at": "2024-10-18T03:09:25.922Z",
      "updated_at": "2024-10-18T03:09:25.922Z"
    },
    {
      "id": 3,
      "sequence": 3,
      "products": {
        "id": 3,
        "description": "aipim",
        "code": "CODE003",
        "sku": "SKU002"
      },
      "lote": "LoteD456",
      "expiration": "2024-12-15T23:59:59.000Z",
      "quantity": 200,
      "unit_price": 20,
      "total_price": 4000,
      "image_link": null,
      "suppliers": null,
      "stock_location": {
        "id": 3,
        "description": "Pátio"
      },
      "created_at": "2024-10-18T03:09:25.922Z",
      "updated_at": "2024-10-18T03:09:25.922Z"
    },
    {
      "id": 4,
      "sequence": 4,
      "products": {
        "id": 4,
        "description": "mirtilo",
        "code": "CODE004",
        "sku": "SKU003"
      },
      "lote": "LoteE123",
      "expiration": "2024-12-31T23:59:59.000Z",
      "quantity": 100,
      "unit_price": 10,
      "total_price": 1000,
      "image_link": null,
      "suppliers": null,
      "stock_location": {
        "id": 1,
        "description": "Câmara Fria A"
      },
      "created_at": "2024-10-18T03:09:25.922Z",
      "updated_at": "2024-10-18T03:09:25.922Z"
    },
    {
      "id": 5,
      "sequence": 5,
      "products": {
        "id": 5,
        "description": "laranja",
        "code": "CODE005",
        "sku": "SKU004"
      },
      "lote": "LoteF123",
      "expiration": "2024-12-31T23:59:59.000Z",
      "quantity": 100,
      "unit_price": 10,
      "total_price": 1000,
      "image_link": null,
      "suppliers": null,
      "stock_location": {
        "id": 1,
        "description": "Câmara Fria A"
      },
      "created_at": "2024-10-18T03:09:25.922Z",
      "updated_at": "2024-10-18T03:09:25.922Z"
    },
    {
      "id": 6,
      "sequence": 6,
      "products": {
        "id": 6,
        "description": "couve",
        "code": "CODE006",
        "sku": "SKU005"
      },
      "lote": "LoteG456",
      "expiration": "2024-12-15T23:59:59.000Z",
      "quantity": 200,
      "unit_price": 20,
      "total_price": 4000,
      "image_link": null,
      "suppliers": null,
      "stock_location": {
        "id": 3,
        "description": "Pátio"
      },
      "created_at": "2024-10-18T03:09:25.922Z",
      "updated_at": "2024-10-18T03:09:25.922Z"
    }
  ]
}

AllStockLotes

GET http://localhost:3000/stock/batchs

response:

[
  {
    "productId": 1,
    "description": "batata branca",
    "lots": [
      {
        "lote": "P100020",
        "totalQuantity": 200,
        "expiration": "2024-01-01T00:00:00.000Z"
      },
      {
        "lote": "P100019",
        "totalQuantity": 200,
        "expiration": "2024-01-01T00:00:00.000Z"
      },
      {
        "lote": "LoteA123",
        "totalQuantity": 80,
        "expiration": "2024-12-31T23:59:59.000Z"
      },
      {
        "lote": "PD100022",
        "totalQuantity": 0,
        "expiration": "2024-01-01T00:00:00.000Z"
      }
    ]
  },
  {
    "productId": 2,
    "description": "mix de folhas verdes",
    "lots": [
      {
        "lote": "LoteC123",
        "totalQuantity": 80,
        "expiration": "2024-12-31T23:59:59.000Z"
      },
      {
        "lote": "PD100023",
        "totalQuantity": 0,
        "expiration": "2024-01-01T00:00:00.000Z"
      },
      {
        "lote": "P100021",
        "totalQuantity": 200,
        "expiration": "2024-01-01T00:00:00.000Z"
      }
    ]
  },
  {
    "productId": 3,
    "description": "aipim",
    "lots": [
      {
        "lote": "LoteD456",
        "totalQuantity": 180,
        "expiration": "2024-12-15T23:59:59.000Z"
      }
    ]
  },
  {
    "productId": 4,
    "description": "mirtilo",
    "lots": [
      {
        "lote": "LoteE123",
        "totalQuantity": 90,
        "expiration": "2024-12-31T23:59:59.000Z"
      }
    ]
  },
  {
    "productId": 5,
    "description": "laranja",
    "lots": [
      {
        "lote": "LoteF123",
        "totalQuantity": 90,
        "expiration": "2024-12-31T23:59:59.000Z"
      }
    ]
  },
  {
    "productId": 6,
    "description": "couve",
    "lots": [
      {
        "lote": "LoteG456",
        "totalQuantity": 180,
        "expiration": "2024-12-15T23:59:59.000Z"
      }
    ]
  },
  {
    "productId": 7,
    "description": "uva",
    "lots": [
      {
        "lote": "P100013",
        "totalQuantity": 10,
        "expiration": "2024-01-01T00:00:00.000Z"
      },
      {
        "lote": "LoteA123",
        "totalQuantity": 90,
        "expiration": "2024-12-31T23:59:59.000Z"
      },
      {
        "lote": null,
        "totalQuantity": 0,
        "expiration": null
      },
      {
        "lote": "ABRACADABRA",
        "totalQuantity": 0,
        "expiration": "2024-09-01T09:00:00.000Z"
      },
      {
        "lote": "P10001",
        "totalQuantity": 20030,
        "expiration": null
      },
      {
        "lote": "P100011",
        "totalQuantity": 10,
        "expiration": "2024-01-01T00:00:00.000Z"
      },
      {
        "lote": "P100012",
        "totalQuantity": 10,
        "expiration": "2024-01-01T00:00:00.000Z"
      },
      {
        "lote": "PD100014",
        "totalQuantity": 0,
        "expiration": "2024-01-01T00:00:00.000Z"
      }
    ]
  },
  {
    "productId": 8,
    "description": "Batata cubinhos",
    "lots": [
      {
        "lote": "LoteC123",
        "totalQuantity": 90,
        "expiration": "2024-12-31T23:59:59.000Z"
      }
    ]
  },
  {
    "productId": 9,
    "description": "cenoura cubinhos",
    "lots": [
      {
        "lote": "LoteKK123",
        "totalQuantity": 90,
        "expiration": "2024-12-31T23:59:59.000Z"
      }
    ]
  },
  {
    "productId": 10,
    "description": "Mandioca descascada",
    "lots": [
      {
        "lote": "LoteTY123",
        "totalQuantity": 90,
        "expiration": "2024-12-31T23:59:59.000Z"
      }
    ]
  },
  {
    "productId": 11,
    "description": "mirtilos selecionados",
    "lots": [
      {
        "lote": "LoteER56",
        "totalQuantity": 180,
        "expiration": "2024-12-15T23:59:59.000Z"
      }
    ]
  },
  {
    "productId": 12,
    "description": "laranja descascada",
    "lots": [
      {
        "lote": "LoteOI123",
        "totalQuantity": 90,
        "expiration": "2024-12-31T23:59:59.000Z"
      }
    ]
  },
  {
    "productId": 13,
    "description": "mix de verduras",
    "lots": [
      {
        "lote": "LoteABC123",
        "totalQuantity": 90,
        "expiration": "2024-12-31T23:59:59.000Z"
      },
      {
        "lote": "LOTE-TESTE",
        "totalQuantity": 0,
        "expiration": "2024-12-31T23:59:59.000Z"
      }
    ]
  },
  {
    "productId": 14,
    "description": "suco natural de uva",
    "lots": [
      {
        "lote": "LoteWW456",
        "totalQuantity": 180,
        "expiration": "2024-12-15T23:59:59.000Z"
      },
      {
        "lote": "LOTE-TESTE",
        "totalQuantity": 0,
        "expiration": "2024-12-15T23:59:59.000Z"
      }
    ]
  }
]

Create

POST http://localhost:3000/stock/

request:

{
  "document_number": "5001",
  "document_date": "2024-09-15T10:30:00.000Z",
  "stock_moviment": "INPUT",
  "stock_items": [
    {
      "product_id": 1,
      "quantity": 200,
      "unit_price": 10.5
    },
    {
      "product_id": 2,
      "quantity": 200,
      "unit_price": 10.5
    }
  ]
}

response:

{
  "stockDocument": {
    "id": 43,
    "document_number": "5001",
    "document_date": "2024-09-15T10:30:00.000Z",
    "stock_moviment": "INPUT",
    "created_at": "2024-10-19T06:31:44.819Z",
    "updated_at": "2024-10-19T06:31:44.819Z",
    "items": [
      {
        "id": 51,
        "stock_id": 43,
        "sequence": 1,
        "product_id": 1,
        "quantity": 200,
        "unit_price": 10.5,
        "total_price": 2100,
        "lote": "P100024",
        "expiration": "2024-01-01T00:00:00.000Z",
        "image_link": null,
        "photo": [],
        "supplier": null,
        "costumer": null,
        "stock_location_id": 1,
        "observation": null,
        "created_at": "2024-10-19T06:31:45.079Z",
        "updated_at": "2024-10-19T06:31:45.079Z",
        "created_by": null,
        "updated_by": null
      },
      {
        "id": 52,
        "stock_id": 43,
        "sequence": 2,
        "product_id": 2,
        "quantity": 200,
        "unit_price": 10.5,
        "total_price": 2100,
        "lote": "P100025",
        "expiration": "2024-01-01T00:00:00.000Z",
        "image_link": null,
        "photo": [],
        "supplier": null,
        "costumer": null,
        "stock_location_id": 1,
        "observation": null,
        "created_at": "2024-10-19T06:31:45.192Z",
        "updated_at": "2024-10-19T06:31:45.192Z",
        "created_by": null,
        "updated_by": null
      }
    ]
  }
}

Update

PATCH http://localhost:3000/stock/33

request:

response:

Delete (remoção física)

DELETE http://localhost:3000/stock/3

response:

{
  "message": "Stock ID 3 permanently removed successfully"
}
Clone repository
  • Infraestrutura
  • Utilizando a wiki
    • adicionando imagens
    • escrevendo em markdown
    • wiki no editor de texto
  • analytics
  • arquitetura
  • backend_categories
  • backend_inicio
  • backend_persons
  • backend_production_order
  • backend_products
  • backend_qualidade
  • backend_settings
  • backend_stock
  • backend_stock_locations
View All Pages