diff --git a/internal/reporter/reporter.go b/internal/reporter/reporter.go index 78fce06..b134d12 100644 --- a/internal/reporter/reporter.go +++ b/internal/reporter/reporter.go @@ -181,19 +181,23 @@ func (r reporterImpl) GetSheetValuesToPublishReport(taxReport taxReport, month t tinToStateDetailsMap := getTinToStateDetailsMap() stateTaxBlock := [][]interface{}{ {"G )", "Total payable tax as per following states"}, + {}, {"sr no.", "Name of state", "I.G.S.T", "C.G.S.T", "S.G.S.T", "Total Tax"}, {}, } for stateCode, taxBreakup := range taxReport.StateTaxBreakup { - //fmt.Println(stateCode, taxBreakup.PayableTax.GetTotalTax()) var stateEntry []interface{} - if stateCode != "**" { - purchaseTax := taxBreakup.TaxOnPurchase - stateEntry = append(stateEntry, nil, tinToStateDetailsMap[stateCode].StateName, purchaseTax.GetIGST(), purchaseTax.GetCGST(), purchaseTax.GetSGST(), purchaseTax.GetTotalTax()) + payableTax := taxBreakup.PayableTax + if stateCode != "**" && payableTax.GetTotalTax() != 0 { + stateEntry = append(stateEntry, nil, tinToStateDetailsMap[stateCode].StateName, payableTax.GetIGST(), payableTax.GetCGST(), payableTax.GetSGST(), payableTax.GetTotalTax()) stateTaxBlock = append(stateTaxBlock, stateEntry) } - } + totalSalesTax := taxReport.TotalSales.Tax + stateTaxBlock = append(stateTaxBlock, + []interface{}{}, + []interface{}{nil, "TOTAL", totalSalesTax.GetIGST(), totalSalesTax.GetCGST(), totalSalesTax.GetSGST(), totalSalesTax.GetTotalTax()}) + values = append(values, stateTaxBlock...) return values diff --git a/internal/types/invoice/service.go b/internal/types/invoice/service.go index 833567c..fc8e061 100644 --- a/internal/types/invoice/service.go +++ b/internal/types/invoice/service.go @@ -30,7 +30,7 @@ func (s serviceImpl) GetAllPurchaseInvoices(ctx context.Context) []Invoice { for index, row := range offlineSalesRecords { if index > 0 { - invoice := getInvoiceFromRow(row) + invoice := getInvoiceFromRow(row, Purchase) purchaseInvoices = append(purchaseInvoices, invoice) } } @@ -46,7 +46,7 @@ func (s serviceImpl) GetAllSalesInvoices(ctx context.Context) []Invoice { var purchaseInvoices []Invoice for index, row := range offlinePurchaseRecords { if index > 0 { - invoice := getInvoiceFromRow(row) + invoice := getInvoiceFromRow(row, Sales) purchaseInvoices = append(purchaseInvoices, invoice) } } @@ -54,7 +54,7 @@ func (s serviceImpl) GetAllSalesInvoices(ctx context.Context) []Invoice { } -func getInvoiceFromRow(row []interface{}) Invoice { +func getInvoiceFromRow(row []interface{}, transactionType invoiceType) Invoice { totalAmount := parseFloat(fmt.Sprintf("%s", row[6])) invoiceDate, _ := time.Parse("2006-01-02", fmt.Sprintf("%s", row[1])) invoiceNo := fmt.Sprintf("%s", row[2]) @@ -65,7 +65,7 @@ func getInvoiceFromRow(row []interface{}) Invoice { igst := parseFloat(fmt.Sprintf("%s", row[9])) invoiceTransaction := transaction.New(totalAmount, tax.New(cgst, sgst, igst)) - invoice := New(Purchase, invoiceDate, invoiceNo, partyName, gstNo, invoiceTransaction, "offline") + invoice := New(transactionType, invoiceDate, invoiceNo, partyName, gstNo, invoiceTransaction, "offline") return invoice }