branch crud and intergration

This commit is contained in:
2026-09-08 12:13:49 +05:30
parent bebec10eb3
commit f664961fce
113 changed files with 41598 additions and 174 deletions
@@ -0,0 +1,16 @@
// Branch configuration. Singleton - no id. When `branchingEnabled` is off, the
// Employee/Warehouse create forms stop asking for a branch and every new record is
// silently assigned to the deployment's one default branch server-side instead.
import { apiRequestWithETag } from "@/lib/api-client"
import { ApiResult } from "@/types/common"
import { BranchConfig, UpdateBranchConfigRequest } from "@/types/hrm"
export const branchConfigApi = {
get(): Promise<ApiResult<BranchConfig>> {
return apiRequestWithETag<BranchConfig>("/branch-config")
},
update(request: UpdateBranchConfigRequest, ifMatch: string): Promise<ApiResult<BranchConfig>> {
return apiRequestWithETag<BranchConfig>("/branch-config", { method: "PUT", body: request, ifMatch })
},
}
+3 -3
View File
@@ -1,9 +1,9 @@
// Dashboard overview endpoint (Backend/ERPCore/Controllers/DashboardController.cs).
import { apiRequest } from "@/lib/api-client"
import { apiRequest, buildQuery } from "@/lib/api-client"
import { DashboardStats } from "@/types/dashboard"
export const dashboardApi = {
stats(): Promise<DashboardStats> {
return apiRequest<DashboardStats>("/dashboard/stats")
stats(params: { branchId?: number } = {}): Promise<DashboardStats> {
return apiRequest<DashboardStats>(`/dashboard/stats${buildQuery(params)}`)
},
}
+1
View File
@@ -26,6 +26,7 @@ export interface ListGrnsParams {
poId?: number
vendorId?: number
warehouseId?: number
branchId?: number
sort?: string
}
+3 -2
View File
@@ -12,8 +12,9 @@ import {
WorkShift,
} from "@/types/hrm"
export interface CreateBranchRequest { code: string; name: string; address?: string | null }
export type UpdateBranchRequest = Omit<CreateBranchRequest, "code">
// Code is server-generated ("BR-001", ...) — never sent from the client.
export interface CreateBranchRequest { name: string; address?: string | null; phoneNumber?: string | null }
export type UpdateBranchRequest = CreateBranchRequest
export const branchesHrmApi = createMasterApi<Branch, CreateBranchRequest, UpdateBranchRequest>("branches")
export interface CreateDepartmentRequest {
@@ -9,6 +9,7 @@ export interface ListAdjustmentsParams {
pageSize?: number
q?: string
warehouseId?: number
branchId?: number
reasonCodeId?: number
sort?: string
}
@@ -17,6 +17,7 @@ export interface ListCountsParams {
q?: string
status?: CountStatus
warehouseId?: number
branchId?: number
sort?: string
}
@@ -20,6 +20,7 @@ export interface ListTransfersParams {
status?: TransferStatus
srcWarehouseId?: number
destWarehouseId?: number
branchId?: number
sort?: string
}
+6 -1
View File
@@ -6,6 +6,7 @@ import { LedgerEntry, OnHand, ReorderAlert, ReorderRequisitionResponse, Valuatio
export interface LedgerQuery {
itemId?: number
warehouseId?: number
branchId?: number
/** `YYYY-MM-DD`. */
from?: string
to?: string
@@ -23,6 +24,7 @@ export interface LedgerQuery {
export interface OnHandListParams {
itemId?: number
warehouseId?: number
branchId?: number
page?: number
pageSize?: number
}
@@ -46,7 +48,10 @@ export const stockApi = {
},
/** Items at or below their reorder point — computed on read, no stored entity (FR-STK-10). */
reorderAlerts(warehouseId?: number, params: { page?: number; pageSize?: number } = {}): Promise<PagedResponse<ReorderAlert>> {
reorderAlerts(
warehouseId?: number,
params: { branchId?: number; page?: number; pageSize?: number } = {},
): Promise<PagedResponse<ReorderAlert>> {
return apiRequest<PagedResponse<ReorderAlert>>(`/stock/reorder-alerts${buildQuery({ warehouseId, ...params })}`)
},
+2
View File
@@ -43,6 +43,7 @@ export interface WastageRecord {
export interface ListWastageParams {
warehouseId?: number
branchId?: number
reasonCodeId?: number
page?: number
pageSize?: number
@@ -73,6 +74,7 @@ export const wastageApi = {
// otherwise fetch the page and keep the loss-type rows.
const res = await stockAdjustmentsApi.list({
warehouseId: params.warehouseId,
branchId: params.branchId,
reasonCodeId: params.reasonCodeId,
page: params.page,
pageSize: params.pageSize ?? 50,