@@ -70,7 +70,7 @@ func Test_service_Convert(t *testing.T) {
7070 },
7171 },
7272 want : & ConvertResponse {
73- Date : time .Date (2022 , time .December , 8 , 0 , 0 , 0 , 0 , time .Local ),
73+ Date : time .Date (2022 , time .December , 8 , 0 , 0 , 0 , 0 , time .UTC ),
7474 Amount : models.Money {
7575 Amount : 568 ,
7676 Currency : currencies .AED ,
@@ -195,7 +195,21 @@ func Test_service_Calculate(t *testing.T) {
195195 Amount : 1067.99 ,
196196 Currency : currencies .GEL ,
197197 },
198- IncomeConverted : models.Money {
198+ Incomes : []ConvertResponse {
199+ {
200+ Date : time .Date (2022 , time .December , 8 , 0 , 0 , 0 , 0 , time .UTC ),
201+ Amount : models.Money {
202+ Amount : 1000 ,
203+ Currency : currencies .EUR ,
204+ },
205+ Converted : models.Money {
206+ Amount : 1000 ,
207+ Currency : currencies .GEL ,
208+ },
209+ Rate : models .NewMoney (1 , "" ),
210+ },
211+ },
212+ TotalIncomeConverted : models.Money {
199213 Amount : 1000 ,
200214 Currency : currencies .GEL ,
201215 },
@@ -247,7 +261,33 @@ func Test_service_Calculate(t *testing.T) {
247261 Amount : 1267.99 ,
248262 Currency : currencies .GEL ,
249263 },
250- IncomeConverted : models.Money {
264+ Incomes : []ConvertResponse {
265+ {
266+ Date : time .Date (2022 , time .December , 8 , 0 , 0 , 0 , 0 , time .UTC ),
267+ Amount : models.Money {
268+ Amount : 1000 ,
269+ Currency : currencies .EUR ,
270+ },
271+ Converted : models.Money {
272+ Amount : 1000 ,
273+ Currency : currencies .GEL ,
274+ },
275+ Rate : models .NewMoney (1 , "" ),
276+ },
277+ {
278+ Date : time .Date (2023 , time .June , 8 , 0 , 0 , 0 , 0 , time .UTC ),
279+ Amount : models.Money {
280+ Amount : 200 ,
281+ Currency : currencies .USD ,
282+ },
283+ Converted : models.Money {
284+ Amount : 200 ,
285+ Currency : currencies .GEL ,
286+ },
287+ Rate : models .NewMoney (1 , "" ),
288+ },
289+ },
290+ TotalIncomeConverted : models.Money {
251291 Amount : 1200 ,
252292 Currency : currencies .GEL ,
253293 },
@@ -331,62 +371,61 @@ func Test_service_Calculate(t *testing.T) {
331371}
332372
333373func TestCalculateResponse_String (t * testing.T ) {
334- type fields struct {
335- Date time.Time
336- TaxRate taxes.TaxRate
337- YearIncome models.Money
338- Income models.Money
339- IncomeConverted models.Money
340- Tax models.Money
341- }
342-
343374 tests := []struct {
344375 name string
345- fields fields
376+ fields CalculateResponse
346377 want string
347378 }{
348379 {
349- name : "" ,
350- fields : fields {
351- Date : time .Date (2022 , time .December , 8 , 0 , 0 , 0 , 0 , time .Local ),
380+ name : "one income" ,
381+ fields : CalculateResponse {
352382 TaxRate : taxes.TaxRate {
353383 Type : taxes .TaxTypeEmployment ,
354384 Rate : 0.2 ,
355385 },
356386 YearIncome : models.Money {
357- Amount : 0 ,
387+ Amount : 1267.99 ,
358388 Currency : currencies .GEL ,
359389 },
360- Income : models.Money {
361- Amount : 568.99 ,
362- Currency : currencies .AED ,
390+ Incomes : []ConvertResponse {
391+ {
392+ Date : time .Date (2022 , time .December , 8 , 0 , 0 , 0 , 0 , time .UTC ),
393+ Amount : models.Money {
394+ Amount : 568.99 ,
395+ Currency : currencies .AED ,
396+ },
397+ Converted : models.Money {
398+ Amount : 789.99 ,
399+ Currency : currencies .GEL ,
400+ },
401+ Rate : models .NewMoney (1.39 , "" ),
402+ },
363403 },
364- IncomeConverted : models.Money {
404+ TotalIncomeConverted : models.Money {
365405 Amount : 789.99 ,
366- Currency : currencies .EUR ,
406+ Currency : currencies .GEL ,
367407 },
368408 Tax : models.Money {
369- Amount : 99.02 ,
370- Currency : currencies .AMD ,
409+ Amount : 157.99 ,
410+ Currency : currencies .GEL ,
371411 },
372412 },
373413 want : "Tax Rate: Employment 20 %\n " +
374- "Year Income: 0 GEL\n " +
375- "Converted: 789.99 EUR\n " +
376- "Taxes: 99.02 AMD" ,
414+ "Year Income: 1267.99 GEL\n " +
415+ "Incomes:\n " +
416+ "\t - 1:\n " +
417+ "\t \t Date: 2022-12-08\n " +
418+ "\t \t Amount: 568.99 AED\n " +
419+ "\t \t Converted: 789.99 GEL\n " +
420+ "\t \t Rate: 1.39\n " +
421+ "Total Income Converted: 789.99 GEL\n " +
422+ "Taxes: 157.99 GEL" ,
377423 },
378424 }
379425
380426 for _ , tt := range tests {
381427 t .Run (tt .name , func (t * testing.T ) {
382- c := CalculateResponse {
383- TaxRate : tt .fields .TaxRate ,
384- YearIncome : tt .fields .YearIncome ,
385- IncomeConverted : tt .fields .IncomeConverted ,
386- Tax : tt .fields .Tax ,
387- }
388-
389- assert .Equalf (t , tt .want , c .String (), "String()" )
428+ assert .Equalf (t , tt .want , tt .fields .String (), "String()" )
390429 })
391430 }
392431}
@@ -407,7 +446,7 @@ func TestConvertResponse_String(t *testing.T) {
407446 {
408447 name : "" ,
409448 fields : fields {
410- Date : time .Date (2022 , time .December , 8 , 0 , 0 , 0 , 0 , time .Local ),
449+ Date : time .Date (2022 , time .December , 8 , 0 , 0 , 0 , 0 , time .UTC ),
411450 Amount : models.Money {
412451 Amount : 568.99 ,
413452 Currency : currencies .AED ,
0 commit comments