@fintekkers/ledger-models 1.1.0 → 1.1.1

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.
@@ -0,0 +1,303 @@
1
+ // source: fintekkers/models/position/tax_lot.proto
2
+ /**
3
+ * @fileoverview
4
+ * @enhanceable
5
+ * @suppress {missingRequire} reports error on implicit type usages.
6
+ * @suppress {messageConventions} JS Compiler reports an error if a variable or
7
+ * field starts with 'MSG_' and isn't a translatable message.
8
+ * @public
9
+ */
10
+ // GENERATED CODE -- DO NOT EDIT!
11
+ /* eslint-disable */
12
+ // @ts-nocheck
13
+
14
+ var jspb = require('google-protobuf');
15
+ var goog = jspb;
16
+ var global = (function() {
17
+ if (this) { return this; }
18
+ if (typeof window !== 'undefined') { return window; }
19
+ if (typeof global !== 'undefined') { return global; }
20
+ if (typeof self !== 'undefined') { return self; }
21
+ return Function('return this')();
22
+ }.call(null));
23
+
24
+ var fintekkers_models_util_decimal_value_pb = require('../../../fintekkers/models/util/decimal_value_pb.js');
25
+ goog.object.extend(proto, fintekkers_models_util_decimal_value_pb);
26
+ var fintekkers_models_util_local_date_pb = require('../../../fintekkers/models/util/local_date_pb.js');
27
+ goog.object.extend(proto, fintekkers_models_util_local_date_pb);
28
+ goog.exportSymbol('proto.fintekkers.models.position.TaxLotProto', null, global);
29
+ /**
30
+ * Generated by JsPbCodeGenerator.
31
+ * @param {Array=} opt_data Optional initial data array, typically from a
32
+ * server response, or constructed directly in Javascript. The array is used
33
+ * in place and becomes part of the constructed object. It is not cloned.
34
+ * If no data is provided, the constructed object will be empty, but still
35
+ * valid.
36
+ * @extends {jspb.Message}
37
+ * @constructor
38
+ */
39
+ proto.fintekkers.models.position.TaxLotProto = function(opt_data) {
40
+ jspb.Message.initialize(this, opt_data, 0, -1, null, null);
41
+ };
42
+ goog.inherits(proto.fintekkers.models.position.TaxLotProto, jspb.Message);
43
+ if (goog.DEBUG && !COMPILED) {
44
+ /**
45
+ * @public
46
+ * @override
47
+ */
48
+ proto.fintekkers.models.position.TaxLotProto.displayName = 'proto.fintekkers.models.position.TaxLotProto';
49
+ }
50
+
51
+
52
+
53
+ if (jspb.Message.GENERATE_TO_OBJECT) {
54
+ /**
55
+ * Creates an object representation of this proto.
56
+ * Field names that are reserved in JavaScript and will be renamed to pb_name.
57
+ * Optional fields that are not set will be set to undefined.
58
+ * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
59
+ * For the list of reserved names please see:
60
+ * net/proto2/compiler/js/internal/generator.cc#kKeyword.
61
+ * @param {boolean=} opt_includeInstance Deprecated. whether to include the
62
+ * JSPB instance for transitional soy proto support:
63
+ * http://goto/soy-param-migration
64
+ * @return {!Object}
65
+ */
66
+ proto.fintekkers.models.position.TaxLotProto.prototype.toObject = function(opt_includeInstance) {
67
+ return proto.fintekkers.models.position.TaxLotProto.toObject(opt_includeInstance, this);
68
+ };
69
+
70
+
71
+ /**
72
+ * Static version of the {@see toObject} method.
73
+ * @param {boolean|undefined} includeInstance Deprecated. Whether to include
74
+ * the JSPB instance for transitional soy proto support:
75
+ * http://goto/soy-param-migration
76
+ * @param {!proto.fintekkers.models.position.TaxLotProto} msg The msg instance to transform.
77
+ * @return {!Object}
78
+ * @suppress {unusedLocalVariables} f is only used for nested messages
79
+ */
80
+ proto.fintekkers.models.position.TaxLotProto.toObject = function(includeInstance, msg) {
81
+ var f, obj = {
82
+ openDate: (f = msg.getOpenDate()) && fintekkers_models_util_local_date_pb.LocalDateProto.toObject(includeInstance, f),
83
+ openQuantity: (f = msg.getOpenQuantity()) && fintekkers_models_util_decimal_value_pb.DecimalValueProto.toObject(includeInstance, f),
84
+ price: (f = msg.getPrice()) && fintekkers_models_util_decimal_value_pb.DecimalValueProto.toObject(includeInstance, f)
85
+ };
86
+
87
+ if (includeInstance) {
88
+ obj.$jspbMessageInstance = msg;
89
+ }
90
+ return obj;
91
+ };
92
+ }
93
+
94
+
95
+ /**
96
+ * Deserializes binary data (in protobuf wire format).
97
+ * @param {jspb.ByteSource} bytes The bytes to deserialize.
98
+ * @return {!proto.fintekkers.models.position.TaxLotProto}
99
+ */
100
+ proto.fintekkers.models.position.TaxLotProto.deserializeBinary = function(bytes) {
101
+ var reader = new jspb.BinaryReader(bytes);
102
+ var msg = new proto.fintekkers.models.position.TaxLotProto;
103
+ return proto.fintekkers.models.position.TaxLotProto.deserializeBinaryFromReader(msg, reader);
104
+ };
105
+
106
+
107
+ /**
108
+ * Deserializes binary data (in protobuf wire format) from the
109
+ * given reader into the given message object.
110
+ * @param {!proto.fintekkers.models.position.TaxLotProto} msg The message object to deserialize into.
111
+ * @param {!jspb.BinaryReader} reader The BinaryReader to use.
112
+ * @return {!proto.fintekkers.models.position.TaxLotProto}
113
+ */
114
+ proto.fintekkers.models.position.TaxLotProto.deserializeBinaryFromReader = function(msg, reader) {
115
+ while (reader.nextField()) {
116
+ if (reader.isEndGroup()) {
117
+ break;
118
+ }
119
+ var field = reader.getFieldNumber();
120
+ switch (field) {
121
+ case 1:
122
+ var value = new fintekkers_models_util_local_date_pb.LocalDateProto;
123
+ reader.readMessage(value,fintekkers_models_util_local_date_pb.LocalDateProto.deserializeBinaryFromReader);
124
+ msg.setOpenDate(value);
125
+ break;
126
+ case 2:
127
+ var value = new fintekkers_models_util_decimal_value_pb.DecimalValueProto;
128
+ reader.readMessage(value,fintekkers_models_util_decimal_value_pb.DecimalValueProto.deserializeBinaryFromReader);
129
+ msg.setOpenQuantity(value);
130
+ break;
131
+ case 3:
132
+ var value = new fintekkers_models_util_decimal_value_pb.DecimalValueProto;
133
+ reader.readMessage(value,fintekkers_models_util_decimal_value_pb.DecimalValueProto.deserializeBinaryFromReader);
134
+ msg.setPrice(value);
135
+ break;
136
+ default:
137
+ reader.skipField();
138
+ break;
139
+ }
140
+ }
141
+ return msg;
142
+ };
143
+
144
+
145
+ /**
146
+ * Serializes the message to binary data (in protobuf wire format).
147
+ * @return {!Uint8Array}
148
+ */
149
+ proto.fintekkers.models.position.TaxLotProto.prototype.serializeBinary = function() {
150
+ var writer = new jspb.BinaryWriter();
151
+ proto.fintekkers.models.position.TaxLotProto.serializeBinaryToWriter(this, writer);
152
+ return writer.getResultBuffer();
153
+ };
154
+
155
+
156
+ /**
157
+ * Serializes the given message to binary data (in protobuf wire
158
+ * format), writing to the given BinaryWriter.
159
+ * @param {!proto.fintekkers.models.position.TaxLotProto} message
160
+ * @param {!jspb.BinaryWriter} writer
161
+ * @suppress {unusedLocalVariables} f is only used for nested messages
162
+ */
163
+ proto.fintekkers.models.position.TaxLotProto.serializeBinaryToWriter = function(message, writer) {
164
+ var f = undefined;
165
+ f = message.getOpenDate();
166
+ if (f != null) {
167
+ writer.writeMessage(
168
+ 1,
169
+ f,
170
+ fintekkers_models_util_local_date_pb.LocalDateProto.serializeBinaryToWriter
171
+ );
172
+ }
173
+ f = message.getOpenQuantity();
174
+ if (f != null) {
175
+ writer.writeMessage(
176
+ 2,
177
+ f,
178
+ fintekkers_models_util_decimal_value_pb.DecimalValueProto.serializeBinaryToWriter
179
+ );
180
+ }
181
+ f = message.getPrice();
182
+ if (f != null) {
183
+ writer.writeMessage(
184
+ 3,
185
+ f,
186
+ fintekkers_models_util_decimal_value_pb.DecimalValueProto.serializeBinaryToWriter
187
+ );
188
+ }
189
+ };
190
+
191
+
192
+ /**
193
+ * optional fintekkers.models.util.LocalDateProto open_date = 1;
194
+ * @return {?proto.fintekkers.models.util.LocalDateProto}
195
+ */
196
+ proto.fintekkers.models.position.TaxLotProto.prototype.getOpenDate = function() {
197
+ return /** @type{?proto.fintekkers.models.util.LocalDateProto} */ (
198
+ jspb.Message.getWrapperField(this, fintekkers_models_util_local_date_pb.LocalDateProto, 1));
199
+ };
200
+
201
+
202
+ /**
203
+ * @param {?proto.fintekkers.models.util.LocalDateProto|undefined} value
204
+ * @return {!proto.fintekkers.models.position.TaxLotProto} returns this
205
+ */
206
+ proto.fintekkers.models.position.TaxLotProto.prototype.setOpenDate = function(value) {
207
+ return jspb.Message.setWrapperField(this, 1, value);
208
+ };
209
+
210
+
211
+ /**
212
+ * Clears the message field making it undefined.
213
+ * @return {!proto.fintekkers.models.position.TaxLotProto} returns this
214
+ */
215
+ proto.fintekkers.models.position.TaxLotProto.prototype.clearOpenDate = function() {
216
+ return this.setOpenDate(undefined);
217
+ };
218
+
219
+
220
+ /**
221
+ * Returns whether this field is set.
222
+ * @return {boolean}
223
+ */
224
+ proto.fintekkers.models.position.TaxLotProto.prototype.hasOpenDate = function() {
225
+ return jspb.Message.getField(this, 1) != null;
226
+ };
227
+
228
+
229
+ /**
230
+ * optional fintekkers.models.util.DecimalValueProto open_quantity = 2;
231
+ * @return {?proto.fintekkers.models.util.DecimalValueProto}
232
+ */
233
+ proto.fintekkers.models.position.TaxLotProto.prototype.getOpenQuantity = function() {
234
+ return /** @type{?proto.fintekkers.models.util.DecimalValueProto} */ (
235
+ jspb.Message.getWrapperField(this, fintekkers_models_util_decimal_value_pb.DecimalValueProto, 2));
236
+ };
237
+
238
+
239
+ /**
240
+ * @param {?proto.fintekkers.models.util.DecimalValueProto|undefined} value
241
+ * @return {!proto.fintekkers.models.position.TaxLotProto} returns this
242
+ */
243
+ proto.fintekkers.models.position.TaxLotProto.prototype.setOpenQuantity = function(value) {
244
+ return jspb.Message.setWrapperField(this, 2, value);
245
+ };
246
+
247
+
248
+ /**
249
+ * Clears the message field making it undefined.
250
+ * @return {!proto.fintekkers.models.position.TaxLotProto} returns this
251
+ */
252
+ proto.fintekkers.models.position.TaxLotProto.prototype.clearOpenQuantity = function() {
253
+ return this.setOpenQuantity(undefined);
254
+ };
255
+
256
+
257
+ /**
258
+ * Returns whether this field is set.
259
+ * @return {boolean}
260
+ */
261
+ proto.fintekkers.models.position.TaxLotProto.prototype.hasOpenQuantity = function() {
262
+ return jspb.Message.getField(this, 2) != null;
263
+ };
264
+
265
+
266
+ /**
267
+ * optional fintekkers.models.util.DecimalValueProto price = 3;
268
+ * @return {?proto.fintekkers.models.util.DecimalValueProto}
269
+ */
270
+ proto.fintekkers.models.position.TaxLotProto.prototype.getPrice = function() {
271
+ return /** @type{?proto.fintekkers.models.util.DecimalValueProto} */ (
272
+ jspb.Message.getWrapperField(this, fintekkers_models_util_decimal_value_pb.DecimalValueProto, 3));
273
+ };
274
+
275
+
276
+ /**
277
+ * @param {?proto.fintekkers.models.util.DecimalValueProto|undefined} value
278
+ * @return {!proto.fintekkers.models.position.TaxLotProto} returns this
279
+ */
280
+ proto.fintekkers.models.position.TaxLotProto.prototype.setPrice = function(value) {
281
+ return jspb.Message.setWrapperField(this, 3, value);
282
+ };
283
+
284
+
285
+ /**
286
+ * Clears the message field making it undefined.
287
+ * @return {!proto.fintekkers.models.position.TaxLotProto} returns this
288
+ */
289
+ proto.fintekkers.models.position.TaxLotProto.prototype.clearPrice = function() {
290
+ return this.setPrice(undefined);
291
+ };
292
+
293
+
294
+ /**
295
+ * Returns whether this field is set.
296
+ * @return {boolean}
297
+ */
298
+ proto.fintekkers.models.position.TaxLotProto.prototype.hasPrice = function() {
299
+ return jspb.Message.getField(this, 3) != null;
300
+ };
301
+
302
+
303
+ goog.object.extend(exports, proto.fintekkers.models.position);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * LM-364 — a TipsInput with cost_basis (20): non-default elections and two
3
+ * TaxLotProto lots round-trip unchanged.
4
+ *
5
+ * The enum values are all non-zero: value 0 is not written on the wire.
6
+ */
7
+ export {};
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ /**
3
+ * LM-364 — a TipsInput with cost_basis (20): non-default elections and two
4
+ * TaxLotProto lots round-trip unchanged.
5
+ *
6
+ * The enum values are all non-zero: value 0 is not written on the wire.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const product_inputs_pb_1 = require("./product_inputs_pb");
10
+ const valuation_request_pb_1 = require("./valuation_request_pb");
11
+ const amortisation_elections_pb_1 = require("../../../fintekkers/models/portfolio/amortisation_elections_pb");
12
+ const tax_lot_pb_1 = require("../../../fintekkers/models/position/tax_lot_pb");
13
+ const local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
14
+ const decimal_1 = require("../../../wrappers/models/utils/decimal");
15
+ function decimal(value) {
16
+ return (0, decimal_1.encodeDecimal)((0, decimal_1.parseDecimalString)(value));
17
+ }
18
+ function date(year, month, day) {
19
+ const d = new local_date_pb_1.LocalDateProto();
20
+ d.setYear(year);
21
+ d.setMonth(month);
22
+ d.setDay(day);
23
+ return d;
24
+ }
25
+ function lot(openDate, openQuantity, price) {
26
+ const l = new tax_lot_pb_1.TaxLotProto();
27
+ l.setOpenDate(openDate);
28
+ l.setOpenQuantity(decimal(openQuantity));
29
+ l.setPrice(decimal(price));
30
+ return l;
31
+ }
32
+ describe('TipsInput cost_basis (20)', () => {
33
+ test('non-default elections and two lots round-trip unchanged', () => {
34
+ const elections = new amortisation_elections_pb_1.AmortisationElectionsProto();
35
+ elections.setBondPremium(amortisation_elections_pb_1.PremiumAmortisationElectionProto.PREMIUM_NOT_ELECTED);
36
+ elections.setMarketDiscountInclusion(amortisation_elections_pb_1.MarketDiscountInclusionProto.INCLUDE_CURRENTLY);
37
+ elections.setMarketDiscountAccrual(amortisation_elections_pb_1.MarketDiscountAccrualMethodProto.CONSTANT_YIELD);
38
+ const costBasis = new product_inputs_pb_1.CostBasisInput();
39
+ costBasis.setElections(elections);
40
+ costBasis.addLots(lot(date(2024, 1, 15), '10000', '98.25'));
41
+ costBasis.addLots(lot(date(2025, 6, 2), '5000', '101.50'));
42
+ const tips = new product_inputs_pb_1.TipsInput();
43
+ tips.setCleanPrice(decimal('97.50'));
44
+ tips.setCostBasis(costBasis);
45
+ const productInput = new product_inputs_pb_1.ProductInput();
46
+ productInput.setTips(tips);
47
+ const request = new valuation_request_pb_1.ValuationRequestProto();
48
+ request.setProductInput(productInput);
49
+ const decoded = valuation_request_pb_1.ValuationRequestProto.deserializeBinary(request.serializeBinary()).getProductInput().getTips();
50
+ expect(decoded.toObject()).toEqual(tips.toObject());
51
+ expect(decoded.hasCostBasis()).toBe(true);
52
+ const parsed = decoded.getCostBasis();
53
+ expect(parsed.hasElections()).toBe(true);
54
+ const e = parsed.getElections();
55
+ expect(e.getBondPremium()).toBe(amortisation_elections_pb_1.PremiumAmortisationElectionProto.PREMIUM_NOT_ELECTED);
56
+ expect(e.getMarketDiscountInclusion()).toBe(amortisation_elections_pb_1.MarketDiscountInclusionProto.INCLUDE_CURRENTLY);
57
+ expect(e.getMarketDiscountAccrual()).toBe(amortisation_elections_pb_1.MarketDiscountAccrualMethodProto.CONSTANT_YIELD);
58
+ const lots = parsed.getLotsList().map(l => [
59
+ l.getOpenDate().toObject(),
60
+ (0, decimal_1.toCanonicalString)((0, decimal_1.decodeDecimal)(l.getOpenQuantity())),
61
+ (0, decimal_1.toCanonicalString)((0, decimal_1.decodeDecimal)(l.getPrice())),
62
+ ]);
63
+ expect(lots).toEqual([
64
+ [{ year: 2024, month: 1, day: 15 }, '10000', '98.25'],
65
+ [{ year: 2025, month: 6, day: 2 }, '5000', '101.50'],
66
+ ]);
67
+ });
68
+ });
69
+ //# sourceMappingURL=cost_basis_input.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cost_basis_input.test.js","sourceRoot":"","sources":["cost_basis_input.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,2DAA8E;AAC9E,iEAA+D;AAC/D,8GAGwE;AACxE,+EAA6E;AAE7E,iFAA+E;AAC/E,oEAA6H;AAE7H,SAAS,OAAO,CAAC,KAAa;IAC1B,OAAO,IAAA,uBAAa,EAAC,IAAA,4BAAkB,EAAC,KAAK,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,IAAI,CAAC,IAAY,EAAE,KAAa,EAAE,GAAW;IAClD,MAAM,CAAC,GAAG,IAAI,8BAAc,EAAE,CAAC;IAC/B,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC,CAAC,MAAM,CAAC,GAAG,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AG,CAAC,CAAC;YACtD,IAAA,2BAAiB,EAAC,IAAA,uBAAa,EAAC,CAAC,CAAC,QAAQ,EAAG,CAAC,CAAC;SAClD,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;YACjB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC;YACrD,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC;SACvD,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * LM-364 — a TipsInput with cost_basis (20): non-default elections and two
3
+ * TaxLotProto lots round-trip unchanged.
4
+ *
5
+ * The enum values are all non-zero: value 0 is not written on the wire.
6
+ */
7
+
8
+ import { CostBasisInput, ProductInput, TipsInput } from './product_inputs_pb';
9
+ import { ValuationRequestProto } from './valuation_request_pb';
10
+ import {
11
+ AmortisationElectionsProto, MarketDiscountAccrualMethodProto, MarketDiscountInclusionProto,
12
+ PremiumAmortisationElectionProto,
13
+ } from '../../../fintekkers/models/portfolio/amortisation_elections_pb';
14
+ import { TaxLotProto } from '../../../fintekkers/models/position/tax_lot_pb';
15
+ import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
16
+ import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
17
+ import { decodeDecimal, encodeDecimal, parseDecimalString, toCanonicalString } from '../../../wrappers/models/utils/decimal';
18
+
19
+ function decimal(value: string): DecimalValueProto {
20
+ return encodeDecimal(parseDecimalString(value));
21
+ }
22
+
23
+ function date(year: number, month: number, day: number): LocalDateProto {
24
+ const d = new LocalDateProto();
25
+ d.setYear(year);
26
+ d.setMonth(month);
27
+ d.setDay(day);
28
+ return d;
29
+ }
30
+
31
+ function lot(openDate: LocalDateProto, openQuantity: string, price: string): TaxLotProto {
32
+ const l = new TaxLotProto();
33
+ l.setOpenDate(openDate);
34
+ l.setOpenQuantity(decimal(openQuantity));
35
+ l.setPrice(decimal(price));
36
+ return l;
37
+ }
38
+
39
+ describe('TipsInput cost_basis (20)', () => {
40
+ test('non-default elections and two lots round-trip unchanged', () => {
41
+ const elections = new AmortisationElectionsProto();
42
+ elections.setBondPremium(PremiumAmortisationElectionProto.PREMIUM_NOT_ELECTED);
43
+ elections.setMarketDiscountInclusion(MarketDiscountInclusionProto.INCLUDE_CURRENTLY);
44
+ elections.setMarketDiscountAccrual(MarketDiscountAccrualMethodProto.CONSTANT_YIELD);
45
+ const costBasis = new CostBasisInput();
46
+ costBasis.setElections(elections);
47
+ costBasis.addLots(lot(date(2024, 1, 15), '10000', '98.25'));
48
+ costBasis.addLots(lot(date(2025, 6, 2), '5000', '101.50'));
49
+ const tips = new TipsInput();
50
+ tips.setCleanPrice(decimal('97.50'));
51
+ tips.setCostBasis(costBasis);
52
+ const productInput = new ProductInput();
53
+ productInput.setTips(tips);
54
+ const request = new ValuationRequestProto();
55
+ request.setProductInput(productInput);
56
+
57
+ const decoded = ValuationRequestProto.deserializeBinary(request.serializeBinary()).getProductInput()!.getTips()!;
58
+ expect(decoded.toObject()).toEqual(tips.toObject());
59
+
60
+ expect(decoded.hasCostBasis()).toBe(true);
61
+ const parsed = decoded.getCostBasis()!;
62
+ expect(parsed.hasElections()).toBe(true);
63
+ const e = parsed.getElections()!;
64
+ expect(e.getBondPremium()).toBe(PremiumAmortisationElectionProto.PREMIUM_NOT_ELECTED);
65
+ expect(e.getMarketDiscountInclusion()).toBe(MarketDiscountInclusionProto.INCLUDE_CURRENTLY);
66
+ expect(e.getMarketDiscountAccrual()).toBe(MarketDiscountAccrualMethodProto.CONSTANT_YIELD);
67
+
68
+ const lots = parsed.getLotsList().map(l => [
69
+ l.getOpenDate()!.toObject(),
70
+ toCanonicalString(decodeDecimal(l.getOpenQuantity()!)),
71
+ toCanonicalString(decodeDecimal(l.getPrice()!)),
72
+ ]);
73
+ expect(lots).toEqual([
74
+ [{ year: 2024, month: 1, day: 15 }, '10000', '98.25'],
75
+ [{ year: 2025, month: 6, day: 2 }, '5000', '101.50'],
76
+ ]);
77
+ });
78
+ });
@@ -5,6 +5,8 @@
5
5
  /* eslint-disable */
