Skip to content

Commit

Permalink
added state tax breakup in final sheet + logic flow fixed
Browse files Browse the repository at this point in the history
Signed-off-by: jenish.jain <jenish.jain@rapido.bike>
  • Loading branch information
jenishjain committed Jun 11, 2023
1 parent b0134b2 commit d3ba52e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 9 additions & 5 deletions internal/reporter/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions internal/types/invoice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -46,15 +46,15 @@ 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)
}
}
return purchaseInvoices

}

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])
Expand All @@ -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
}

Expand Down

0 comments on commit d3ba52e

Please sign in to comment.