payservedb 3.1.1 → 3.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,33 +1,43 @@
1
1
  const mongoose = require('mongoose');
2
2
 
3
- // Define the schema for CountryTaxRate
4
- const countryTaxRateSchema = new mongoose.Schema({
3
+ const CountryTaxRateSchema = new mongoose.Schema({
5
4
  facilityId: {
6
- type: mongoose.Schema.Types.ObjectId,
7
- ref: 'Facility',
8
- required: [true, 'Facility ID is required']
5
+ type: String,
6
+ required: true
9
7
  },
10
8
  taxRate: {
11
9
  type: Number,
12
- required: [true, 'Tax rate is required'],
13
- min: [0, 'Tax rate cannot be negative']
10
+ required: true
14
11
  },
15
12
  country: {
16
13
  type: String,
17
- required: [true, 'Country is required'],
18
- trim: true,
19
- minlength: [1, 'Country name must be at least 1 character long']
14
+ required: true
20
15
  },
21
16
  currency: {
22
17
  type: String,
23
- required: [true, 'Currency is required'],
24
- trim: true,
25
- minlength: [1, 'Currency code must be at least 1 character long']
18
+ required: true
19
+ },
20
+ taxType: {
21
+ type: String,
22
+ required: true,
23
+ enum: [
24
+ 'rental_income',
25
+ 'capital_gains',
26
+ 'vat',
27
+ 'stamp_duty',
28
+ 'land_rates',
29
+ 'land_rent',
30
+ 'withholding'
31
+ ]
26
32
  }
27
33
  }, {
28
- timestamps: true
34
+ timestamps: true
29
35
  });
30
36
 
31
- const CountryTaxRate = mongoose.model('CountryTaxRate', countryTaxRateSchema);
37
+ // Add compound index to ensure unique tax type per facility
38
+ CountryTaxRateSchema.index({ facilityId: 1, taxType: 1 }, { unique: true });
39
+
40
+ // Register the model
41
+ const CountryTaxRate = mongoose.model('CountryTaxRate', CountryTaxRateSchema);
32
42
 
33
43
  module.exports = CountryTaxRate;