6
6
 
7
7
  import * as jspb from "google-protobuf";
8
+ import * as fintekkers_models_portfolio_amortisation_elections_pb from "../../../fintekkers/models/portfolio/amortisation_elections_pb";
9
+ import * as fintekkers_models_position_tax_lot_pb from "../../../fintekkers/models/position/tax_lot_pb";
8
10
  import * as fintekkers_models_security_security_pb from "../../../fintekkers/models/security/security_pb";
9
11
  import * as fintekkers_models_security_index_index_type_pb from "../../../fintekkers/models/security/index/index_type_pb";
10
12
  import * as fintekkers_models_util_decimal_value_pb from "../../../fintekkers/models/util/decimal_value_pb";
@@ -72,6 +74,11 @@ export class BondInput extends jspb.Message {
72
74
  getBenchmarkCurve(): SecurityBasedCurveInput | undefined;
73
75
  setBenchmarkCurve(value?: SecurityBasedCurveInput): BondInput;
74
76
 
77
+ hasCostBasis(): boolean;
78
+ clearCostBasis(): void;
79
+ getCostBasis(): CostBasisInput | undefined;
80
+ setCostBasis(value?: CostBasisInput): BondInput;
81
+
75
82
  serializeBinary(): Uint8Array;
76
83
  toObject(includeInstance?: boolean): BondInput.AsObject;
77
84
  static toObject(includeInstance: boolean, msg: BondInput): BondInput.AsObject;
@@ -87,6 +94,7 @@ export namespace BondInput {
87
94
  security?: fintekkers_models_security_security_pb.SecurityProto.AsObject,
88
95
  cleanPrice?: fintekkers_models_util_decimal_value_pb.DecimalValueProto.AsObject,
89
96
  benchmarkCurve?: SecurityBasedCurveInput.AsObject,
97
+ costBasis?: CostBasisInput.AsObject,
90
98
  }
91
99
  }
