law-common 10.17.1-beta.7 → 10.18.1-beta.0

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.
@@ -9,7 +9,7 @@ export interface IBillingCreateDto extends Omit<IEntityCreateDto<IBillingEntity>
9
9
  export interface IBillingParticulars {
10
10
  invoiceText?: string;
11
11
  debitNoteText?: string;
12
- includeDebitNoteSummary?: boolean;
12
+ includeDebitNoteSummary: boolean;
13
13
  }
14
14
  export interface IBillingCreateDtoExtra {
15
15
  particulars: IBillingParticulars[];
@@ -22,7 +22,7 @@ import { IHolidayListEntity } from "./holiday-list.entity.interface";
22
22
  import { IHolidayEntity } from "./holiday.entity.interface";
23
23
  import { IIndustryEntity } from "./industry.entity.interface";
24
24
  import { IIntermediaryBankEntity } from "./intermediary_bank.entity.interface";
25
- import { ILeaveEntity, IUserLeaveVirtualEntity } from "./leave.entity.interface";
25
+ import { ILeaveCountVirtualEntity, ILeaveEntity, IUserLeaveVirtualEntity } from "./leave.entity.interface";
26
26
  import { ILeaveHistoryEntity } from "./leave_history.entity.interface";
27
27
  import { IOfficeLocationEntity } from "./office.location.entity";
28
28
  import { IOrganizationEntity } from "./organization.entity.interface";
@@ -144,7 +144,7 @@ export type IBaseEntityApiResponse<T extends {
144
144
  [K in EntityEnum | VirtualEntityEnum]?: IBaseEntityApiResponse<EnumEntityType<K>>;
145
145
  };
146
146
  };
