@barchart/portfolio-api-common 1.0.269 → 1.0.270

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.
@@ -23,6 +23,17 @@ module.exports = (() => {
23
23
  return portfolioUpdateFailedNoPortfolio;
24
24
  }
25
25
 
26
+ /**
27
+ * The portfolio does not exist.
28
+ *
29
+ * @public
30
+ * @static
31
+ * @returns {FailureType}
32
+ */
33
+ static get PORTFOLIO_DELETE_FAILED_NO_PORTFOLIO() {
34
+ return portfolioDeleteFailedNoPortfolio;
35
+ }
36
+
26
37
  /**
27
38
  * The portfolio does not exist.
28
39
  *
@@ -136,7 +147,8 @@ module.exports = (() => {
136
147
  }
137
148
  }
138
149
 
139
- const portfolioUpdateFailedNoPortfolio = new FailureType('PORTFOLIO_UPDATED_FAILED_NO_PORTFOLIO', 'Unable to update portfolio. The portfolio does not exist, has it been deleted?');
150
+ const portfolioUpdateFailedNoPortfolio = new FailureType('PORTFOLIO_UPDATE_FAILED_NO_PORTFOLIO', 'Unable to update portfolio. The portfolio does not exist, has it been deleted?');
151
+ const portfolioDeleteFailedNoPortfolio = new FailureType('PORTFOLIO_DELETE_FAILED_NO_PORTFOLIO', 'Unable to delete portfolio. The portfolio does not exist, has it already been deleted?');
140
152
 
141
153
  const positionCreateFailedNoPortfolio = new FailureType('POSITION_CREATE_FAILED_NO_PORTFOLIO', 'Unable to create transaction. The portfolio does not exist, has it been deleted?');
142
154
  const positionUpdateFailedNoPosition = new FailureType('POSITION_UPDATE_FAILED_NO_POSITION', 'Unable to update preferences for position. The position does not exist, has it been deleted?');
@@ -25,22 +25,12 @@ module.exports = (() => {
25
25
  * @public
26
26
  * @static
27
27
  * @param {Array.<Object>} transactions
28
- * @param {Boolean=} partial - If true, sequence validation starts with the array's first transaction.
29
28
  * @return {boolean}
30
29
  */
31
- static validateOrder(transactions, partial) {
30
+ static validateOrder(transactions) {
32
31
  assert.argumentIsArray(transactions, 'transactions');
33
- assert.argumentIsOptional(partial, 'partial', Boolean);
34
32
 
35
- let startSequence;
36
-
37
- if (partial && transactions.length !== 0) {
38
- startSequence = array.first(transactions).sequence;
39
- } else {
40
- startSequence = 1;
41
- }
42
-
43
- return transactions.every((t, i) => t.sequence === (i + startSequence) && (i === 0 || !t.date.getIsBefore(transactions[i - 1].date)));
33
+ return transactions.every((t, i) => t.sequence === (i + 1) && (i === 0 || !t.date.getIsBefore(transactions[i - 1].date)));
44
34
  }
45
35
 
46
36
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.269",
3
+ "version": "1.0.270",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -983,22 +983,12 @@ module.exports = (() => {
983
983
  * @public
984
984
  * @static
985
985
  * @param {Array.<Object>} transactions
986
- * @param {Boolean=} partial - If true, sequence validation starts with the array's first transaction.
987
986
  * @return {boolean}
988
987
  */
989
- static validateOrder(transactions, partial) {
988
+ static validateOrder(transactions) {
990
989
  assert.argumentIsArray(transactions, 'transactions');
991
- assert.argumentIsOptional(partial, 'partial', Boolean);
992
990
 
993
- let startSequence;
994
-
995
- if (partial && transactions.length !== 0) {
996
- startSequence = array.first(transactions).sequence;
997
- } else {
998
- startSequence = 1;
999
- }
1000
-
1001
- return transactions.every((t, i) => t.sequence === (i + startSequence) && (i === 0 || !t.date.getIsBefore(transactions[i - 1].date)));
991
+ return transactions.every((t, i) => t.sequence === (i + 1) && (i === 0 || !t.date.getIsBefore(transactions[i - 1].date)));
1002
992
  }
1003
993
 
1004
994
  /**
@@ -9103,14 +9093,6 @@ describe('When validating transaction order', () => {
9103
9093
  it('An array of transactions with ordered sequences, on the reversed days should not be valid', () => {
9104
9094
  expect(TransactionValidator.validateOrder([ build(1, '2018-05-02'), build(2, '2018-05-01'), build(3, '2018-04-30') ])).toEqual(false);
9105
9095
  });
9106
-
9107
- it('A partial array of transactions with ordered sequences (starting after one), on the same day should be valid', () => {
9108
- expect(TransactionValidator.validateOrder([ build(3, '2018-04-30'), build(4, '2018-04-30'), build(5, '2018-04-30') ], true)).toEqual(true);
9109
- });
9110
-
9111
- it('A partial array of transactions with gap in sequences (starting after one), on the same day should be not valid', () => {
9112
- expect(TransactionValidator.validateOrder([ build(3, '2018-04-30'), build(5, '2018-04-30'), build(6, '2018-04-30') ], true)).toEqual(false);
9113
- });
9114
9096
  });
9115
9097
 
9116
9098
  },{"./../../../lib/data/TransactionValidator":5,"@barchart/common-js/lang/Day":18}],37:[function(require,module,exports){
@@ -40,12 +40,4 @@ describe('When validating transaction order', () => {
40
40
  it('An array of transactions with ordered sequences, on the reversed days should not be valid', () => {
41
41
  expect(TransactionValidator.validateOrder([ build(1, '2018-05-02'), build(2, '2018-05-01'), build(3, '2018-04-30') ])).toEqual(false);
42
42
  });
43
-
44
- it('A partial array of transactions with ordered sequences (starting after one), on the same day should be valid', () => {
45
- expect(TransactionValidator.validateOrder([ build(3, '2018-04-30'), build(4, '2018-04-30'), build(5, '2018-04-30') ], true)).toEqual(true);
46
- });
47
-
48
- it('A partial array of transactions with gap in sequences (starting after one), on the same day should be not valid', () => {
49
- expect(TransactionValidator.validateOrder([ build(3, '2018-04-30'), build(5, '2018-04-30'), build(6, '2018-04-30') ], true)).toEqual(false);
50
- });
51
43
  });