stock request
This commit is contained in:
@@ -1029,6 +1029,10 @@ export interface CreateTenantLocationInput {
|
||||
latitude?: string;
|
||||
longitude?: string;
|
||||
status?: string;
|
||||
moduleid?: number;
|
||||
applocationid?: number;
|
||||
partnerid?: number;
|
||||
roleid?: number;
|
||||
}
|
||||
|
||||
/** POST /tenants/createtenantlocation — Create a new store location under a tenant. */
|
||||
@@ -1043,6 +1047,8 @@ export interface UpdateTenantLocationInput {
|
||||
contactno?: string;
|
||||
email?: string;
|
||||
status?: string;
|
||||
suburb?: string;
|
||||
city?: string;
|
||||
}
|
||||
|
||||
/** PUT /tenants/updatetenantlocation — Update store location details/status. */
|
||||
@@ -1136,3 +1142,71 @@ export async function reassignDeliveries(opts: {
|
||||
return fiestaSend<Row>('riders/reassigndeliveries', 'POST', opts);
|
||||
}
|
||||
|
||||
/** POST /v1/web/tenants/createlocation — Create a new tenant location (outlet). */
|
||||
export async function createLocation(opts: {
|
||||
tenantid: number;
|
||||
locationname: string;
|
||||
suburb: string;
|
||||
contactno?: string;
|
||||
status?: string;
|
||||
}): Promise<Row> {
|
||||
// Use fiestaSend, note that we include /v1/web explicitly here as the FIESTA_BASE is likely just the root.
|
||||
// Wait, let's look at FIESTA_BASE in the file.
|
||||
// Actually, I'll just use the full endpoint path.
|
||||
return fiestaSend<Row>('v1/web/tenants/createlocation', 'POST', opts);
|
||||
}
|
||||
|
||||
/** PUT /v1/web/tenants/updatelocation — Update an existing tenant location (outlet). */
|
||||
export async function updateLocation(opts: {
|
||||
tenantid: number;
|
||||
locationid: number;
|
||||
locationname?: string;
|
||||
suburb?: string;
|
||||
contactno?: string;
|
||||
status?: string;
|
||||
}): Promise<Row> {
|
||||
return fiestaSend<Row>('v1/web/tenants/updatelocation', 'PUT', opts);
|
||||
}
|
||||
|
||||
/** DELETE /v1/web/tenants/deletelocation — Delete an existing tenant location (outlet). */
|
||||
export async function deleteLocation(opts: {
|
||||
tenantid: number;
|
||||
locationid: number;
|
||||
}) {
|
||||
const qs = new URLSearchParams({
|
||||
tenantid: String(opts.tenantid),
|
||||
locationid: String(opts.locationid),
|
||||
}).toString();
|
||||
return await fiestaSend(`tenants/deletelocation?${qs}`, 'POST');
|
||||
}
|
||||
|
||||
export interface SalesSummaryChartData {
|
||||
date: string;
|
||||
revenue: number;
|
||||
orders: number;
|
||||
}
|
||||
|
||||
export interface SalesSummaryTopLocation {
|
||||
locationname: string;
|
||||
revenue: number;
|
||||
}
|
||||
|
||||
export interface SalesSummaryResponse {
|
||||
totalRevenue: number;
|
||||
totalOrders: number;
|
||||
averageOrderValue: number;
|
||||
chartData: SalesSummaryChartData[];
|
||||
topLocations: SalesSummaryTopLocation[];
|
||||
}
|
||||
|
||||
/** GET /v1/web/reports/sales-summary — Fetches aggregated sales and revenue data. */
|
||||
export async function getSalesSummary(opts: {
|
||||
tenantid: number;
|
||||
locationid?: number;
|
||||
fromdate: string;
|
||||
todate: string;
|
||||
}): Promise<SalesSummaryResponse> {
|
||||
// Use fiestaGet wrapper which parses standard responses
|
||||
const res = await fiestaGet<{ details: SalesSummaryResponse }>('v1/web/reports/sales-summary', opts);
|
||||
return res.details;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user