view · edit · sidebar · attach · print · history

20101229-update-ydim

<< Masa.20101230-update-vat_rate-ydim | 2010 | Masa.20101228-setup-ydim >>


  1. Git push sql script
  2. Switch display 7.6%, 8.0% depending on the date of data

Goal
  • Update ydim / 100%
Milestones
  1. script push 8:30
  2. check reboot necessary after update?
  3. check autoinvoicer running date suspend
  4. Switch display 7.6%, 8.0% depending on the date of data
Summary
Commits
ToDo Tomorrow
  • Change logo and email etc. of bbmb.ch
Keep in Mind
  1. swissmedic_followers debug
  2. export_fachinfo test locally (weekend)
  3. backup script (weekend)
  4. On Ice
  5. emerge --sync

Git push sql script

Attach:set_initial_ydim_db.sql.txt

How to use this

cat set_initial_ydim_db.sql | psql -U postgres ydim

Note

  • Before using this script, you may need to create a DB 'ydim' and a user 'ydim'
sudo -u postgres dropdb ydim
sudo -u postgres createdb -E UTF8 -T template0 ydim
createuser ydim -P
  • Default db name and user are defined in lib/ydim/server.rb
      'db_driver_url'         => 'DBI:Pg:ydim',
      'db_user'               => 'ydim',
      'db_auth'               => '',
  • 'Pg' is a database driver
  • 'ydim' is both a database name and a user name for the database
  • 'db_auth' is the password
  • You can change these parameters in ydimd.yml or commandline parameter

Commit

Switch display 7.6%, 8.0% depending on the date of data]]

If I change as follows, lib/ydim/html/util/lookandfeel.rb

            #:vat                                               =>  'MwSt. (7.6%)',
            :vat                                                =>  'MwSt. (8.0%)',

then, both new and old Rechnung displays 'MwSt. (8.0%)'

New data
Old data

Task

  • The display should switch '7.6%' and '8.0%' depending on the date of data or calculated data
  • from 1.1.2011 the MwSt will be 8.0% but until 31.12.2010 MwSt is 7.6%

BraSt

  • How about preparing two :vat values and
  • Switch them with checking the date of data or saved calculated data
  • I should learn more about sbsm and htmlgrid

Experiment

lib/ydim/html/util/lookandfeel.rb

            :vat                                                =>  'MwSt. (8.0%)',
            :vat_2010                                               =>  'MwSt. (7.6%)',

lib/ydim/html/view/invoice.rb

class InvoiceTotalComposite < HtmlGrid::Composite
    COMPONENTS = {
        [0,0]   =>  :total_netto,
#        [0,1]   =>  :vat,
        [0,1]   =>  :vat_2010,
        [0,2]   =>  :total_brutto,
    }

Reboot

  • ydimd
  • ydim-htmld

Access http://masa.ydim.com

Result

  • The value disappears and MwSt becomes back 7.6%

Experiment

lib/ydim/invoice.rb

        sum :total_brutto
        sum :total_netto
        sum :vat
sum :vat_2010

lib/ydim/item.rb

        DATA_KEYS = [ :data, :expiry_time, :item_type, :price, :quantity, :text,
            :time, :unit, :vat_rate, :vat_rate_2010 ]
...
        def vat_2010
          total_netto * (@vat_rate_2010.to_f / 100.0)
        end

Result

  • MwSt is shown but the number is 0.0

Note

  • I have to set the item@vat_rate_2010

grep vat_rate

masa@masa ~/ywesee/ydim $ grep -r vat_rate *
bin/ydim-edit:  'vat_rate'                                                      => 8.0,
lib/ydim/factory.rb:          nitem.vat_rate = @serv.config.vat_rate
lib/ydim/invoice.rb:      rate = bool ? 0 : YDIM::Server.config.vat_rate
lib/ydim/invoice.rb:      @items.each do |item| item.vat_rate = rate end
lib/ydim/item.rb:                       :time, :unit, :vat_rate, :vat_rate_2010 ]
lib/ydim/item.rb:                       total_netto * (@vat_rate.to_f / 100.0)
lib/ydim/item.rb:          total_netto * (@vat_rate_2010.to_f / 100.0)
lib/ydim/root_session.rb:      rate = invoice.suppress_vat ? 0 : @serv.config.vat_rate
lib/ydim/root_session.rb:                               item = Item.new({:vat_rate => rate}.update(data))
lib/ydim/server.rb:      #'vat_rate'              => 7.6,
lib/ydim/server.rb:      'vat_rate'              => 8.0,
lib/ydim/server.rb.orig:      'vat_rate'              => 8.0,

Experiment

lib/ydim/invoice.rb#suppress_vat=

    def suppress_vat= bool
      rate = bool ? 0 : YDIM::Server.config.vat_rate
      rate2010 = bool ? 0 : YDIM::Server.config.vat_rate_2010
      @items.each do |item| 
        item.vat_rate = rate 
        item.vat_rate_2010 = rate2010
      end
      @suppress_vat = bool
    end

lib/ydim/server.rb

      'vat_rate'              => 8.0,
      'vat_rate_2010'              => 7.6,

Result

  • The price of MwSt is not shown yet in saved data
  • But the price comes in the case of new data
  • But 'Total Brutto' is calculated with the new vat_rate

Note

  • 'def suppress_vat=' is called when a new invoice is created
  • This method should not be updated
  • But without this modification, MwSt is 0.0 when a new invoice is created
  • Why?

BraSt

  • How about switch 'view' depending on 'state'?

ToDo

  1. Show appropriate MwSt in Saved data by using :vat_2010
    • In this prcess I should learn the code structure
  2. Next new rechnung process
  3. Think about switching process

Experiment

        def total_brutto
            #total_netto + vat
            total_netto + vat_2010
        end

Result

  • 'Total Brutto' becomes the same value to 'Total Netto'

Hypothesis

  • item@vat_rate is saved in cache
  • item@total_netto and item@total_brutto is calculated everytime from saved item@vat_rate

Experiment

lib/ydim/item.rb

        def vat_2010
          #total_netto * (@vat_rate_2010.to_f / 100.0)
          total_netto * 7.6 / 100.0
        end

Result

  • MwSt becomes calculated with 7.6%

Note

  • 'Total Brutto' is still calculated with 8.0% but this is due to the definition of 'total_brutto' in lib/ydim/item.rb
  • I will switch this method depending on the date of data

Next

  • How should I switch the view or method?

Interim Summary (htmlgrid)

  • 'view' classes are corresponding to 'stat' classes
  • 'view' class name is called in 'state' class and set in 'VIEW' constant
  • This is set when the ydim-htmld boots
  • After that (probably) the setting is saved in cache
  • I do not know how to switch the VIEW constant so far
view · edit · sidebar · attach · print · history
Page last modified on July 13, 2011, at 12:04 PM