@@ -19,7 +19,6 @@ import { BankTxReturnService } from '../../bank-tx/bank-tx-return/bank-tx-return
1919import { createCustomBankTx } from '../../bank-tx/bank-tx/__mocks__/bank-tx.entity.mock' ;
2020import { createCustomBank , yapealEUR } from '../../bank/bank/__mocks__/bank.entity.mock' ;
2121import { BankService } from '../../bank/bank/bank.service' ;
22- import { IbanBankName } from '../../bank/bank/dto/bank.dto' ;
2322import { createCustomVirtualIban } from '../../bank/virtual-iban/__mocks__/virtual-iban.entity.mock' ;
2423import { VirtualIbanService } from '../../bank/virtual-iban/virtual-iban.service' ;
2524import { createCustomLog } from '../../log/__mocks__/log.entity.mock' ;
@@ -185,19 +184,19 @@ describe('FiatOutputJobService', () => {
185184 } ) ;
186185
187186 describe ( 'setReadyDate' , ( ) => {
188- it ( 'should set ready date when balance is available and cryptoInput is confirmed ' , async ( ) => {
187+ it ( 'should set ready date for non-EUR transactions and skip EUR transactions ' , async ( ) => {
189188 jest . spyOn ( fiatOutputRepo , 'find' ) . mockResolvedValue ( [
190189 createCustomFiatOutput ( {
191190 id : 1 ,
192- accountIban : 'DE123456789 ' ,
191+ accountIban : 'CH123456789 ' ,
193192 iban : 'CH123456789' ,
194193 isReadyDate : null ,
195194 buyFiats : [
196195 createCustomBuyFiat ( {
197196 cryptoInput : createCustomCryptoInput ( { isConfirmed : true , asset : createDefaultAsset ( ) } ) ,
198197 } ) ,
199198 ] ,
200- amount : 15000 ,
199+ amount : 100 ,
201200 currency : 'EUR' ,
202201 type : FiatOutputType . BUY_FIAT ,
203202 } ) ,
@@ -211,154 +210,61 @@ describe('FiatOutputJobService', () => {
211210 cryptoInput : createCustomCryptoInput ( { isConfirmed : true , asset : createDefaultAsset ( ) } ) ,
212211 } ) ,
213212 ] ,
214- amount : 5000 ,
213+ amount : 100 ,
215214 currency : 'CHF' ,
216215 type : FiatOutputType . BUY_FIAT ,
217216 } ) ,
218217 createCustomFiatOutput ( {
219218 id : 3 ,
220- accountIban : 'DE123456789 ' ,
219+ accountIban : 'CH123456789 ' ,
221220 iban : 'CH123456789' ,
222221 isReadyDate : null ,
223222 buyFiats : [
224223 createCustomBuyFiat ( {
225224 cryptoInput : createCustomCryptoInput ( { isConfirmed : true , asset : createDefaultAsset ( ) } ) ,
226225 } ) ,
227226 ] ,
228- amount : 100 ,
227+ amount : 200 ,
229228 currency : 'EUR' ,
230229 type : FiatOutputType . BUY_FIAT ,
231230 } ) ,
232231 createCustomFiatOutput ( {
233232 id : 4 ,
234- accountIban : 'DE123456789' ,
235- iban : 'CH123456789' ,
236- isReadyDate : null ,
237- buyFiats : [
238- createCustomBuyFiat ( {
239- cryptoInput : createCustomCryptoInput ( { isConfirmed : true , asset : createDefaultAsset ( ) } ) ,
240- } ) ,
241- ] ,
242- amount : 300 ,
243- currency : 'EUR' ,
244- type : FiatOutputType . BUY_FIAT ,
245- } ) ,
246- createCustomFiatOutput ( {
247- id : 5 ,
248- accountIban : 'DE123456789' ,
249- isReadyDate : null ,
250- amount : 9500 ,
251- currency : 'EUR' ,
252- type : FiatOutputType . LIQ_MANAGEMENT ,
253- } ) ,
254- createCustomFiatOutput ( {
255- id : 6 ,
256- accountIban : 'DE123456789' ,
257- iban : 'DE123459876' ,
258- isReadyDate : new Date ( ) ,
259- buyFiats : [
260- createCustomBuyFiat ( {
261- cryptoInput : createCustomCryptoInput ( { isConfirmed : true , asset : createDefaultAsset ( ) } ) ,
262- } ) ,
263- ] ,
264- amount : 1200 ,
265- currency : 'EUR' ,
266- type : FiatOutputType . BUY_FIAT ,
267- } ) ,
268- createCustomFiatOutput ( {
269- id : 7 ,
270- accountIban : 'DE123456789' ,
271- iban : 'CH123456789' ,
272- isReadyDate : null ,
273- buyFiats : [
274- createCustomBuyFiat ( {
275- cryptoInput : createCustomCryptoInput ( { isConfirmed : true , asset : createDefaultAsset ( ) } ) ,
276- amountInChf : 4000 ,
277- amountInEur : 4500 ,
278- } ) ,
279- ] ,
280- amount : 20000 ,
281- currency : 'AED' ,
282- type : FiatOutputType . BUY_FIAT ,
283- } ) ,
284- createCustomFiatOutput ( {
285- id : 8 ,
286- accountIban : 'DE123456789' ,
233+ accountIban : 'CH123456789' ,
287234 iban : 'CH123456789' ,
288235 isReadyDate : null ,
289- buyFiats : [
290- createCustomBuyFiat ( {
291- cryptoInput : createCustomCryptoInput ( { isConfirmed : true , asset : createDefaultAsset ( ) } ) ,
292- amountInChf : 20000 ,
293- amountInEur : 22000 ,
294- } ) ,
295- ] ,
296- amount : 400 ,
297- currency : 'XYZ' ,
298- type : FiatOutputType . BUY_FIAT ,
299- } ) ,
300- createCustomFiatOutput ( {
301- id : 9 ,
302- accountIban : 'CH4243843938' ,
303- iban : 'CH12345987645' ,
304- isReadyDate : new Date ( ) ,
305- buyFiats : [
306- createCustomBuyFiat ( {
307- cryptoInput : createCustomCryptoInput ( { isConfirmed : true , asset : createDefaultAsset ( ) } ) ,
308- } ) ,
309- ] ,
310- amount : 200 ,
311- currency : 'EUR' ,
312- type : FiatOutputType . BUY_FIAT ,
313- bank : createCustomBank ( { name : IbanBankName . YAPEAL , iban : 'CH475843938' } ) ,
314- } ) ,
315- createCustomFiatOutput ( {
316- id : 10 ,
317- accountIban : 'CH4244043938' ,
318- iban : 'CH12345987645' ,
319236 buyFiats : [
320237 createCustomBuyFiat ( {
321238 cryptoInput : createCustomCryptoInput ( { isConfirmed : true , asset : createDefaultAsset ( ) } ) ,
322239 } ) ,
323240 ] ,
324- amount : 100 ,
325- currency : 'EUR ' ,
241+ amount : 150 ,
242+ currency : 'USD ' ,
326243 type : FiatOutputType . BUY_FIAT ,
327- bank : createCustomBank ( { name : IbanBankName . YAPEAL , iban : 'CH475843938' } ) ,
328244 } ) ,
329245 ] ) ;
330246 jest . spyOn ( assetService , 'getAssetsWith' ) . mockResolvedValue ( [
331247 createCustomAsset ( {
332248 id : 1 ,
333249 type : AssetType . CUSTODY ,
334- bank : createCustomBank ( { iban : 'DE123456789' } ) ,
335- name : 'EUR' ,
336- balance : createCustomLiquidityBalance ( { amount : 13000 } ) ,
337- } ) ,
338- createCustomAsset ( {
339- id : 2 ,
340- type : AssetType . CUSTODY ,
341250 bank : createCustomBank ( { iban : 'CH123456789' } ) ,
342251 name : 'CHF' ,
343252 balance : createCustomLiquidityBalance ( { amount : 9000 } ) ,
344253 } ) ,
345- createCustomAsset ( {
346- id : 3 ,
347- type : AssetType . CUSTODY ,
348- bank : createCustomBank ( { iban : 'CH475843938' , name : IbanBankName . YAPEAL } ) ,
349- name : 'CHF' ,
350- balance : createCustomLiquidityBalance ( { amount : 500 } ) ,
351- } ) ,
352254 ] ) ;
353255
354256 await service [ 'setReadyDate' ] ( ) ;
355257
356258 const updateCalls = ( fiatOutputRepo . update as jest . Mock ) . mock . calls ;
357- expect ( updateCalls [ 0 ] [ 0 ] ) . toBe ( 3 ) ;
358- expect ( updateCalls [ 1 ] [ 0 ] ) . toBe ( 4 ) ;
359- expect ( updateCalls [ 2 ] [ 0 ] ) . toBe ( 7 ) ;
360- expect ( updateCalls [ 3 ] [ 0 ] ) . toBe ( 2 ) ;
361- expect ( updateCalls [ 4 ] [ 0 ] ) . toBe ( 10 ) ;
259+ const updatedIds = updateCalls . map ( ( call ) => call [ 0 ] ) ;
260+
261+ // EUR transactions (id 1 and 3) should NOT be updated
262+ expect ( updatedIds ) . not . toContain ( 1 ) ;
263+ expect ( updatedIds ) . not . toContain ( 3 ) ;
264+
265+ // Non-EUR transactions (id 2 CHF and id 4 USD) should be updated
266+ expect ( updatedIds ) . toContain ( 2 ) ;
267+ expect ( updatedIds ) . toContain ( 4 ) ;
362268 } ) ;
363269 } ) ;
364270
0 commit comments