@@ -139,19 +139,29 @@ export const collapseSmallPayments = (
139139 }
140140 const totalAmount = tempTxGroup . reduce ( ( sum , p ) => sum + Number ( p . amount ) , 0 )
141141 const totalValue = tempTxGroup . reduce ( ( sum , p ) => sum + Number ( getTransactionValue ( p ) [ currency ] ) , 0 )
142- const uniquePrices = new Set ( )
142+ const uniquePrices : Set < number > = new Set ( )
143+ const quoteId = QUOTE_IDS [ currency . toUpperCase ( ) ]
143144 tempTxGroup
144145 . forEach ( tx => {
145- const price = tx . prices . find ( p => p . price . quoteId === QUOTE_IDS [ currency . toUpperCase ( ) ] ) ! . price . value
146+ const price = tx . prices . find ( p => p . price . quoteId === quoteId ) ! . price . value
146147 uniquePrices . add ( Number ( price ) )
147148 } )
148149 if ( uniquePrices . size !== 1 ) {
150+ if ( uniquePrices . size > 1 ) {
151+ const nonUniquePrices = [ ...uniquePrices ]
152+ const txsForPrice : Record < number , string [ ] > = { }
153+ nonUniquePrices . forEach ( nonUniquePrice => {
154+ txsForPrice [ nonUniquePrice ] = tempTxGroup . filter ( tx => nonUniquePrice === tx . prices . find ( p => p . price . quoteId === quoteId ) ! . price . value . toNumber ( ) ) . map ( tx => tx . id )
155+ } )
156+ console . error ( 'ERROR DETAIL:' , { txsForPrice } )
157+ }
158+
149159 throw new Error (
150160 RESPONSE_MESSAGES
151161 . INVALID_PRICES_AMOUNT_FOR_TX_ON_CSV_CREATION_500 ( uniquePrices . size , groupKey , tempTxGroup . length , [ ...uniquePrices ] . join ( ',' ) ) . message
152162 )
153163 }
154- const rate = uniquePrices . values ( ) . next ( ) . value
164+ const rate = new Prisma . Decimal ( uniquePrices . values ( ) . next ( ) . value as number )
155165 const buttonName = tempTxGroup [ 0 ] . address . paybuttons [ 0 ] . paybutton . name
156166 const notes = `${ buttonName } - ${ tempTxGroup . length . toString ( ) } transactions`
157167
0 commit comments