addItem (inventoryController.js)

BizzAI · crm

Creates new inventory items with validation, prevents duplicates, triggers stock alerts, and returns created items with alert status.

// Source: https://github.com/orion-ai-community/BizzAI | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import mongoose from "mongoose";
import Item from "../models/Item.js";
import { checkStockAlerts } from "../utils/stockAlert.js";
import { info, error } from "../utils/logger.js";

/**
 * @desc Add new item to inventory
 * @route POST /api/inventory
 */
export const addItem = async (req, res) => {
  try {
    const {
      name, sku, barcode, category, hsnCode, taxRate,
      costPrice, sellingPrice, stockQty, lowStockLimit, unit,
      trackBatch, trackExpiry, reservedStock
    } = req.body;

    if (!name || !costPrice || !sellingPrice) {
      return res.status(400).json({ su

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key