@fintekkers/ledger-models 0.4.23 → 0.4.24
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.
|
@@ -17,6 +17,7 @@ import { Decimal } from 'decimal.js';
|
|
|
17
17
|
import { ModelValidationError } from '../errors';
|
|
18
18
|
import { TransactionProto } from '../../../fintekkers/models/transaction/transaction_pb';
|
|
19
19
|
import { dummyPortfolio } from '../portfolio/portfolio.test';
|
|
20
|
+
import { PortfolioProto } from '../../../fintekkers/models/portfolio/portfolio_pb';
|
|
20
21
|
|
|
21
22
|
test('test Transaction constructor with parameters', () => {
|
|
22
23
|
testTransactionConstructor();
|
|
@@ -153,3 +154,33 @@ test('a link-mode TransactionProto with no as_of still builds', () => {
|
|
|
153
154
|
const txn = new Transaction(link);
|
|
154
155
|
expect(txn.proto.hasAsOf()).toBe(false);
|
|
155
156
|
});
|
|
157
|
+
|
|
158
|
+
// LM-271: a link portfolio with no as_of serializes, on its own and inside a
|
|
159
|
+
// Transaction, and as_of stays unset (never defaulted).
|
|
160
|
+
test('link portfolio with no as_of serializes', () => {
|
|
161
|
+
const uuid = UUID.random();
|
|
162
|
+
const link = new PortfolioProto();
|
|
163
|
+
link.setUuid(uuid.toUUIDProto());
|
|
164
|
+
link.setIsLink(true);
|
|
165
|
+
const portfolio = new Portfolio(link);
|
|
166
|
+
|
|
167
|
+
const copy = PortfolioProto.deserializeBinary(portfolio.proto.serializeBinary());
|
|
168
|
+
assert(copy.getIsLink());
|
|
169
|
+
assert(!copy.hasAsOf());
|
|
170
|
+
|
|
171
|
+
const transaction = new Transaction({
|
|
172
|
+
tradeDate: new Date(2024, 0, 15),
|
|
173
|
+
settlementDate: new Date(2024, 0, 17),
|
|
174
|
+
asOfDate: new Date(2024, 0, 15, 10, 30, 0),
|
|
175
|
+
price: new Decimal('100'),
|
|
176
|
+
security: dummySecurity(),
|
|
177
|
+
transactionType: dummyTransactionType(),
|
|
178
|
+
portfolio,
|
|
179
|
+
quantity: new Decimal('10'),
|
|
180
|
+
});
|
|
181
|
+
const txnCopy = TransactionProto.deserializeBinary(transaction.proto.serializeBinary());
|
|
182
|
+
const txnPortfolio = txnCopy.getPortfolio()!;
|
|
183
|
+
assert(txnPortfolio.getIsLink());
|
|
184
|
+
assert(!txnPortfolio.hasAsOf());
|
|
185
|
+
assert(UUID.fromU8Array(txnPortfolio.getUuid()!.getRawUuid_asU8()).toString() === uuid.toString());
|
|
186
|
+
});
|