92
100
 
@@ -107,6 +115,11 @@ export class TipsInput extends jspb.Message {
107
115
  getCpi(): InflationIndexInput | undefined;
108
116
  setCpi(value?: InflationIndexInput): TipsInput;
109
117
 
118
+ hasCostBasis(): boolean;
119
+ clearCostBasis(): void;
120
+ getCostBasis(): CostBasisInput | undefined;
121
+ setCostBasis(value?: CostBasisInput): TipsInput;
122
+
110
123
  serializeBinary(): Uint8Array;
111
124
  toObject(includeInstance?: boolean): TipsInput.AsObject;
112
125
  static toObject(includeInstance: boolean, msg: TipsInput): TipsInput.AsObject;
@@ -122,6 +135,35 @@ export namespace TipsInput {
122
135
  security?: fintekkers_models_security_security_pb.SecurityProto.AsObject,
123
136
  cleanPrice?: fintekkers_models_util_decimal_value_pb.DecimalValueProto.AsObject,
124
137
  cpi?: InflationIndexInput.AsObject,
138
+ costBasis?: CostBasisInput.AsObject,
139
+ }
140
+ }
141
+
142
+ export class CostBasisInput extends jspb.Message {
143
+
144
+ hasElections(): boolean;
145
+ clearElections(): void;
146
+ getElections(): fintekkers_models_portfolio_amortisation_elections_pb.AmortisationElectionsProto | undefined;
147
+ setElections(value?: fintekkers_models_portfolio_amortisation_elections_pb.AmortisationElectionsProto): CostBasisInput;
148
+ clearLotsList(): void;
149
+ getLotsList(): Array<fintekkers_models_position_tax_lot_pb.TaxLotProto>;
150
+ setLotsList(value: Array<fintekkers_models_position_tax_lot_pb.TaxLotProto>): CostBasisInput;
151
+ addLots(value?: fintekkers_models_position_tax_lot_pb.TaxLotProto, index?: number): fintekkers_models_position_tax_lot_pb.TaxLotProto;
152
+
153
+ serializeBinary(): Uint8Array;
154
+ toObject(includeInstance?: boolean): CostBasisInput.AsObject;
155
+ static toObject(includeInstance: boolean, msg: CostBasisInput): CostBasisInput.AsObject;
156
+ static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
157
+ static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
158
+ static serializeBinaryToWriter(message: CostBasisInput, writer: jspb.BinaryWriter): void;
159
+ static deserializeBinary(bytes: Uint8Array): CostBasisInput;
160
+ static deserializeBinaryFromReader(message: CostBasisInput, reader: jspb.BinaryReader): CostBasisInput;
161
+ }
162
+
163
+ export namespace CostBasisInput {
164
+ export type AsObject = {
165
+ elections?: fintekkers_models_portfolio_amortisation_elections_pb.AmortisationElectionsProto.AsObject,
166
+ lotsList: Array<fintekkers_models_position_tax_lot_pb.TaxLotProto.AsObject>,
125
167
  }
126
168
  }
127
169
 
@@ -241,6 +283,11 @@ export class FrnInput extends jspb.Message {
241
283
  setFixingsList(value: Array<ReferenceRateFixingProto>): FrnInput;
242
284
  addFixings(value?: ReferenceRateFixingProto, index?: number): ReferenceRateFixingProto;
243
285
 
286
+ hasCostBasis(): boolean;
287
+ clearCostBasis(): void;
288
+ getCostBasis(): CostBasisInput | undefined;
289
+ setCostBasis(value?: CostBasisInput): FrnInput;
290
+
244
291
  serializeBinary(): Uint8Array;
245
292
  toObject(includeInstance?: boolean): FrnInput.AsObject;
246
293
  static toObject(includeInstance: boolean, msg: FrnInput): FrnInput.AsObject;
@@ -257,6 +304,7 @@ export namespace FrnInput {
257
304
  cleanPrice?: fintekkers_models_util_decimal_value_pb.DecimalValueProto.AsObject,
258
305
  curve?: YieldCurveInput.AsObject,
259
306
  fixingsList: Array<ReferenceRateFixingProto.AsObject>,
307
+ costBasis?: CostBasisInput.AsObject,
260
308
  }
261
309
  }
262
310