147
- export type EnumEntityType<T extends EntityEnum | VirtualEntityEnum> = (T extends EntityEnum.BILLING ? IBillingEntity : T extends EntityEnum.BILLING_TIMESHEET ? IBillingTimesheetEntity : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? IBillingReimbursementExpenseEntity : T extends EntityEnum.TIMESHEET ? ITimesheetEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.PROJECT ? IProjectEntity : T extends EntityEnum.CLIENT ? IClientEntity : T extends EntityEnum.LEAVE ? ILeaveEntity : T extends EntityEnum.BANK ? IBankEntity : T extends EntityEnum.BILLING_PAYMENT ? IBillingPaymentEntity : T extends EntityEnum.BILLING_TRANSACTION ? IBillingTransactionEntity : T extends EntityEnum.CLIENT_AFFILIATE ? IClientAffiliateEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationEntity : T extends EntityEnum.HOLIDAY ? IHolidayEntity : T extends EntityEnum.HOLIDAY_LIST ? IHolidayListEntity : T extends EntityEnum.COUNTRY ? ICountryEntity : T extends EntityEnum.EXPENSE_TYPE ? IExpenseTypeEntity : T extends EntityEnum.INDUSTRY ? IIndustryEntity : T extends EntityEnum.INTERMEDIARY_BANK ? IIntermediaryBankEntity : T extends EntityEnum.OFFICE_LOCATION ? IOfficeLocationEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.TASK ? ITaskEntity : T extends EntityEnum.DESIGNATION ? IDesignationEntity : T extends EntityEnum.RATE ? IRateEntity : T extends EntityEnum.REIMBURSEMENT ? IReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? IReimbursementExpenseEntity : T extends EntityEnum.WORK_FROM_HOME ? IWorkFromHomeEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? IProjectUserMappingEntity : T extends EntityEnum.CLIENT_USER_MAPPING ? IClientUserMappingEntity : T extends EntityEnum.TO_DO_LIST ? IToDoListEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : T extends VirtualEntityEnum.USER_LEAVE ? IUserLeaveVirtualEntity : T extends EntityEnum.BANK_HISTORY ? IBankHistoryEntity : T extends EntityEnum.LEAVE_HISTORY ? ILeaveHistoryEntity : T extends EntityEnum.WORK_FROM_HOME_HISTORY ? IWorkFromHomeHistoryEntity : T extends EntityEnum.TIMESHEET_HISTORY ? ITimesheetHistoryEntity : never) & {
147
+ export type EnumEntityType<T extends EntityEnum | VirtualEntityEnum> = (T extends EntityEnum.BILLING ? IBillingEntity : T extends EntityEnum.BILLING_TIMESHEET ? IBillingTimesheetEntity : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? IBillingReimbursementExpenseEntity : T extends EntityEnum.TIMESHEET ? ITimesheetEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.PROJECT ? IProjectEntity : T extends EntityEnum.CLIENT ? IClientEntity : T extends EntityEnum.LEAVE ? ILeaveEntity : T extends EntityEnum.BANK ? IBankEntity : T extends EntityEnum.BILLING_PAYMENT ? IBillingPaymentEntity : T extends EntityEnum.BILLING_TRANSACTION ? IBillingTransactionEntity : T extends EntityEnum.CLIENT_AFFILIATE ? IClientAffiliateEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationEntity : T extends EntityEnum.HOLIDAY ? IHolidayEntity : T extends EntityEnum.HOLIDAY_LIST ? IHolidayListEntity : T extends EntityEnum.COUNTRY ? ICountryEntity : T extends EntityEnum.EXPENSE_TYPE ? IExpenseTypeEntity : T extends EntityEnum.INDUSTRY ? IIndustryEntity : T extends EntityEnum.INTERMEDIARY_BANK ? IIntermediaryBankEntity : T extends EntityEnum.OFFICE_LOCATION ? IOfficeLocationEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.TASK ? ITaskEntity : T extends EntityEnum.DESIGNATION ? IDesignationEntity : T extends EntityEnum.RATE ? IRateEntity : T extends EntityEnum.REIMBURSEMENT ? IReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? IReimbursementExpenseEntity : T extends EntityEnum.WORK_FROM_HOME ? IWorkFromHomeEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? IProjectUserMappingEntity : T extends EntityEnum.CLIENT_USER_MAPPING ? IClientUserMappingEntity : T extends EntityEnum.TO_DO_LIST ? IToDoListEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : T extends VirtualEntityEnum.USER_LEAVE ? IUserLeaveVirtualEntity : T extends VirtualEntityEnum.LEAVE_COUNT ? ILeaveCountVirtualEntity : T extends EntityEnum.BANK_HISTORY ? IBankHistoryEntity : T extends EntityEnum.LEAVE_HISTORY ? ILeaveHistoryEntity : T extends EntityEnum.WORK_FROM_HOME_HISTORY ? IWorkFromHomeHistoryEntity : T extends EntityEnum.TIMESHEET_HISTORY ? ITimesheetHistoryEntity : never) & {
148
148
  id: number;
149
149
  };
150
150
  export type EntityRelationConfig<T extends EntityEnum | VirtualEntityEnum> = {
@@ -262,7 +262,8 @@ export type IHistoryEntityChangedLogs<T> = {
262
262
  timeStamp: string;
263
263
  };
264
264
  export declare enum VirtualEntityEnum {
265
- USER_LEAVE = "user_leave"
265
+ USER_LEAVE = "user_leave",
266
+ LEAVE_COUNT = "leave_count"
266
267
  }
267
268
  export type IHistoryConstraintSearchResponse<T> = IBaseResponse<IHistoryEntitySearchByConstraintResponse<T>[]>;
268
269
  export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByConstraintResponse<T>[];
@@ -80,4 +80,5 @@ var EntityEnum;
80
80
  var VirtualEntityEnum;
81
81
  (function (VirtualEntityEnum) {
82
82
  VirtualEntityEnum["USER_LEAVE"] = "user_leave";
83
+ VirtualEntityEnum["LEAVE_COUNT"] = "leave_count";
83
84
  })(VirtualEntityEnum || (exports.VirtualEntityEnum = VirtualEntityEnum = {}));
@@ -2,7 +2,7 @@ import { DurationTypeEnum } from "../enums/duration-type.enum";
2
2
  import { LeaveTypeEnum } from "../enums/leave-type.enum";
3
3
  import { LeaveStatusEnum } from "../enums/leave.status.enum";
4
4
  import { IAuditColumnEntity } from "./audit-column.entity.interface";
5
- import { IEntityFilterData } from "./entity.utils.interface";
5
+ import { EnumEntityType, IEntityFilterData, VirtualEntityEnum } from "./entity.utils.interface";
6
6
  import { IUserEntity } from "./user.entity.interface";
7
7
  export interface ILeaveEntity extends IAuditColumnEntity {
8
8
  id: number;
@@ -38,3 +38,12 @@ export interface IUserLeaveVirtualEntity extends IAuditColumnEntity {
38
38
  type: LeaveTypeEnum;
39
39
  id: number;
40
40
  }
41
+ export interface ILeaveCountVirtualEntity extends IAuditColumnEntity {
42
+ id: number;
43
+ period: string;
44
+ leaveId?: number;
45
+ count: number;
46
+ }
47
+ export declare const virtualEntityToKeysMap: {
48
+ [K in VirtualEntityEnum]: (keyof EnumEntityType<K>)[];
49
+ };
@@ -1,2 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.virtualEntityToKeysMap = void 0;
4
+ const entity_utils_interface_1 = require("./entity.utils.interface");
5
+ exports.virtualEntityToKeysMap = {
6
+ [entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT]: [
7
+ "createdBy",
8
+ "createdOn",
9
+ "leaveId",
10
+ "period",
11
+ "updatedBy",
12
+ "updatedOn",
13
+ "count",
14
+ "id"
15
+ ],
16
+ [entity_utils_interface_1.VirtualEntityEnum.USER_LEAVE]: [
17
+ "createdBy",
18
+ "createdOn",
19
+ "id",
20
+ "leavesPending",
21
+ "leavesTaken",
22
+ "period",
23
+ "type",
24
+ "updatedBy",
25
+ "updatedOn",
26
+ "userId",
27
+ ],
28
+ };
@@ -0,0 +1,20 @@
1
+ import { IBankApiEntity } from "../../api";
2
+ import { BankStatusEnum } from "../enums/bank_status.enum";
3
+ export declare class BankEntity implements IBankApiEntity {
4
+ id: number;
5
+ accountName: string;
6
+ organizationId: number;
7
+ name: string;
8
+ accountNo: string;
9
+ branchAddress: string;
10
+ ifscCode: string;
11
+ emailForPaymentInfoCsv: string;
12
+ status: BankStatusEnum;
13
+ remark?: string;
14
+ swiftAddress?: string;
15
+ createdBy: number;
16
+ updatedBy: number;
17
+ createdOn: string;
18
+ updatedOn: string;
19
+ static fromApiEntity(apiEntity: IBankApiEntity): BankEntity;
20
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BankEntity = void 0;
4
+ const bank_status_enum_1 = require("../enums/bank_status.enum");
5
+ class BankEntity {
6
+ constructor() {
7
+ this.id = 0;
8
+ this.accountName = "";
9
+ this.organizationId = 0;
10
+ this.name = "";
11
+ this.accountNo = "";
12
+ this.branchAddress = "";
13
+ this.ifscCode = "";
14
+ this.emailForPaymentInfoCsv = "";
15
+ this.status = bank_status_enum_1.BankStatusEnum.CREATE_APPROVAL;
16
+ this.createdBy = 0;
17
+ this.updatedBy = 0;
18
+ this.createdOn = `${new Date()}`;
19
+ this.updatedOn = `${new Date()}`;
20
+ }
21
+ static fromApiEntity(apiEntity) {
22
+ const entity = new BankEntity();
23
+ Object.assign(entity, apiEntity);
24
+ return entity;
25
+ }
26
+ }
27
+ exports.BankEntity = BankEntity;
@@ -19,6 +19,7 @@ export declare class LeaveEntityModel implements ILeaveEntity {
19
19
  updatedBy: number;
20
20
  private constructor();
21
21
  static fromEntity(data: ILeaveEntity): LeaveEntityModel;
22
+ isMoreThanOneDayLeave(): boolean;
22
23
  getLeaveDuration(excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[]): number;
23
24
  static getLeaveDuration(leaves: LeaveEntityModel[], excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[], leaveStatusEnum?: LeaveStatusEnum[]): number;
24
25
  getDateCodeModels(dateCodeIncludePredicates?: ((dateModel: DateCodeModel) => boolean)[], dateCodeExcludePredicates?: ((dateModel: DateCodeModel) => boolean)[]): DateCodeModel[];
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LeaveEntityModel = void 0;
4
4
  const utils_1 = require("../../utils");
5
+ const duration_type_enum_1 = require("../enums/duration-type.enum");
5
6
  const leave_status_enum_1 = require("../enums/leave.status.enum");
6
7
  class LeaveEntityModel {
7
8
  constructor(data) {
@@ -22,10 +23,28 @@ class LeaveEntityModel {
22
23
  static fromEntity(data) {
23
24
  return new LeaveEntityModel(data);
24
25
  }
26
+ isMoreThanOneDayLeave() {
27
+ const fromDate = new utils_1.DateCodeModel(this.fromDate);
28
+ const toDate = new utils_1.DateCodeModel(this.toDate);
29
+ return fromDate.diffInDays(toDate) > 1;
30
+ }
25
31
  getLeaveDuration(excludeWeekdays = [], excludeDates = []) {
32
+ if (!this.isMoreThanOneDayLeave()) {
33
+ return this.durationType === duration_type_enum_1.DurationTypeEnum.FULL ? 1 : 0.5;
34
+ }
26
35
  const fromDate = new utils_1.DateCodeModel(this.fromDate);
27
36
  const toDate = new utils_1.DateCodeModel(this.toDate);
28
- return fromDate.diffInDays(toDate, excludeWeekdays, excludeDates);
37
+ let count = fromDate.diffInDays(toDate, excludeWeekdays, excludeDates);
38
+ if (this.durationType === duration_type_enum_1.DurationTypeEnum.FULL) {
39
+ return count;
40
+ }
41
+ if (this.durationType === duration_type_enum_1.DurationTypeEnum.SECOND_FIRST) {
42
+ return count - 1;
43
+ }
44
+ if (this.durationType === duration_type_enum_1.DurationTypeEnum.FULL_FIRST || this.durationType === duration_type_enum_1.DurationTypeEnum.SECOND_FULL) {
45
+ return count - 0.5;
46
+ }
47
+ return count;
29
48
  }
30
49
  // getLeaveDurationByPredicates(predicates: ((leave: LeaveEntityModel) => boolean)[]): number {
31
50
  // const fromDate = new DateCodeModel(this.fromDate);
@@ -36,4 +36,5 @@ export declare class DateCodeModel {
36
36
  getDateInIST(): Date;
37
37
  static getDaysInCurrentMonth(): number;
38
38
  getDaysInMonth(dateCode?: string): number;
39
+ isPresent(dateCodes: DateCodeModel[]): boolean;
39
40
  }
@@ -222,5 +222,8 @@ class DateCodeModel {
222
222
  // Number of days in that month
223
223
  return (0, date_fns_1.lastDayOfMonth)(date).getDate();
224
224
  }
225
+ isPresent(dateCodes) {
226
+ return dateCodes.some((d) => d.isSame(this));
227
+ }
225
228
  }
226
229
  exports.DateCodeModel = DateCodeModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.17.1-beta.7",
3
+ "version": "10.18.1-beta.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [