Results 1 to 7 of 7

Thread: Performing A Silly Logic In Gambas?

  1. #1
    Join Date
    Oct 2008
    Location
    INDIA
    Beans
    331
    Distro
    Ubuntu 12.04 Precise Pangolin

    Thumbs down 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.

    Please help.
    Controlling complexity is the essence of computer programming. - Brian

  2. #2
    Join Date
    Oct 2008
    Location
    INDIA
    Beans
    331
    Distro
    Ubuntu 12.04 Precise Pangolin

    Thumbs down Re: Performing A Silly Logic In Gambas?

    anybody please help...
    Controlling complexity is the essence of computer programming. - Brian

  3. #3
    Join Date
    May 2006
    Beans
    1,787

    Re: Performing A Silly Logic In Gambas?

    Quote Originally Posted by etdsbastar View Post
    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.

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

  4. #4
    Join Date
    Oct 2008
    Location
    INDIA
    Beans
    331
    Distro
    Ubuntu 12.04 Precise Pangolin

    Red face 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.
    Controlling complexity is the essence of computer programming. - Brian

  5. #5
    Join Date
    Oct 2008
    Location
    INDIA
    Beans
    331
    Distro
    Ubuntu 12.04 Precise Pangolin

    Wink Re: Performing A Silly Logic In Gambas?

    If anyone wants more information please intimate.
    Controlling complexity is the essence of computer programming. - Brian

  6. #6
    Join Date
    May 2006
    Beans
    1,787

    Re: Performing A Silly Logic In Gambas?

    Quote Originally Posted by etdsbastar View Post
    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. #7
    Join Date
    Oct 2008
    Location
    INDIA
    Beans
    331
    Distro
    Ubuntu 12.04 Precise Pangolin

    Red face 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.
    Controlling complexity is the essence of computer programming. - Brian

Tags for this Thread

Bookmarks

Posting Permissions

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