# Thread: Performing A Silly Logic In Gambas?

1. ## Performing A Silly Logic In Gambas?

Hello friends,

I stuck in a simple coding in one project. Actually I want to put a fine of 10% if the Tax Payment exceeds the current financial year (i.e. 31st March).

For example:

Today is 09th of August 2011

If someone pays the tax payment on 1st of April 2012 or on any above date then I want to apply a surcharge of 10% on per year basis. Same will do for next year and so on...

How to do it.

2. ## Re: Performing A Silly Logic In Gambas?

3. Ubuntu Cappuccino Scuro
Join Date
May 2006
Beans
1,787

## Re: Performing A Silly Logic In Gambas?

Originally Posted by etdsbastar
Hello friends,

I stuck in a simple coding in one project. Actually I want to put a fine of 10% if the Tax Payment exceeds the current financial year (i.e. 31st March).

For example:

Today is 09th of August 2011

If someone pays the tax payment on 1st of April 2012 or on any above date then I want to apply a surcharge of 10% on per year basis. Same will do for next year and so on...

How to do it.

Apart from the fine, what does the program actually do? What is the input, and what is the output?

4. ## Re: Performing A Silly Logic In Gambas?

Thanks for the reply.

Its just a financial year calculation of Tax (1st April) to (31st March) of any Financial year. I just want to add a % of tax to the payments which are paid after 31st March of current financial year.

Here is the sample code which I wrote:

Code:
```PUBLIC SUB txtPaymentAmount_LostFocus()

DIM finEndDay, finEndMonth, finEndYear AS Integer
DIM dtVal AS String
DIM finEndDate AS Date

finEndDay = 1
finEndMonth = 4
finEndYear = Year(Now)

dtVal = finEndDay & "/" & finEndMonth & "/" & finEndYear

finEndDate = Support.StringToDate(dtVal, FALSE)

IF CDate(txtPaymentDate.Text) < finEndDate THEN
lblAmtAfterLateFee.Caption = CFloat(txtPaymentAmount.Text) * (CFloat(Support.GetConfigValue("Settings/lf", 6.25)) / 100)
ELSE
lblAmtAfterLateFee.Caption = "0.00"
ENDIF

CATCH
END```
But the above code is not working properly.

5. ## Re: Performing A Silly Logic In Gambas?

6. Ubuntu Cappuccino Scuro
Join Date
May 2006
Beans
1,787

## Re: Performing A Silly Logic In Gambas?

Originally Posted by etdsbastar
Thanks for the reply.

Its just a financial year calculation of Tax (1st April) to (31st March) of any Financial year. I just want to add a % of tax to the payments which are paid after 31st March of current financial year.

Here is the sample code which I wrote:

Code:
```PUBLIC SUB txtPaymentAmount_LostFocus()

DIM finEndDay, finEndMonth, finEndYear AS Integer
DIM dtVal AS String
DIM finEndDate AS Date

finEndDay = 1
finEndMonth = 4
finEndYear = Year(Now)

dtVal = finEndDay & "/" & finEndMonth & "/" & finEndYear

finEndDate = Support.StringToDate(dtVal, FALSE)

IF CDate(txtPaymentDate.Text) < finEndDate THEN
lblAmtAfterLateFee.Caption = CFloat(txtPaymentAmount.Text) * (CFloat(Support.GetConfigValue("Settings/lf", 6.25)) / 100)
ELSE
lblAmtAfterLateFee.Caption = "0.00"
ENDIF

CATCH
END```
But the above code is not working properly.
So what happens instead?

7. ## Re: Performing A Silly Logic In Gambas?

The problem has been solved with the following code:

Code:
```PRIVATE FUNCTION CalculateTax(amount AS Float) AS Float

DIM \$Fiscal AS String
DIM \$FiscalStart AS String
DIM iDateDiff AS Integer
DIM iDateDiffStart AS Integer
DIM iYearDiff AS Integer
DIM iYearDiffStart AS Integer

\$Fiscal = Date(Year(Now) + 1, 03, 31)
\$FiscalStart = Date(Year(Now), 04, 01)

iDateDiff = DateDiff(\$Fiscal, CDate(txtPaymentDate.Text), gb.Day)

IF iDateDiff > 0 THEN
amount = CFloat(txtPaymentAmount.Text) * (CFloat(Support.GetConfigValue("Settings/lf", 6.25)) / 100)
IF Year(CDate(txtPaymentDate.Text)) > Year(Now) THEN
iYearDiff = Year(CDate(txtPaymentDate.Text)) - Year(Now)
amount = amount * iYearDiff
ELSE
amount = CFloat(txtPaymentAmount.Text) * (CFloat(Support.GetConfigValue("Settings/lf", 6.25)) / 100)
ENDIF
ELSE
IF Year(CDate(txtPaymentDate.Text)) < Year(Now) THEN
amount = CFloat(txtPaymentAmount.Text) * (CFloat(Support.GetConfigValue("Settings/lf", 6.25)) / 100)
iYearDiffStart = Abs(Year(CDate(txtPaymentDate.Text)) - Year(\$FiscalStart))
amount = amount * iYearDiffStart
ELSE
amount = 0
ENDIF
ENDIF

RETURN amount

END```
Please suggest any corrections or modifications if needed.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•