diff --git a/README.md b/README.md index adde998d7..cbfc21824 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ DNS name or IP address of the server hosting the elasticSearch database. SECRET_KEY_BASE Used by the authentication system to generate random tokens, eg. for resetting passwords. -Used by Rails to generate the integrity of signed cookies. +Used by Rails to verify the integrity of signed cookies. You can generate such a random key by running `rake secret`. STRIPE_API_KEY & STRIPE_PUBLISHABLE_KEY @@ -174,8 +174,8 @@ So set this setting carefully before starting the application for the first time INVOICE_PREFIX -When payments are done on the platform, an invoice will be generate as a PDF file. -This value configure the prefix of the PDF file name. +When payments are done on the platform, an invoice will be generated as a PDF file. +The PDF file name will be of the form "(INVOICE_PREFIX) - (invoice ID) _ (invoice date) .pdf" FABLAB_WITHOUT_PLANS @@ -203,7 +203,7 @@ Identifier of your Google Analytics account. DISQUS_SHORTNAME Unique identifier of your [Disqus](http://www.disqus.com) forum. -Disquq forums are used to allow visitors to comment on projects. +Disqus forums are used to allow visitors to comment on projects. See https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname- for more informations. TWITTER_NAME @@ -213,6 +213,7 @@ Identifier of the Twitter account, for witch the last tweet will be displayed on TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN & TWITTER_ACCESS_TOKEN_SECRET Keys and secrets to access the twitter API. +Retrieve them from https://apps.twitter.com Settings related to i18n @@ -443,7 +444,9 @@ If you are in a development environment, your can keep the default values, other #### Settings RAILS_LOCALE -Be sure that `config/locales/rails.XX.yml` exists, where `XX` match your configured rails_locale. +Configure Ruby on Rails for l10n. + +Be sure that `config/locales/rails.XX.yml` exists, where `XX` match your configured RAILS_LOCALE. You can find templates of these files at https://github.com/svenfuchs/rails-i18n/tree/rails-4-x/rails/locale. Be aware that **this file MUST contain the CURRENCY symbol used to generate invoices** (among other things). diff --git a/app/assets/templates/admin/invoices/index.html.erb b/app/assets/templates/admin/invoices/index.html.erb index 4c96d3789..11d7b2ee3 100644 --- a/app/assets/templates/admin/invoices/index.html.erb +++ b/app/assets/templates/admin/invoices/index.html.erb @@ -154,11 +154,11 @@ {{ 'including_VAT' | translate }} {{invoice.VAT.rate}} % - {{30*invoice.VAT.rate/100 | currency}} + {{30/(invoice.VAT.rate/100+1) | currency}} {{ 'including_total_excluding_taxes' }} - {{30-(30*invoice.VAT.rate/100) | currency}} + {{30-(30/(invoice.VAT.rate/100+1)) | currency}} {{ 'including_amount_payed_on_ordering' }} diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 0421c364d..787eec524 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -117,7 +117,7 @@ class Invoice < ActiveRecord::Base reference end - # only for debug + # for debug & used by rake task "fablab:regenerate_invoices" def regenerate_invoice_pdf pdf = ::PDF::Invoice.new(self).render File.binwrite(file, pdf) diff --git a/app/pdfs/pdf/invoice.rb b/app/pdfs/pdf/invoice.rb index 9651cca61..ce890dad0 100644 --- a/app/pdfs/pdf/invoice.rb +++ b/app/pdfs/pdf/invoice.rb @@ -138,7 +138,7 @@ module PDF data += [ [I18n.t('invoices.total_including_all_taxes'), number_to_currency(total)] ] vat_rate = Setting.find_by({name: 'invoice_VAT-rate'}).value.to_f - vat = total * vat_rate / 100 + vat = total / (vat_rate / 100 + 1) data += [ [I18n.t('invoices.including_VAT_RATE', RATE: vat_rate), number_to_currency(vat)] ] data += [ [I18n.t('invoices.including_total_excluding_taxes'), number_to_currency(total-vat)] ] data += [ [I18n.t('invoices.including_amount_payed_on_ordering'), number_to_currency(total)] ] diff --git a/lib/tasks/fablab.rake b/lib/tasks/fablab.rake index 5ca3a43fa..32c3b4010 100644 --- a/lib/tasks/fablab.rake +++ b/lib/tasks/fablab.rake @@ -26,14 +26,7 @@ namespace :fablab do start_date = Time.new(year.to_i, month.to_i, 1) end_date = start_date.next_month puts "-> Start regenerate the invoices between #{I18n.l start_date, format: :long} in #{I18n.l end_date-1.minute, format: :long}" - index = '000' invoices = Invoice.only_invoice.where("created_at >= :start_date AND created_at < :end_date", {start_date: start_date, end_date: end_date}).order(created_at: :asc) - invoices.each do |i| - i.update_columns(reference: "#{year.to_s[2..3]}#{'%02d' % month}#{index.next!}#{i.stp_invoice_id ? '/VL' : ''}") - if i.avoir - i.avoir.update_columns(reference: "#{year.to_s[2..3]}#{'%02d' % month}#{index.next!}/A") - end - end invoices.each(&:regenerate_invoice_pdf) puts "-> Done" end