@@ -160,7 +160,6 @@ impl ToXml for Details<'_> {
160160#[ cfg( test) ]
161161mod tests {
162162 use super :: * ;
163- use rust_decimal_macros:: dec;
164163
165164 use crate :: {
166165 reduction_and_surcharge:: { ReductionAndSurchargeValue , SurchargeListLineItem } ,
@@ -170,14 +169,14 @@ mod tests {
170169
171170 #[ test]
172171 fn rounds_line_item_amount_result_after_calculation ( ) {
173- let quantity = dec ! ( 0.005 ) ;
174- let unit_price = dec ! ( 0.005 ) ;
172+ let quantity = Decimal :: new ( 5 , 3 ) ;
173+ let unit_price = Decimal :: new ( 5 , 3 ) ;
175174
176175 let result = DetailsItem :: new (
177176 quantity,
178177 "KGM" ,
179178 unit_price,
180- TaxItem :: new ( dec ! ( 20 ) , TaxCategory :: S ) ,
179+ TaxItem :: new ( Decimal :: from ( 20 ) , TaxCategory :: S ) ,
181180 )
182181 . with_description ( "Sand" )
183182 . to_xml ( ) ;
@@ -190,14 +189,14 @@ mod tests {
190189
191190 #[ test]
192191 fn rounds_correctly_up ( ) {
193- let quantity = dec ! ( 100.123456 ) ;
194- let unit_price = dec ! ( 10.20005 ) ;
192+ let quantity = Decimal :: new ( 100123456 , 6 ) ;
193+ let unit_price = Decimal :: new ( 1020005 , 5 ) ;
195194
196195 let result = DetailsItem :: new (
197196 quantity,
198197 "KGM" ,
199198 unit_price,
200- TaxItem :: new ( dec ! ( 20 ) , TaxCategory :: S ) ,
199+ TaxItem :: new ( Decimal :: from ( 20 ) , TaxCategory :: S ) ,
201200 )
202201 . with_description ( "Sand" )
203202 . to_xml ( ) ;
@@ -211,15 +210,15 @@ mod tests {
211210 #[ test]
212211 fn calculates_reduction_correctly ( ) {
213212 let result = DetailsItem :: new (
214- dec ! ( 1 ) ,
213+ Decimal :: from ( 1 ) ,
215214 "STK" ,
216- dec ! ( 5.00 ) ,
217- TaxItem :: new ( dec ! ( 10 ) , TaxCategory :: AA ) ,
215+ Decimal :: from ( 5 ) ,
216+ TaxItem :: new ( Decimal :: from ( 10 ) , TaxCategory :: AA ) ,
218217 )
219218 . with_description ( "Handbuch zur Schraube" )
220219 . with_reduction ( ReductionListLineItem :: new (
221- dec ! ( 5 ) ,
222- ReductionAndSurchargeValue :: Amount ( dec ! ( 2.3399 ) ) ,
220+ Decimal :: from ( 5 ) ,
221+ ReductionAndSurchargeValue :: Amount ( Decimal :: new ( 23399 , 4 ) ) ,
223222 ) )
224223 . to_xml ( ) ;
225224
@@ -232,15 +231,15 @@ mod tests {
232231 #[ test]
233232 fn calculates_surcharge_correctly ( ) {
234233 let result = DetailsItem :: new (
235- dec ! ( 1 ) ,
234+ Decimal :: from ( 1 ) ,
236235 "STK" ,
237- dec ! ( 5.00 ) ,
238- TaxItem :: new ( dec ! ( 10 ) , TaxCategory :: AA ) ,
236+ Decimal :: from ( 5 ) ,
237+ TaxItem :: new ( Decimal :: from ( 10 ) , TaxCategory :: AA ) ,
239238 )
240239 . with_description ( "Handbuch zur Schraube" )
241240 . with_surcharge ( SurchargeListLineItem :: new (
242- dec ! ( 5 ) ,
243- ReductionAndSurchargeValue :: Amount ( dec ! ( 2 ) ) ,
241+ Decimal :: from ( 5 ) ,
242+ ReductionAndSurchargeValue :: Amount ( Decimal :: from ( 2 ) ) ,
244243 ) )
245244 . to_xml ( ) ;
246245
@@ -252,14 +251,14 @@ mod tests {
252251
253252 #[ test]
254253 fn rounds_correctly_down ( ) {
255- let quantity = dec ! ( 100.12344 ) ;
256- let unit_price = dec ! ( 10.20001 ) ;
254+ let quantity = Decimal :: new ( 10012344 , 5 ) ;
255+ let unit_price = Decimal :: new ( 1020001 , 5 ) ;
257256
258257 let result = DetailsItem :: new (
259258 quantity,
260259 "KGM" ,
261260 unit_price,
262- TaxItem :: new ( dec ! ( 20 ) , TaxCategory :: S ) ,
261+ TaxItem :: new ( Decimal :: from ( 20 ) , TaxCategory :: S ) ,
263262 )
264263 . with_description ( "Sand" )
265264 . to_xml ( ) ;
0 commit comments