nazar-salary 3.4.6 → 3.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +71 -1
- package/index.js +45 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -453,6 +453,74 @@ declare module 'nazar-salary' {
|
|
|
453
453
|
prices: Price[];
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
+
/** Price with aggregated student/revenue stats — returned by getPricesList() only */
|
|
457
|
+
export interface PriceWithStats extends Price {
|
|
458
|
+
/** Gross sales attributed to this tariff (purchase_amount, before bank commission, verified and not) */
|
|
459
|
+
total_amount: number;
|
|
460
|
+
/** Distinct students with at least one active course on this tariff */
|
|
461
|
+
active_students: number;
|
|
462
|
+
/** Distinct students whose courses on this tariff are all closed */
|
|
463
|
+
inactive_students: number;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export interface PricesListResponse {
|
|
467
|
+
prices: PriceWithStats[];
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export interface PriceStudent {
|
|
471
|
+
price_id: number;
|
|
472
|
+
price_name: string;
|
|
473
|
+
student_id: number;
|
|
474
|
+
first_name: string;
|
|
475
|
+
last_name: string;
|
|
476
|
+
phone: string;
|
|
477
|
+
completed_lessons: number;
|
|
478
|
+
total_lessons: number;
|
|
479
|
+
remaining_lessons: number;
|
|
480
|
+
/** Enrollment length in months */
|
|
481
|
+
enrollment_months: number;
|
|
482
|
+
/** Current tariff rate per lesson */
|
|
483
|
+
rate_per_lesson: number;
|
|
484
|
+
/** Gross payments attributed to this student on this tariff */
|
|
485
|
+
purchase_amount: number;
|
|
486
|
+
teacher_id: number | null;
|
|
487
|
+
teacher_name: string | null;
|
|
488
|
+
/** Owner of the student (student_history.owned_by) */
|
|
489
|
+
manager_id: number | null;
|
|
490
|
+
manager_name: string | null;
|
|
491
|
+
manager_role: 'manager' | 'admin' | null;
|
|
492
|
+
/** Whether the course itself is active */
|
|
493
|
+
is_active: boolean;
|
|
494
|
+
/** Student-level status, independent of the course */
|
|
495
|
+
student_status: 'active' | 'waiting' | 'cancelled';
|
|
496
|
+
group_name: string | null;
|
|
497
|
+
main_course: string;
|
|
498
|
+
student_history_id: number;
|
|
499
|
+
/** Course start date, ms timestamp */
|
|
500
|
+
created_at: number;
|
|
501
|
+
/** Student sale/registration date (students.created_at) — what created_from/created_to filter on */
|
|
502
|
+
student_created_at: number;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export interface PriceStudentsResponse {
|
|
506
|
+
price: {
|
|
507
|
+
id: number;
|
|
508
|
+
name: string;
|
|
509
|
+
format: PriceFormat;
|
|
510
|
+
lesson_type: LessonType;
|
|
511
|
+
lessons_per_month: number;
|
|
512
|
+
duration_minutes: number;
|
|
513
|
+
rate_per_lesson: number;
|
|
514
|
+
};
|
|
515
|
+
pagination: {
|
|
516
|
+
page: number;
|
|
517
|
+
limit: number;
|
|
518
|
+
total: number;
|
|
519
|
+
pages: number;
|
|
520
|
+
};
|
|
521
|
+
students: PriceStudent[];
|
|
522
|
+
}
|
|
523
|
+
|
|
456
524
|
export interface PriceHistoryItem {
|
|
457
525
|
id: number;
|
|
458
526
|
format: PriceFormat;
|
|
@@ -1703,7 +1771,9 @@ declare module 'nazar-salary' {
|
|
|
1703
1771
|
updatePrice(priceId: number, data: UpdatePriceData): Promise<Price>;
|
|
1704
1772
|
getPriceHistory(priceId: number): Promise<PriceHistoryResponse>;
|
|
1705
1773
|
deletePrice(priceId: number): Promise<void>;
|
|
1706
|
-
getPricesList(): Promise<
|
|
1774
|
+
getPricesList(): Promise<PricesListResponse>;
|
|
1775
|
+
getPriceStudents(priceId: number, params?: { status?: 'active' | 'inactive'; created_from?: string; created_to?: string; page?: number; limit?: number }): Promise<PriceStudentsResponse>;
|
|
1776
|
+
exportPriceStudents(prices?: number[] | string, options?: { status?: 'active' | 'inactive'; created_from?: string; created_to?: string }): Promise<ArrayBuffer>;
|
|
1707
1777
|
|
|
1708
1778
|
// Student endpoints
|
|
1709
1779
|
createStudent(data: CreateStudentData): Promise<CreateStudentResponse>;
|
package/index.js
CHANGED
|
@@ -527,13 +527,32 @@ class SalaryAPI {
|
|
|
527
527
|
|
|
528
528
|
/**
|
|
529
529
|
* Get list of all prices (requireAuth - for managers)
|
|
530
|
-
* Returns prices with latest history data
|
|
531
|
-
*
|
|
530
|
+
* Returns prices with latest history data plus per-tariff stats:
|
|
531
|
+
* total_amount (gross sales), active_students, inactive_students
|
|
532
|
+
* @returns {Promise<PricesListResponse>}
|
|
532
533
|
*/
|
|
533
534
|
async getPricesList() {
|
|
534
535
|
return await this.client.get("/api/v1/price/");
|
|
535
536
|
}
|
|
536
537
|
|
|
538
|
+
/**
|
|
539
|
+
* Get students of a tariff (requireAuth - for managers)
|
|
540
|
+
* One row per student — their latest course on that tariff
|
|
541
|
+
* @param {number} priceId - Price/tariff ID
|
|
542
|
+
* @param {object} [params]
|
|
543
|
+
* @param {'active'|'inactive'} [params.status] - Filter by course state
|
|
544
|
+
* @param {string} [params.created_from] - Student sale date from, YYYY-MM-DD or ISO 8601
|
|
545
|
+
* @param {string} [params.created_to] - Student sale date to, inclusive
|
|
546
|
+
* @param {number} [params.page=1]
|
|
547
|
+
* @param {number} [params.limit=30] - Max 200
|
|
548
|
+
* @returns {Promise<PriceStudentsResponse>}
|
|
549
|
+
*/
|
|
550
|
+
async getPriceStudents(priceId, params = {}) {
|
|
551
|
+
return await this.client.get(`/api/v1/price/${priceId}/students`, {
|
|
552
|
+
params,
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
|
|
537
556
|
// ===== STUDENT ENDPOINTS =====
|
|
538
557
|
|
|
539
558
|
/**
|
|
@@ -1050,6 +1069,30 @@ class SalaryAPI {
|
|
|
1050
1069
|
});
|
|
1051
1070
|
}
|
|
1052
1071
|
|
|
1072
|
+
/**
|
|
1073
|
+
* Export students of selected tariffs as an Excel file (requireAuth)
|
|
1074
|
+
* Single sheet, one row per student, with a tariff name column
|
|
1075
|
+
* @param {number[]|string} [prices] - Tariff IDs, e.g. [1,2,3] or "1,2,3". Omit for all tariffs
|
|
1076
|
+
* @param {object} [options]
|
|
1077
|
+
* @param {'active'|'inactive'} [options.status] - Filter by course state
|
|
1078
|
+
* @param {string} [options.created_from] - Student sale date from, YYYY-MM-DD or ISO 8601
|
|
1079
|
+
* @param {string} [options.created_to] - Student sale date to, inclusive
|
|
1080
|
+
* @returns {Promise<ArrayBuffer>} Excel file
|
|
1081
|
+
*/
|
|
1082
|
+
async exportPriceStudents(prices, options = {}) {
|
|
1083
|
+
const params = {};
|
|
1084
|
+
if (prices !== undefined && prices !== null) {
|
|
1085
|
+
params.prices = Array.isArray(prices) ? prices.join(",") : prices;
|
|
1086
|
+
}
|
|
1087
|
+
if (options.status !== undefined) params.status = options.status;
|
|
1088
|
+
if (options.created_from !== undefined) params.created_from = options.created_from;
|
|
1089
|
+
if (options.created_to !== undefined) params.created_to = options.created_to;
|
|
1090
|
+
return await this.client.get("/api/v1/price/students/export", {
|
|
1091
|
+
params,
|
|
1092
|
+
responseType: "arraybuffer",
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1053
1096
|
/**
|
|
1054
1097
|
* Export students by manager as Excel file (Admin only)
|
|
1055
1098
|
* @param {number} managerId - Manager (МЗК) ID (required)
|