GithubHelp home page GithubHelp logo

fiscali's People

Contributors

asanghi avatar chiperific avatar maxwell avatar mikaji avatar moubry avatar mxie avatar reed avatar ryoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fiscali's Issues

Fiscal zone set in initializer but not remembered in app

My project sets Date.fiscal_zone in an initializer, but the app is acting like Date.fiscal_zone is still nil. Looking at your code, it looks like this is caused by this being stored in the Thread.current hash - the initializer is being run in a different thread than the application itself, and so modifications to the Thread.current hash in the initializer don't carry over.

Here's an example of what's happening - I triggered the debugger at the end of the initializer and in the controller:

=> Rails 3.1.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
/Users/sagroup/.rvm/gems/ruby-1.9.2-p290-patched@drachmas/gems/activesupport-3.1.6/lib/active_support/dependencies.rb:641
aborting = false
(rdb:1) pp Date.fiscal_zone
:us
(rdb:1) pp Thread.current[:fiscali_zone]
:us
(rdb:1) pp Thread.current
# <Thread:0x00000109c3b360 run>

(rdb:1) cont
[2012-07-12 11:36:38] INFO  WEBrick 1.3.1
[2012-07-12 11:36:38] INFO  ruby 1.9.2 (2011-07-09) [x86_64-darwin11.3.0]
[2012-07-12 11:36:38] INFO  WEBrick::HTTPServer#start: pid=41940 port=3000
/Users/sagroup/dev/drachmas3/app/controllers/core_dashboard_controller.rb:22
dt = params[:dt] || Date.today.beginning_of_financial_q1
(rdb:2) pp Date.fiscal_zone
nil
(rdb:2) pp Thread.current[:fiscali_zone]
nil
(rdb:2) pp Thread.current
# <Thread:0x0000012ffcd2a0 run>```

Date vs. DateTime

irb(main):005:0> @start_date = Date.new(2013,2,1) => Fri, 01 Feb 2013 irb(main):006:0> @start_date.financial_year #correct => 2013 irb(main):007:0> @start_date.beginning_of_financial_year => Mon, 01 Jul 2013 #correct irb(main):008:0> @second_date = DateTime.new(2013,2,1) => Fri, 01 Feb 2013 00:00:00 +0000 irb(main):009:0> @second_date.financial_year => 2014 #incorrect irb(main):010:0> @second_date.beginning_of_financial_year => Wed, 01 Jan 2014 00:00:00 +0000 #incorrect

Seems to struggle to differentiate between Date and DateTime, maybe?

Wrong fiscal_year_start

I found an inconsistency and potential bug in the gem:

>> Date.fiscal_zone
:us
>> Date.uses_forward_year?
true
>> Date.today
Mon, 08 Oct 2018
>> Date.today.financial_year
2019
>> Date.financial_year_start
Mon, 01 Oct 2018
>> Date.financial_year_start(2019)
Tue, 01 Oct 2019

The last statement returns a wrong result. The financial_year_start of 2019 should be Mon, 01 Oct 2018 not Tue, 01 Oct 2019.

How to extend the functionality of this gem

Hi,

I am still learning Ruby and Rails. I'd like to define my own method on this that does the following.

Assuming I am in financial year 2014 I can call Date.today.financial_periods and have an array [201501,201502,201503,201504,201505,201506,201507,201508,201509,201510,201511,201512] returned.

Where would I put this to define it?

I have tried creating a new file under my lib directory called fiscali.rb and adding

module RisingSun
  module Fiscali
    def financial_periods
      year = self.financial_year
      financial_periods = []
      (1..12).each do |period|
        period.format("%02d",4)
        financial_periods << period
      end
    end
  end
end

But no luck... ๐Ÿ˜–

Add configuration for fiscal year start week

I love that you have a configuration for start_month. However, it would also be nice to have a similar configuration for start_week, because some companies start their fiscal years in the middle of the month โ€” for example, the 4th week of a month.

Start week would be an integer ranging from 1โ€“5. By default it would be 1, since most companies start their fiscal year in the first week of the month.

I quickly spiked-out a working version of this change here: moubry@9121ba2. Tests pass.

not > rails-3.0 compliant

fiscali-1.2.5/lib/rising_sun/fiscali.rb:16:in fiscal_zone=': undefined methodwrite_inheritable_attribute' for Date:Class (NoMethodError)

... simply trying to launch the console on an otherwise empty rails-3.1 or rails-3.2 project

Docs are out of date

Under Using in your rails project it says:

Date.fiscal_zone = :india
Time.fiscal_zone = :india
or Date.start_month = 4

When setting it manually I had to use:
Date.fy_start_month=4

It may also be worth noting that you have to set it for each class Date, Time, and DateTime, so my initializer looks like:

Date.fy_start_month = 2
Time.fy_start_month = 2
DateTime.fy_start_month = 2

financial_year flexibility

Not really a bug, but a feature request. GREAT gem, by the way. Saved me hours!

Fiscal years are often named future-tense. For example, July 2012 - June 2013 is referred to as FY 2013. Your system returns FY2012 here:

def financial_year self.month < start_month ? self.year - 1 : self.year end

I changed it to:
`def financial_year
self.month < start_month ? self.year : self.year + 1
end``

It might be nice to be able to set that as a default option.

Thanks again for a good, clean gem.

use_forward_year throws all calcs forward a year

In v2.2.0, with use_forward_year set on Date and Time and fiscal_zone set to :us, Date.today.financial_year returns 2014, which is correct, but now Date.today.beginning_of_financial_year and Date.today.end_of_financial_year return the start/end dates for FY 2015.

jruby-1.7.13 :018 > Date.today.financial_year
=> 2014
jruby-1.7.13 :019 > Date.today.beginning_of_financial_year
=> Wed, 01 Oct 2014
jruby-1.7.13 :020 > Date.today.end_of_financial_year
=> Wed, 30 Sep 2015
jruby-1.7.13 :023 > Date.uses_forward_year?
=> true

Dependency on ActiveSupport

Hi,

I'm using your gem in a Sinatra application, and don't have (nor want to install) ActiveSupport.

If I comment out the two ActiveSupport 'requires' in fiscali/lib/fiscali.rb everything appears to work for me, so should ActiveSupport be in the gemspec (and fiscali.rb)?

Mike.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.