<< Masa.20101231-update-vat_rate-ydim | 2010 | Masa.20101229-update-ydim >>
suspend
Done
suspend
Commit
Reboot (ydimd, ydim-htmld server)
~/git/ydim $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: bin/ydim-edit # deleted: set_initial_ydim_db.sql # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # doc/ # lib/ydim/debitors.rb # lib/ydim/drbwrapper.rb # test/flexmock.rb # test/test_debitors.rb # test/test_drbwrapper.rb ~/git/ydim $ git checkout -f ~/git/ydim $ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # doc/ # lib/ydim/debitors.rb # lib/ydim/drbwrapper.rb # test/flexmock.rb # test/test_debitors.rb # test/test_drbwrapper.rb nothing added to commit but untracked files present (use "git add" to track) /var/www/ydim.ywesee.com $ git pull remote: Counting objects: 13, done. remote: Compressing objects: 100% (6/6), done. remote: Total 7 (delta 3), reused 0 (delta 0) Unpacking objects: 100% (7/7), done. From /home/ywesee/cogito/ydim-html/ cec7536..de0e512 master -> origin Updating cec7536..de0e512 Fast-forward lib/ydim/html/util/lookandfeel.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) ~/git/ydim $ su # svstat /service/ydim /service/ydim: up (pid 26521) 23558995 seconds # svc -d /service/ydim # svstat /service/ydim /service/ydim: down 1 seconds, normally up # svc -u /service/ydim # svstat /service/ydim /service/ydim: up (pid 13104) 2 seconds # svstat /service/ydim /service/ydim: up (pid 13104) 6 seconds # svstat /service/ydim-html /service/ydim-html: up (pid 21018) 21854055 seconds # svc -d /service/ydim-html # svstat /service/ydim-html /service/ydim-html: down 8 seconds, normally up # svc -u /service/ydim-html # svstat /service/ydim-html /service/ydim-html: up (pid 13187) 4 seconds # svstat /service/ydim-html /service/ydim-html: up (pid 13187) 7 seconds
Reference (New company information)
Commit
BraSt
Confirm default
saved data
new data
Make new 'state' and 'view' classes
lib/ydim/html/util/lookandfeel.rb
:vat => 'MwSt. (8.0%)', :vat_2010 => 'MwSt. (7.6%)',
class InvoiceTotalComposite_2010 < InvoiceTotalComposite COMPONENTS = { [0,0] => :total_netto, [0,1] => :vat_2010, [0,2] => :total_brutto, } end ... class InvoiceComposite_2010 < InvoiceComposite COMPONENTS = { [0,0] => InvoiceInnerComposite, [0,1] => :items, [0,2] => InvoiceTotalComposite_2010, [0,3] => :submit, [1,3] => :pdf, [2,3] => :send_invoice, } end .. class Invoice_2010 < Invoice CONTENT = InvoiceComposite_2010 end
Note
grep View::Invoice
masa@masa ~/ywesee/ydim $ grep -r View::Invoice * lib/ydim/html/state/invoice.rb: VIEW = Html::View::Invoice lib/ydim/html/state/invoice.rb: VIEW = Html::View::Invoice
Note
Check Invoice_2010 working
lib/ydim/html/state/invoice.rb
#VIEW = Html::View::Invoice VIEW = Html::View::Invoice_2010
Note
Result
def vat_2010 total_netto * (@vat_rate.to_f / 100.0) end
sum :vat sum :vat_2010
Result
Create new State classes for saved data
lib/ydim/html/state/invoice.rb
class Invoice_2010 < Invoice VIEW = Html::View::Invoice_2010 end
Question
grep
masa@masa ~/ywesee/ydim $ grep -r State::Invoice * lib/ydim/html/state/invoice.rb:# Html::State::Invoice -- ydim -- 16.01.2006 -- hwyss@ywesee.com lib/ydim/html/state/invoices.rb:# Html::State::Invoices -- ydim -- 13.01.2006 -- hwyss@ywesee.com masa@masa ~/ywesee/ydim $
Hypothesis
Experiment
lib/ydim/invoice_2010.rb
#!/usr/bin/env ruby # Invoice -- ydim -- 11.01.2006 -- hwyss@ywesee.com require 'pdfinvoice/config' require 'pdfinvoice/invoice' require 'ydim/item' require 'ydim/server' module YDIM class Invoice_2010 < Invoice end end end
lib/ydim/html/state/global.rb#invoice
def invoice if(id = @session.user_input(:unique_id)) #Invoice.new(@session, @session.invoice(id.to_i)) Invoice_2010.new(@session, @session.invoice(id.to_i)) end end
Result
Experiment (switch)
lib/ydim/html/state/global.rb#invoice
def invoice ret = nil if(id = @session.user_input(:unique_id)) #Invoice.new(@session, @session.invoice(id.to_i)) #Invoice_2010.new(@session, @session.invoice(id.to_i)) ret = Invoice.new(@session, @session.invoice(id.to_i)) if (ret.model.items[0].vat_rate - YDIM::Server.config.vat_rate).abs > 0.1 ret = Invoice_2010.new(@session, @session.invoice(id.to_i)) end end return ret end
Problem
Hypothesis
Check invoice.rb
require 'pdfinvoice/config' require 'pdfinvoice/invoice' ... def pdf_invoice(sort_args={}) config = PdfInvoice.config.dup ...
Note
Correct MwSt in the config file of pdfinvoice
/etc/pdfinvoice $ ls config.yml logo.png /etc/pdfinvoice $ cat config.yml ... tax: MwSt 7.6% ...
(correct)
/etc/pdfinvoice $ cat config.yml ... tax: MwSt 8.0% ...
Result
Check the differences among Invoice, Invoices, Item classes
Note
Improvement
alias :vat_2010 :vat
lib/ydim/html/state/global.rb#invoice
def invoice inv = nil if(id = @session.user_input(:unique_id)) # Invoice.new(@session, @session.invoice(id.to_i)) inv = Invoice.new(@session, @session.invoice(id.to_i)) rate = YDIM::Server.config.vat_rate if(item = inv.model.items[0] and (item.vat_rate - rate).abs > 0.1) inv = Invoice_2010.new(@session, @session.invoice(id.to_i)) end end return inv end
Result
New View classes
class InvoiceTotalComposite_2010 < InvoiceTotalComposite COMPONENTS = { [0,0] => :total_netto, [0,1] => :vat_2010, [0,2] => :total_brutto, } end class InvoiceComposite_2010 < InvoiceComposite COMPONENTS = { [0,0] => InvoiceInnerComposite, [0,1] => :items, [0,2] => InvoiceTotalComposite_2010, [0,3] => :submit, [1,3] => :pdf, [2,3] => :send_invoice, } end class Invoice_2010 < Invoice CONTENT = InvoiceComposite_2010 end
New State class
lib/ydim/html/state/invoice.rb
class Invoice_2010 < Invoice VIEW = Html::View::Invoice_2010 end
The other modifications
sum :vat_2010 ... class Invoice_2010 < Invoice end
lib/ydim/html/util/lookandfeel.rb
:vat_2010 => 'MwSt. (7.6%)',
alias :vat_2010 :vat
lib/ydim/html/state/global.rb#invoice
def invoice inv = nil if(id = @session.user_input(:unique_id)) # Invoice.new(@session, @session.invoice(id.to_i)) inv = Invoice.new(@session, @session.invoice(id.to_i)) rate = YDIM::Server.config.vat_rate if(item = inv.model.items[0] and (item.vat_rate - rate).abs > 0.1) inv = Invoice_2010.new(@session, @session.invoice(id.to_i)) end end return inv end
Result