feat: complete admin panel and backend admin api migration

This commit is contained in:
s.esmaeili
2026-09-13 21:02:25 +03:30
parent 03119cd655
commit 267fc7b7d1
239 changed files with 25431 additions and 935 deletions
@@ -1,5 +1,6 @@
import { Type } from 'class-transformer';
import { ArrayMinSize, IsArray, IsInt, IsNumber, IsOptional, IsPositive, IsString, Min, ValidateNested } from 'class-validator';
import { OrderChannel } from '@prisma/client';
import { ArrayMinSize, IsArray, IsEnum, IsInt, IsNumber, IsOptional, IsPositive, IsString, Min, ValidateNested } from 'class-validator';
export class CreateOrderItemInputDto {
@IsString()
@@ -31,6 +32,15 @@ export class CreateOrderDto {
@IsString()
branchId?: string;
/**
* Which sales channel placed the order. Legacy had no such field because the
* two channels lived in separate tables (orders vs orders_orders); the one
* Order model carries the distinction here. Defaults to RETAIL.
*/
@IsOptional()
@IsEnum(OrderChannel)
channel?: OrderChannel;
@IsArray()
@ArrayMinSize(1)
@ValidateNested({ each: true })
@@ -2,7 +2,9 @@ import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
import { OrdersService } from './orders.service';
import { CreateOrderDto } from './dto/create-order.dto';
import { UpdateOrderStatusDto } from './dto/update-order-status.dto';
import { Public } from '../auth/guards';
@Public() // pre-existing unauthenticated endpoint; see Phase 1 notes
@Controller('orders')
export class OrdersController {
constructor(private readonly orders: OrdersService) {}
@@ -1,5 +1,5 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { OrderStatus, Prisma } from '@prisma/client';
import { OrderChannel, OrderStatus, Prisma } from '@prisma/client';
import { PrismaService } from '../../prisma/prisma.service';
import { CatalogService } from '../catalog/catalog.service';
import { LedgerService } from '../accounting/ledger.service';
@@ -80,6 +80,7 @@ export class OrdersService {
orderNumber: this.generateOrderNumber(),
customerId: dto.customerId,
branchId: dto.branchId,
channel: dto.channel ?? OrderChannel.RETAIL,
status: initialStatus,
totalGoldWeightGrams,
wageWeightGrams,