@dynamatix/gb-schemas 1.2.48 → 1.2.49

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,18 +9,18 @@ const applicantEmploymentSchema = new mongoose.Schema({
9
9
  addressLine2: { type: String, default: null },
10
10
  addressLine3: { type: String, default: null },
11
11
  addressPostCode: { type: String, required: true },
12
- averageBonusPreviousTwoYears: { type: Pound, default: 0.00' },
13
- basicGrossIncome: { type: Pound, default: 0.00' },
14
- basicPay: { type: Pound, default: 0.00' },
15
- carAllowance: { type: Pound, default: 0.00' },
16
- childBenefit: { type: Pound, default: 0.00' },
17
- childBenefitOrSchoolAllowance: { type: Pound, default: 0.00' },
12
+ averageBonusPreviousTwoYears: { type: Pound, default: 0.00 },
13
+ basicGrossIncome: { type: Pound, default: 0.00 },
14
+ basicPay: { type: Pound, default: 0.00 },
15
+ carAllowance: { type: Pound, default: 0.00 },
16
+ childBenefit: { type: Pound, default: 0.00 },
17
+ childBenefitOrSchoolAllowance: { type: Pound, default: 0.00 },
18
18
  contractRemaining: { type: String },
19
19
  dateJoined: { type: String, required: true },
20
- disabilityLiving: { type: Pound, default: 0.00' },
20
+ disabilityLiving: { type: Pound, default: 0.00 },
21
21
  employerName: { type: String, required: true },
22
22
  employerTelephone: { type: String, default: null },
23
- housingAllowance: { type: Pound, default: 0.00' },
23
+ housingAllowance: { type: Pound, default: 0.00 },
24
24
  industryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
25
25
  isUnderTerminationNotice: {
26
26
  type: Boolean,
@@ -28,17 +28,17 @@ const applicantEmploymentSchema = new mongoose.Schema({
28
28
  get: (v) => v ? "Yes" : "No"
29
29
  },
30
30
  jobTitleLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
31
- maintenance: { type: Pound, default: 0.00' },
32
- maternityIncome: { type: Pound, default: 0.00' },
31
+ maintenance: { type: Pound, default: 0.00 },
32
+ maternityIncome: { type: Pound, default: 0.00 },
33
33
  natureOfBusiness: { type: String, required: true },
34
- pensionIncome: { type: Pound, default: 0.00' },
34
+ pensionIncome: { type: Pound, default: 0.00 },
35
35
  previousAddressCity: { type: String, default: null },
36
36
  previousAddressCountryLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
37
37
  previousAddressLine1: { type: String, required: true },
38
38
  previousAddressLine2: { type: String, default: null },
39
39
  previousAddressLine3: { type: String, default: null },
40
40
  previousAddressPostCode: { type: String, required: true },
41
- previousBasicGrossIncome: { type: Pound, default: 0.00', required: true },
41
+ previousBasicGrossIncome: { type: Pound, default: 0.00, required: true },
42
42
  previousDateJoined: { type: String, required: true },
43
43
  previousDateLeft: { type: String, required: true },
44
44
  previousEmployerName: { type: String, required: true },
@@ -47,8 +47,8 @@ const applicantEmploymentSchema = new mongoose.Schema({
47
47
  previousNatureOfBusiness: { type: String, required: true },
48
48
  referenceContact: { type: String, default: null },
49
49
  referenceContactEmail: { type: String, required: true },
50
- secondJob: { type: Pound, default: 0.00' },
51
- travelAllowance: { type: Pound, default: 0.00' },
50
+ secondJob: { type: Pound, default: 0.00 },
51
+ travelAllowance: { type: Pound, default: 0.00 },
52
52
  underTerminationNoticeNote: { type: String, default: null }
53
53
  }, {
54
54
  toJSON: { getters: true },
@@ -15,7 +15,7 @@ const applicantExpenditureSchema = new mongoose.Schema({
15
15
  vehicleInsurance: { type: Pound, required: true },
16
16
  mortgagePaymentVehicle: { type: Pound, required: true },
17
17
  other: { type: Pound, required: true },
18
- totalMontlyExpenditure: { type: String, default: 0.00' }
18
+ totalMontlyExpenditure: { type: String, default: 0.00 }
19
19
  }, {
20
20
  toJSON: { getters: true },
21
21
  toObject: { getters: true }
@@ -34,9 +34,9 @@ const incomeSchema = new mongoose.Schema({
34
34
  },
35
35
  nameOfBusiness: { type: String, required: true },
36
36
  natureOfBusiness: { type: String, required: true },
37
- netAssets1: { type: Pound, default: 0.00' },
38
- netAssets2: { type: Pound, default: 0.00' },
39
- netAssets3: { type: Pound, default: 0.00' },
37
+ netAssets1: { type: Pound, default: 0.00 },
38
+ netAssets2: { type: Pound, default: 0.00 },
39
+ netAssets3: { type: Pound, default: 0.00 },
40
40
  pageValidFlag: { type: String, default: true },
41
41
  percentageOfShareholding: { type: Number, required: true, min: 0, max: 100 },
42
42
  registeredAddressLine1: { type: String, required: true },
@@ -47,12 +47,12 @@ const incomeSchema = new mongoose.Schema({
47
47
  registeredPostCode: { type: String, required: true },
48
48
  registeredTelephone: { type: String, required: true },
49
49
  selfEmployedDate: { type: String, required: true },
50
- turnover1: { type: Pound, default: 0.00' },
51
- turnover2: { type: Pound, default: 0.00' },
52
- turnover3: { type: Pound, default: 0.00' },
53
- year1: { type: Pound, default: 0.00' },
54
- year2: { type: Pound, default: 0.00' },
55
- year3: { type: Pound, default: 0.00' },
50
+ turnover1: { type: Pound, default: 0.00 },
51
+ turnover2: { type: Pound, default: 0.00 },
52
+ turnover3: { type: Pound, default: 0.00 },
53
+ year1: { type: Pound, default: 0.00 },
54
+ year2: { type: Pound, default: 0.00 },
55
+ year3: { type: Pound, default: 0.00 },
56
56
  yearEnd1: { type: Number, default: '' },
57
57
  yearEnd2: { type: Number, default: '' },
58
58
  yearEnd3: { type: Number, default: '' }
@@ -3,7 +3,7 @@ import { Pound } from "../value-objects/pound";
3
3
  const applicantOtherIncomeSchema = new mongoose.Schema({
4
4
  // Income Source 1
5
5
  sourceDetails1: { type: String, default: null },
6
- amount1: { type: Pound, default: 0.00' },
6
+ amount1: { type: Pound, default: 0.00 },
7
7
  payFrequency1Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
8
8
  guaranteed1: {
9
9
  type: Boolean,
@@ -12,7 +12,7 @@ const applicantOtherIncomeSchema = new mongoose.Schema({
12
12
  },
13
13
  // Income Source 2
14
14
  sourceDetails2: { type: String, default: null },
15
- amount2: { type: Pound, default: 0.00' },
15
+ amount2: { type: Pound, default: 0.00 },
16
16
  payFrequency2Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
17
17
  guaranteed2: {
18
18
  type: Boolean,
@@ -21,7 +21,7 @@ const applicantOtherIncomeSchema = new mongoose.Schema({
21
21
  },
22
22
  // Income Source 3
23
23
  sourceDetails3: { type: String, default: null },
24
- amount3: { type: Pound, default: 0.00' },
24
+ amount3: { type: Pound, default: 0.00 },
25
25
  payFrequency3Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
26
26
  guaranteed3: {
27
27
  type: Boolean,
@@ -30,19 +30,19 @@ const applicantOtherIncomeSchema = new mongoose.Schema({
30
30
  },
31
31
  // Income Source 4
32
32
  sourceDetails4: { type: String, default: null },
33
- amount4: { type: Pound, default: 0.00' },
33
+ amount4: { type: Pound, default: 0.00 },
34
34
  payFrequency4Lid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", default: null },
35
35
  guaranteed4: {
36
36
  type: Boolean,
37
37
  default: false,
38
38
  get: (v) => v ? "Yes" : "No"
39
39
  },
40
- taxCredits: { type: Pound, default: 0.00' },
41
- maintenance: { type: Pound, default: 0.00' },
42
- otherBenefits: { type: Pound, default: 0.00' },
43
- grossPensionIncome: { type: Pound, default: 0.00' },
44
- privatePensionIncome: { type: Pound, default: 0.00' },
45
- statePensionIncome: { type: Pound, default: 0.00' },
40
+ taxCredits: { type: Pound, default: 0.00 },
41
+ maintenance: { type: Pound, default: 0.00 },
42
+ otherBenefits: { type: Pound, default: 0.00 },
43
+ grossPensionIncome: { type: Pound, default: 0.00 },
44
+ privatePensionIncome: { type: Pound, default: 0.00 },
45
+ statePensionIncome: { type: Pound, default: 0.00 },
46
46
  }, {
47
47
  toJSON: { getters: true },
48
48
  toObject: { getters: true }
@@ -109,7 +109,7 @@ const applicantSchema = new mongoose.Schema({
109
109
  maritalStatusLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
110
110
  mobileNumber: { type: String, default: null },
111
111
  nationalityLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup", required: true },
112
- netIncome: { type: Pound, default: 0.00' },
112
+ netIncome: { type: Pound, default: 0.00 },
113
113
  niNumber: { type: String, required: true },
114
114
  numberOfDependants: { type: Number, default: 0 },
115
115
  isOneYearPrior: {
@@ -28,14 +28,14 @@ const companySchema = new mongoose.Schema({
28
28
  // }
29
29
  // ],
30
30
  yearEnd1: { type: Number, required: true, max: 9999 }, // form
31
- turnoverYear1: { type: Pound, required: true, default: 0.00' }, // form
32
- netProfitYear1: { type: Pound, required: true, default: 0.00' }, // form
31
+ turnoverYear1: { type: Pound, required: true, default: 0.00 }, // form
32
+ netProfitYear1: { type: Pound, required: true, default: 0.00 }, // form
33
33
  yearEnd2: { type: Number, required: true, max: 9999 }, // form
34
- turnoverYear2: { type: Pound, required: true, default: 0.00' }, // form
35
- netProfitYear2: { type: Pound, required: true, default: 0.00' }, // form
34
+ turnoverYear2: { type: Pound, required: true, default: 0.00 }, // form
35
+ netProfitYear2: { type: Pound, required: true, default: 0.00 }, // form
36
36
  yearEnd3: { type: Number, required: true, max: 9999 }, // form
37
- turnoverYear3: { type: Pound, required: true, default: 0.00' }, // form
38
- netProfitYear3: { type: Pound, required: true, default: 0.00' }, // form
37
+ turnoverYear3: { type: Pound, required: true, default: 0.00 }, // form
38
+ netProfitYear3: { type: Pound, required: true, default: 0.00 }, // form
39
39
  // Purchase form - Company section
40
40
  companyCreditDefaults: { type: String, required: true, default: '' }, // form
41
41
  companyCountyCourtJudgment: { type: String, required: true, default: '' }, // form
@@ -10,7 +10,7 @@ const productSchema = new mongoose.Schema({
10
10
  repaymentTypeLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup" },
11
11
  numberOfYearsToRepay: { type: Number, default: 0 },
12
12
  repaymentVehicle: { type: String, required: true, default: '', maxLength: 100 },
13
- fixedAmount: { type: Pound, default: 0.00', required: false },
13
+ fixedAmount: { type: Pound, default: 0.00, required: false },
14
14
  isFinanceRecommendedToApplicantLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup" },
15
15
  procFeeRateLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup" },
16
16
  networkClubSubmission: { type: Boolean, required: true, get: (value) => (value ? "Yes" : "No") },
@@ -18,7 +18,7 @@ const productSchema = new mongoose.Schema({
18
18
  introducerSubmission: { type: Boolean, required: true, get: (value) => (value ? "Yes" : "No") },
19
19
  introducer: { type: String, default: '' },
20
20
  bdm: { type: String, required: true, default: '' },
21
- tempAppFee: { type: Pound, default: 0.00', required: true },
21
+ tempAppFee: { type: Pound, default: 0.00, required: true },
22
22
  productFeePaymentTypeLid: { type: mongoose.Schema.Types.ObjectId, ref: "Lookup" }
23
23
  });
24
24
  // virtual property 'lendingType'
@@ -62,31 +62,31 @@ const propertySchema = new mongoose.Schema({
62
62
  marketValue: {
63
63
  type: Pound,
64
64
  required: true,
65
- default: 0.00',
65
+ default: 0.00,
66
66
  description: "The market value of the property",
67
67
  },
68
68
  monthlyRent: {
69
69
  type: Pound,
70
70
  required: true,
71
- default: 0.00',
71
+ default: 0.00,
72
72
  description: "The monthly rent value of the property"
73
73
  },
74
74
  monthlyRepayment: {
75
75
  type: Pound,
76
76
  required: true,
77
- default: 0.00',
77
+ default: 0.00,
78
78
  description: "The monthly repayment value for the property"
79
79
  },
80
80
  originalLoanBalance: {
81
81
  type: Pound,
82
82
  required: true,
83
- default: 0.00',
83
+ default: 0.00,
84
84
  description: "The original loan balance for the property"
85
85
  },
86
86
  outstandingBalance: {
87
87
  type: Pound,
88
88
  required: true,
89
- default: 0.00',
89
+ default: 0.00,
90
90
  description: "The remaining outstanding balance of the property loan"
91
91
  },
92
92
  otherOwnershipParties: {
@@ -57,11 +57,11 @@ const securitySchema = new mongoose.Schema({
57
57
  pageValidFlag: { type: Boolean, default: true, }, //form
58
58
  haveAnyBuyToLetProperties: { type: Boolean, required: true, default: false }, // not-form propertyData - not in Property form
59
59
  isPropertyInEnglandOrWales: { type: Boolean, required: true, default: false }, // not-form propertyData - not in Property form
60
- // price: { type: Pound, required: true, default: 0.00'} as any, // *already in Purchase Form -> not-form mortgateData - pounds
60
+ // price: { type: Pound, required: true, default: 0.00} as any, // *already in Purchase Form -> not-form mortgateData - pounds
61
61
  noOfBuyToLetProperties: { type: Number, default: 0 }, // not-form propertyData - not in Property form
62
- totalMonthlyRentalIncome: { type: Pound, required: true, default: 0.00' }, // not-form pound propertyData - not in Property form
63
- totalMonthlyRepayment: { type: Pound, required: true, default: 0.00' }, // not-form pound propertyData - not in Property form
64
- totalOutstandingBalance: { type: Pound, required: true, default: 0.00' }, // not-form pound propertyData - not in Property form
62
+ totalMonthlyRentalIncome: { type: Pound, required: true, default: 0.00 }, // not-form pound propertyData - not in Property form
63
+ totalMonthlyRepayment: { type: Pound, required: true, default: 0.00 }, // not-form pound propertyData - not in Property form
64
+ totalOutstandingBalance: { type: Pound, required: true, default: 0.00 }, // not-form pound propertyData - not in Property form
65
65
  areAllBedRoomsOver10sqm: { type: Boolean, required: true, default: false }, // form
66
66
  isBrickTileConstruction: { type: Boolean, required: true, default: false }, // form
67
67
  constructionDetails: { type: String, required: true, default: '' }, // form
@@ -72,7 +72,7 @@ const securitySchema = new mongoose.Schema({
72
72
  isGroundRent: {
73
73
  type: Pound,
74
74
  required: true,
75
- default: 0.00' // Default value in correct format
75
+ default: 0.00 // Default value in correct format
76
76
  }, // form - pounds
77
77
  isHouseLicensed: { type: Boolean, required: true, default: false }, // form
78
78
  houseNumberOfFloors: { type: Number, required: true, default: 0 }, // form
@@ -98,7 +98,7 @@ const securitySchema = new mongoose.Schema({
98
98
  serviceCharge: {
99
99
  type: Pound,
100
100
  required: true,
101
- default: 0.00' // Default value in correct format
101
+ default: 0.00 // Default value in correct format
102
102
  }, // form - pounds
103
103
  unexpiredRemainingLease: { type: Number, required: true, max: 9999, default: 0 }, // form
104
104
  yearLeaseExpires: { type: Number, required: true, default: 0 }, // not-form securityData
@@ -1 +1 @@
1
- {"version":3,"file":"pound.d.ts","sourceRoot":"","sources":["../../value-objects/pound.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC,OAAO,QAAQ,UAAU,CAAC;IACtB,UAAU,MAAM,CAAC;QACb,UAAU,KAAK,CAAC;YACZ,MAAM,KAAM,SAAQ,UAAU;aAAI;SACrC;KACJ;CACJ;AAED,cAAM,KAAM,SAAQ,QAAQ,CAAC,UAAU;gBACvB,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,SAAS,GAAG,SAAS;IAKhE,IAAI,CAAC,GAAG,EAAE,GAAG;CA8ChB;AAKD,OAAO,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"pound.d.ts","sourceRoot":"","sources":["../../value-objects/pound.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC,OAAO,QAAQ,UAAU,CAAC;IACtB,UAAU,MAAM,CAAC;QACb,UAAU,KAAK,CAAC;YACZ,MAAM,KAAM,SAAQ,UAAU;aAAI;SACrC;KACJ;CACJ;AAED,cAAM,KAAM,SAAQ,QAAQ,CAAC,UAAU;gBACvB,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,SAAS,GAAG,SAAS;IAKhE,IAAI,CAAC,GAAG,EAAE,GAAG;CA4BhB;AAKD,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -9,30 +9,16 @@ class Pound extends mongoose.SchemaType {
9
9
  if (val == null) {
10
10
  return val; // Allow null or undefined values
11
11
  }
12
- // Convert numbers to string for processing
13
- if (typeof val === 'number') {
14
- val = val.toFixed(2); // Ensure 2 decimal places
15
- }
16
12
  // Ensure the value is a string
17
- if (typeof val !== 'string') {
13
+ if (typeof val !== 'number') {
18
14
  throw new mongoose.Error.CastError('Pound', val, this.path, new Error('Pound value must be a string or number'));
19
15
  }
20
- // Remove commas for numeric validation
21
- const cleaned = val.replace(/,/g, '');
22
16
  // Check if the cleaned value is a valid number
23
- if (isNaN(Number(cleaned))) {
17
+ if (isNaN(Number(val))) {
24
18
  throw new mongoose.Error.CastError('Pound', val, this.path, new Error(`${val} is not a valid currency value`));
25
19
  }
26
- // Convert to number to handle decimal places correctly
27
- const numValue = Number(cleaned);
28
- // Format the number with commas and 2 decimal places
29
- const formattedValue = numValue.toLocaleString('en-GB', {
30
- style: 'decimal',
31
- minimumFractionDigits: 2,
32
- maximumFractionDigits: 2
33
- });
34
20
  // Return without symbol prefixed
35
- return `${formattedValue}`;
21
+ return val.toFixed(2);
36
22
  }
37
23
  }
38
24
  // Register the custom type globally with Mongoose
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamatix/gb-schemas",
3
- "version": "1.2.48",
3
+ "version": "1.2.49",
4
4
  "description": "All the schemas for gatehouse bank back-end",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",