view · edit · sidebar · attach · print · history

20101228-setup-ydim

<< Masa.20101229-update-ydim | 2010 | Masa.20101227-setup-ydim >>


  1. Confirm ydim boot
  2. Confirm bugs
  3. Debug 'invalid invoice_id error'
  4. Compare dump files between success and failure
  5. Reduce the current data set into minimal data set
  6. Create a new Rechnung and check vat_rate
  7. Change MwSt

Goal
  • Set up ydim / 80%
Milestones
  1. Confirm ydim boot
  2. Debug 'Neue Rechnung' button, IndexError
  3. Create data for local testing
  4. Confirm vat-rate
Summary
Commits
ToDo Tomorrow
Keep in Mind
  1. ydim initializing database 20101228
  2. swissmedic_followers debug
  3. different page 2010, 2011 and navigator link at the bottom of page PM-Wiki Markup for paging between pages
  4. On Ice
  5. export_fachinfo test locally (weekend)
  6. backup script (weekend)
  7. emerge --sync

Confirm ydim boot

Setup script Attach:setup.ydim.sh.txt

$ sh setup.ydim.sh

Run ydimd, ydim-htmld

masa@masa ~/ywesee/ydim $ ruby -I lib bin/ydimd config="ydimd.yml"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "object_pkey" for table "object"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "object_name_key" for table "object"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "object_connection_pkey" for table "object_connection"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "collection_pkey" for table "collection"
I, [2010-12-28T08:36:40.715319 #3472]  INFO -- start: starting ydim-server on druby://localhost:12375
masa@masa ~/ywesee/ydim $ ruby -I lib bin/ydim-htmld config="ydim-htmld.yml" 
./lib/ydim/html/view/htmlgrid.rb:17: warning: already initialized constant HTTP_HEADERS
./lib/ydim/html/view/htmlgrid.rb:80: warning: already initialized constant STRIPED_BG
./lib/ydim/html.rb:3: warning: already initialized constant VERSION

Access http://masa.ydim.com/

  • root account: mhatakeyama@ywesee.com, (pass:same as ydpm)

Result

  • I have confirmed that I can login with mhatakeyama@ywesee.com as root user

Confirm bugs

Bug

  • I cannot create a new Rechnung

[Login] -> [Neuer Kunde]

  • Kundenart
  • Firma
  • Name
  • PLZ/Ort
  • Email

[speichern] -> [Neue Rechnung]

  • Beschreibung

[speichern] -> [Neue Position]

  • invalid invoice_id Error on ydim-htmld console
D, [2010-12-28T08:48:55.290821 #3585] DEBUG -- druby://localhost:12376: attempting login
I, [2010-12-28T08:48:55.291785 #3585]  INFO -- root: login
D, [2010-12-28T08:48:55.292231 #3585] DEBUG -- root: add_items(10003, Array[1], invoice)
D, [2010-12-28T08:48:55.292273 #3585] DEBUG -- root: invoice 10003
E, [2010-12-28T08:48:55.292784 #3585] ERROR -- root: invalid invoice_id: 10003
I, [2010-12-28T08:48:55.293214 #3585]  INFO -- root: logout

[Rechnungen] -> [ID]

  • IndexError on ydimd console
error in SBSM::Session#process: /de/invoice/unique_id/10003
IndexError
invalid invoice_id: 10003
(druby://localhost:12375) ./lib/ydim/root_session.rb:114:in `invoice'
./lib/ydim/client.rb:26:in `send'
./lib/ydim/client.rb:26:in `method_missing'
./lib/ydim/html/util/server.rb:28:in `send'
./lib/ydim/html/util/server.rb:28:in `method_missing'

Debug 'invalid invoice_id error'

grep

masa@masa ~/ywesee/ydim $ grep -r "invalid invoice_id" *
lib/ydim/root_session.rb:        msg = "invalid invoice_id: #{invoice_id}"
lib/ydim/root_session.rb:      msg = "invalid invoice_id: #{invoice_id}"

lib/ydim/root_session.rb#invoice

  def invoice(invoice_id)
    @serv.logger.debug(whoami) { "invoice #{invoice_id}" }
    Invoice.find_by_unique_id(invoice_id.to_s) \      #<= HERE
    or begin
      msg = "invalid invoice_id: #{invoice_id}"
      @serv.logger.error(whoami) { msg }
      raise IndexError, msg
    end
  end

Note

  • 'find_by_unique_id' method failed
  • Probably there is no data for the 'invoice_id.to_s' in the database

Check raw data in the database (ydim)

ydim=# \d
                   Liste der Relationen
 Schema |            Name            |  Typ  | Eigentümer 
--------+----------------------------+-------+------------
 public | collection                 | table | ydim
 public | object                     | table | ydim
 public | object_connection          | table | ydim
 public | ydim_autoinvoice_unique_id | table | ydim
 public | ydim_debitor_email         | table | ydim
 public | ydim_debitor_name          | table | ydim
 public | ydim_debitor_unique_id     | table | ydim
 public | ydim_invoice_status        | table | ydim
 public | ydim_invoice_unique_id     | table | ydim
(9 Zeilen)

ydim=# select * from ydim_invoice_unique_id;
 origin_id | unique_id | target_id 
-----------+-----------+-----------
        17 | 10000     |        17
(1 Zeile)

Note

  • Actually unique_id (10000) is there in 'ydim_invoice_unique_id' table

Compare data dump files between success and failure

Work

  • create 1 Kunde and 1 Rechnung

Failure case

diff dumps

masa@masa ~/work $ diff ydim_dump.1 ydim_dump.2 
152a153
> 15    04086900        
> 15    \N      f       Array
163a166
> 16    \N      f       Array
164a168
> 14    \N      f       YDIM::Debitor
171a176,178
> 12    currency_converter      f       YDIM::CurrencyConverter
> 13    id_server       f       ODBA::IdServer
> 17    \N      f       YDIM::Invoice
189a197,200
> 14    15
> 14    16
> 15    17
> 17    14
205a217
> 14    mhatakeyama@ywesee.com  14
213a226
> 14    masapotheke     14
221a235
> 14    1       14
229a244
> 17    is_open 17
237a253
> 17    10000   17

Success case

diff dumps

masa@masa ~/work $ diff ydim_dump.3 ydim_dump.4 
2119a2120
> 2688  04086900        
< 4     id_server     fODBA::IdServer
3198a3199
> 4     id_server     fODBA::IdServer
4522a4524,4527
> 2689  \N      f       Array
> 2687  \N      f       YDIM::Debitor
> 2688  \N      f       Array
> 2690  \N      f       YDIM::Invoice
8593a8599,8602
> 2687  2688
> 2687  2689
> 2688  2690
> 2690  2687
8926a8936
> 2687  mhatakeyama@ywesee.com  2687
9113a9124
> 2687  masapotheke     2687
9399a9411
> 2687  283     2687
10916a10929
> 2690  is_open 2690
12433a12447
> 2690  11562   2690

Note

  • It looks difficult to find the cause from this data

Question

  • Why does the 'Neue Position' work only in the case of loading the current data?

BraSt

  • The code is the same
  • The data is different
  • Some specific information in the loaded data must be important for the 'Neue Position', namely for 'Invoice.find_by_unique_id'

Next

  • Create a minimal data set (sql dump file) to work 'Neue Position'
  • And compare between the success and failure data

Reduce the current data set into minimal data set

~/ywesee/ydim $ sudo -u postgres dropdb ydim
~/ywesee/ydim $ sudo -u postgres createdb -E UTF8 -T template0 ydim
~/ywesee/ydim $ ruby -I lib bin/ydimd config="ydimd.yml"
~/ywesee/ydim $ pg_dump ydim > failure_case.sql

Notes

  • I do not understand why the 'failure.sql.txt' fails to create 'Rechnung'
  • But the initializing database is wrong anyway, and this must be debugged someday

Summary

How to initialize the database (ydim)

  1. sudo -u postgres dropdb ydim
  2. sudo -u postgres createdb -E UTF8 -T template0 ydim
  3. cat success_case.sql |psql -U postgres ydim

Update setup.ydim.sh

Attach:setup.ydim.sh.txt

Create a new Rechnung and check vat_rate

  1. Login
  2. [Neuer Kunde] (New Customer)
    • Kundenart
    • Firma
    • Name
    • PLZ/Ort
    • Email (max. 3)
  3. [Speichern] (Save)
  1. [Neue Rechnung]
    • Beschreibung
  2. [Speichern]
  1. [Neue Position]
    • Positionstext
    • Anzahl (number)
    • Einheit
    • Preis (Price)
  2. [Speichern]

Note

  • MwSt.(vat_rate) is 8.0% but the description is 7.6% (This should be updated)
  1. 'Rechnungen'
  2. 'offen' (then it goes to the list of 'Bezahlte Rechnung' (paid invoice))

Change vat_rate

lib/ydim/server.rb

module YDIM
    class Server
    ydim_default_dir = File.join(ENV['HOME'], '.ydim')
    default_config_files = [
      File.join(ydim_default_dir, 'ydimd.yml'),
      '/etc/ydim/ydimd.yml',
    ]
    defaults = {
...
      #'vat_rate'              => 8.0,
      'vat_rate'              => 10.0,
    }

Reboot

masa@masa ~/ywesee/ydim $ ruby -I lib bin/ydimd config="ydimd.yml"
masa@masa ~/ywesee/ydim $ ruby -I lib bin/ydim-htmld config="ydim-htmld.yml" 

Access http://masa.ydim.com

Neue Rechnung

Check MwSt (neue Rechnung)

MwSt (alt Rechnung)

Notes

  • Old records are still shown with 8.0%
  • New Rechnung is calculated with 10.0%
  • Looks good
  • The expression 'MwSt. (7.6%)' should be corrected.

Exeriment (before 'offen' what happens?)

Change vat_rate again

lib/ydim/server.rb

module YDIM
    class Server
    ydim_default_dir = File.join(ENV['HOME'], '.ydim')
    default_config_files = [
      File.join(ydim_default_dir, 'ydimd.yml'),
      '/etc/ydim/ydimd.yml',
    ]
    defaults = {
...
      #'vat_rate'              => 8.0,
      'vat_rate'              => 20.0,
    }

Access http://masa.ydim.com

Result

  • The MwSt.(vat_rate) is still 10.0%
  • Namely, 'vat_rate' in lib/ydim/server.rb is applied when 'Neue Rechnung' is clicked
  • This value is not applied to saved data

Conclusion

  • I do not have to change the algorithm
  • Just change 'MwSt' expression

Change MwSt

lib/ydim/html/util/lookandfeel.rb

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

Check the result

  • Neue Rechnung and alte Rechnung are both 'MwSt. (8.0%)'
  • Actual saved values does not change, though.

Note

  • ':vat' symbol is used for both displays

Question

  • Is it possible to switch the expression(7.6%, 8.0%) depending on the date of data (new or old)?
view · edit · sidebar · attach · print · history
Page last modified on July 13, 2011, at 12:04 PM