@7365admin1/core 3.32.2-staging.40 → 3.32.2-staging.42

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/dist/index.d.ts CHANGED
@@ -6920,6 +6920,8 @@ declare const useRedDotPaymentSvc: () => {
6920
6920
  type TBillingItems = {
6921
6921
  _id: ObjectId | string;
6922
6922
  name: string;
6923
+ amount: number;
6924
+ referenceNumber: string;
6923
6925
  };
6924
6926
  type TBillingPayments = {
6925
6927
  _id?: ObjectId;
@@ -7786,6 +7788,7 @@ declare function useBuildingLevelRepo(): {
7786
7788
  message: string;
7787
7789
  data: bson.Document[];
7788
7790
  }>;
7791
+ getActiveLevelsByIds: (ids: (string | ObjectId)[], session?: ClientSession) => Promise<TBuildingLevel[]>;
7789
7792
  };
7790
7793
 
7791
7794
  declare function useBuildingLevelService(): {
package/dist/index.js CHANGED
@@ -29563,6 +29563,20 @@ function useBuildingLevelRepo() {
29563
29563
  }
29564
29564
  }
29565
29565
  }
29566
+ async function getActiveLevelsByIds(ids, session) {
29567
+ if (!ids || ids.length === 0)
29568
+ return [];
29569
+ let objectIds;
29570
+ try {
29571
+ objectIds = ids.map((id) => new import_mongodb53.ObjectId(id));
29572
+ } catch {
29573
+ throw new import_node_server_utils87.BadRequestError("Invalid level ID format.");
29574
+ }
29575
+ return collection.find(
29576
+ { _id: { $in: objectIds }, status: "active" /* ACTIVE */ },
29577
+ { projection: { _id: 1, name: 1 }, session }
29578
+ ).toArray();
29579
+ }
29566
29580
  async function updateLevelById(_id, value, session) {
29567
29581
  try {
29568
29582
  _id = new import_mongodb53.ObjectId(_id);
@@ -29761,7 +29775,8 @@ function useBuildingLevelRepo() {
29761
29775
  deleteById,
29762
29776
  bulkWriteLevels,
29763
29777
  batchUpdateByIds,
29764
- getBuildingLevelList
29778
+ getBuildingLevelList,
29779
+ getActiveLevelsByIds
29765
29780
  };
29766
29781
  }
29767
29782
 
@@ -29782,7 +29797,10 @@ function useBuildingService() {
29782
29797
  } = useBuildingUnitRepo();
29783
29798
  const { updateStatusById } = useFileRepo();
29784
29799
  const { deleteFile } = useFileService();
29785
- const { bulkWriteLevels: _bulkWriteLevels } = useBuildingLevelRepo();
29800
+ const {
29801
+ bulkWriteLevels: _bulkWriteLevels,
29802
+ getActiveLevelsByIds: _getActiveLevelsByIds
29803
+ } = useBuildingLevelRepo();
29786
29804
  function normalizeImportKey(value) {
29787
29805
  return String(value ?? "").trim().replace(/\s+/g, " ").toLowerCase();
29788
29806
  }
@@ -29876,23 +29894,37 @@ function useBuildingService() {
29876
29894
  );
29877
29895
  }
29878
29896
  if (data.levels) {
29879
- const levelsPayload = (data.levels ?? []).map((levelName) => ({
29880
- blockId: id,
29881
- site: building.site.toString(),
29882
- name: levelName,
29883
- status: "active" /* ACTIVE */,
29884
- createdAt: /* @__PURE__ */ new Date(),
29885
- updatedAt: null,
29886
- deletedAt: null
29887
- }));
29888
- let levels;
29889
- if (levelsPayload.length > 0) {
29890
- levels = await _bulkWriteLevels(levelsPayload, session);
29891
- }
29892
- if (levels) {
29893
- building.levels.push(...Object.values(levels.insertedIds));
29894
- data.levels = building.levels.map((id2) => id2.toString());
29897
+ const submittedNames = data.levels ?? [];
29898
+ const existingLevels = await _getActiveLevelsByIds(
29899
+ building.levels,
29900
+ session
29901
+ );
29902
+ const seenKeys = new Set(
29903
+ existingLevels.map((level) => normalizeImportKey(level.name))
29904
+ );
29905
+ const newNames = submittedNames.filter((name) => {
29906
+ const key = normalizeImportKey(name);
29907
+ if (seenKeys.has(key))
29908
+ return false;
29909
+ seenKeys.add(key);
29910
+ return true;
29911
+ });
29912
+ if (newNames.length > 0) {
29913
+ const levelsPayload = newNames.map((name) => ({
29914
+ blockId: id,
29915
+ site: building.site.toString(),
29916
+ name,
29917
+ status: "active" /* ACTIVE */,
29918
+ createdAt: /* @__PURE__ */ new Date(),
29919
+ updatedAt: null,
29920
+ deletedAt: null
29921
+ }));
29922
+ const levels = await _bulkWriteLevels(levelsPayload, session);
29923
+ if (levels) {
29924
+ building.levels.push(...Object.values(levels.insertedIds));
29925
+ }
29895
29926
  }
29927
+ data.levels = building.levels.map((levelId) => levelId.toString());
29896
29928
  }
29897
29929
  const buildingUnitData = {};
29898
29930
  if (data.name && building.name !== data.name) {
@@ -64687,7 +64719,9 @@ var BillingPaymentStatus = /* @__PURE__ */ ((BillingPaymentStatus2) => {
64687
64719
  })(BillingPaymentStatus || {});
64688
64720
  var schemaBillingItems = import_joi126.default.object({
64689
64721
  _id: import_joi126.default.string().hex().optional(),
64690
- name: import_joi126.default.string().optional().allow(null, "")
64722
+ name: import_joi126.default.string().optional().allow(null, ""),
64723
+ amount: import_joi126.default.number().optional().allow(null, ""),
64724
+ referenceNumber: import_joi126.default.string().optional().allow(null, "")
64691
64725
  });
64692
64726
  var schemaBillingPayments = import_joi126.default.object({
64693
64727
  _id: import_joi126.default.string().hex().optional(),