ETASCOM CRM V3 - Documentation API
    Preparing search index...
    • POST(
          request: NextRequest,
      ): Promise<
          | NextResponse<{ error: string; message: string }>
          | NextResponse<
              {
                  success: boolean;
                  message: string;
                  finishedProduct: {
                      id: string;
                      code: string;
                      name: string;
                      description: string
                      | null;
                      category: string | undefined;
                      unit: string;
                      sellingPrice: number;
                      cost: number;
                  };
                  bom: {
                      totalComponents: number;
                      rawMaterialsCount: number;
                      componentsCount: number;
                      totalCost: number;
                      allStockSufficient: boolean;
                      missingMaterialsCount: number;
                  };
                  rawMaterials: {
                      id: string;
                      sequence: number;
                      rawMaterial: {
                          id: string;
                          code: string;
                          name: string;
                          description: string
                          | null;
                          category: string | undefined;
                          unit: string;
                      };
                      quantity: number;
                      unit: string;
                      efficiency: number;
                      isConsumable: boolean;
                      scrapRate: number
                      | null;
                      unitCost: number | null;
                      calculatedCost: number | null;
                      componentPrice: number | null;
                      stock: { totalAvailable: number; unit: string; status: string };
                      fifoLot:
                          | {
                              id: string;
                              lotNumber: string;
                              quantity: number;
                              unit: string;
                              createdAt: Date;
                              labels: { id: string; code: string; quantity: number }[];
                          }
                          | null;
                      availableLots: {
                          id: string;
                          lotNumber: string;
                          quantity: number;
                          unit: string;
                          isFifoFirst: boolean;
                          labelsCount: number;
                      }[];
                  }[];
                  components: {
                      id: string;
                      sequence: number;
                      finishedProduct: {
                          id: string;
                          code: string;
                          name: string;
                          description: string
                          | null;
                          category: string | undefined;
                          unit: string;
                      };
                      quantity: number;
                      unit: string;
                      efficiency: number;
                      unitCost: number
                      | null;
                      calculatedCost: number | null;
                      componentPrice: number | null;
                      stock: { totalAvailable: number; unit: string; status: string };
                      fifoLot:
                          | { id: string; lotNumber: string; quantity: number; unit: string }
                          | null;
                  }[];
                  warnings: {
                      type: string;
                      name: string;
                      code: string;
                      needed: number;
                      available: number;
                      status: string;
                  }[];
                  scanInfo: {
                      scannedAt: string;
                      scannedBy: { id: string; name: string
                      | null; email: string };
                  };
              },
          >,
      >

      API Tablette - Scanner une Nomenclature (BOM)

      POST /api/tablet/bom/scan

      Body:

      • code: string (code du produit fini ou ID nomenclature)
      • userId: string (ID de l'utilisateur connecté)
      • metadata?: object (données supplémentaires)

      Réponse:

      • finishedProduct: object (produit fini)
      • materials: array (matières premières composantes avec FIFO)
      • components: array (produits finis composants)
      • totals: object (coûts et quantités totaux)

      Parameters

      • request: NextRequest

      Returns Promise<
          | NextResponse<{ error: string; message: string }>
          | NextResponse<
              {
                  success: boolean;
                  message: string;
                  finishedProduct: {
                      id: string;
                      code: string;
                      name: string;
                      description: string
                      | null;
                      category: string | undefined;
                      unit: string;
                      sellingPrice: number;
                      cost: number;
                  };
                  bom: {
                      totalComponents: number;
                      rawMaterialsCount: number;
                      componentsCount: number;
                      totalCost: number;
                      allStockSufficient: boolean;
                      missingMaterialsCount: number;
                  };
                  rawMaterials: {
                      id: string;
                      sequence: number;
                      rawMaterial: {
                          id: string;
                          code: string;
                          name: string;
                          description: string
                          | null;
                          category: string | undefined;
                          unit: string;
                      };
                      quantity: number;
                      unit: string;
                      efficiency: number;
                      isConsumable: boolean;
                      scrapRate: number
                      | null;
                      unitCost: number | null;
                      calculatedCost: number | null;
                      componentPrice: number | null;
                      stock: { totalAvailable: number; unit: string; status: string };
                      fifoLot:
                          | {
                              id: string;
                              lotNumber: string;
                              quantity: number;
                              unit: string;
                              createdAt: Date;
                              labels: { id: string; code: string; quantity: number }[];
                          }
                          | null;
                      availableLots: {
                          id: string;
                          lotNumber: string;
                          quantity: number;
                          unit: string;
                          isFifoFirst: boolean;
                          labelsCount: number;
                      }[];
                  }[];
                  components: {
                      id: string;
                      sequence: number;
                      finishedProduct: {
                          id: string;
                          code: string;
                          name: string;
                          description: string
                          | null;
                          category: string | undefined;
                          unit: string;
                      };
                      quantity: number;
                      unit: string;
                      efficiency: number;
                      unitCost: number
                      | null;
                      calculatedCost: number | null;
                      componentPrice: number | null;
                      stock: { totalAvailable: number; unit: string; status: string };
                      fifoLot:
                          | { id: string; lotNumber: string; quantity: number; unit: string }
                          | null;
                  }[];
                  warnings: {
                      type: string;
                      name: string;
                      code: string;
                      needed: number;
                      available: number;
                      status: string;
                  }[];
                  scanInfo: {
                      scannedAt: string;
                      scannedBy: { id: string; name: string
                      | null; email: string };
                  };
              },
          >,
      >