bookyt 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/16x16/add.png +0 -0
- data/app/assets/images/16x16/alert.png +0 -0
- data/app/assets/images/16x16/combolink.png +0 -0
- data/app/assets/images/16x16/copy.png +0 -0
- data/app/assets/images/16x16/delete.png +0 -0
- data/app/assets/images/16x16/edit.png +0 -0
- data/app/assets/images/16x16/filter.png +0 -0
- data/app/assets/images/16x16/index.png +0 -0
- data/app/assets/images/16x16/notice.png +0 -0
- data/app/assets/images/16x16/pdf.png +0 -0
- data/app/assets/images/16x16/print.png +0 -0
- data/app/assets/images/16x16/show.png +0 -0
- data/app/assets/images/22x22/arrow-right.png +0 -0
- data/app/assets/images/22x22/edit.png +0 -0
- data/app/assets/images/22x22/insert_booking.png +0 -0
- data/app/assets/images/22x22/remove.png +0 -0
- data/app/assets/images/32x32/edit.png +0 -0
- data/app/assets/images/32x32/remove.png +0 -0
- data/app/assets/images/48x48/accounting.png +0 -0
- data/app/assets/images/48x48/basic_claims_data.png +0 -0
- data/app/assets/images/48x48/contacts.png +0 -0
- data/app/assets/images/48x48/invoicing.png +0 -0
- data/app/assets/images/48x48/nav_users.png +0 -0
- data/app/assets/images/48x48/settings.png +0 -0
- data/app/assets/images/48x48/store.png +0 -0
- data/app/assets/images/button_bg.png +0 -0
- data/app/assets/images/crystal-icons/16x16/filter.png +0 -0
- data/app/assets/images/down.png +0 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/images/flavour-extended/48x48/invoice.png +0 -0
- data/app/assets/images/free-business-desktop-icons/48x48/business.png +0 -0
- data/app/assets/images/gnome-web-icons/48x48/Gnome-X-Office-Address-Book-48.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_flat_55_fbec88_40x100.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_glass_75_759fcf_1x400.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_glass_85_aeb9cf_1x400.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_gloss-wave_55_aeb9cf_500x100.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_inset-hard_100_759fcf_1x100.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_inset-hard_100_f6f6f6_1x100.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_217bc0_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_469bdd_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_6da8d5_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_d8e7f3_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_f9bd01_256x240.png +0 -0
- data/app/assets/images/jquery/tooltip/black_arrow.png +0 -0
- data/app/assets/images/letter-logo.alpha.png +0 -0
- data/app/assets/images/letter-logo.big.png +0 -0
- data/app/assets/images/letter-logo.orig.png +0 -0
- data/app/assets/images/letter-logo.png +0 -0
- data/app/assets/images/loading.gif +0 -0
- data/app/assets/images/logo.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/application-pdf.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/document-preview.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/document-print.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/edit-copy.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/go-next.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/mail-mark-notjunk.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/status_unknown.png +0 -0
- data/app/assets/images/oxygen-icons/48x48/system-users.png +0 -0
- data/app/assets/images/rails.png +0 -0
- data/app/assets/images/up.png +0 -0
- data/app/assets/javascripts/application.js +49 -0
- data/app/assets/javascripts/cyt.js +86 -0
- data/app/assets/javascripts/jquery-ui.js +11437 -0
- data/app/assets/javascripts/jquery.dirtyform.js +242 -0
- data/app/assets/javascripts/jquery.form.js +785 -0
- data/app/assets/javascripts/jquery.js +8936 -0
- data/app/assets/javascripts/jquery.meio.mask.js +683 -0
- data/app/assets/javascripts/jquery.remotipart.js +46 -0
- data/app/assets/javascripts/jquery.ui.combobox.js +77 -0
- data/app/assets/javascripts/jquery_ujs.js +316 -0
- data/app/assets/javascripts/nested_form.js +51 -0
- data/app/assets/javascripts/tooltip.js +343 -0
- data/app/assets/stylesheets/.gitkeep +0 -0
- data/app/assets/stylesheets/ie.scss +16 -0
- data/app/assets/stylesheets/ie6.scss +4 -0
- data/app/assets/stylesheets/partials/_base.sass +39 -0
- data/app/assets/stylesheets/partials/_content.sass +60 -0
- data/app/assets/stylesheets/partials/_jquery.sass +2 -0
- data/app/assets/stylesheets/partials/_layout.sass +21 -0
- data/app/assets/stylesheets/partials/_sidebar.sass +5 -0
- data/app/assets/stylesheets/partials/content/_accounting.sass +41 -0
- data/app/assets/stylesheets/partials/content/_ajax_indicator.sass +28 -0
- data/app/assets/stylesheets/partials/content/_app.sass +43 -0
- data/app/assets/stylesheets/partials/content/_combobox.sass +8 -0
- data/app/assets/stylesheets/partials/content/_cyt.sass +200 -0
- data/app/assets/stylesheets/partials/content/_fancy_buttons.sass +10 -0
- data/app/assets/stylesheets/partials/content/_flash_errors.sass +46 -0
- data/app/assets/stylesheets/partials/content/_form_view.sass +20 -0
- data/app/assets/stylesheets/partials/content/_icons.sass +35 -0
- data/app/assets/stylesheets/partials/content/_invoice.sass +6 -0
- data/app/assets/stylesheets/partials/content/_overview.sass +40 -0
- data/app/assets/stylesheets/partials/content/_pagination.sass +61 -0
- data/app/assets/stylesheets/partials/content/_person.sass +5 -0
- data/app/assets/stylesheets/partials/content/_scaffold.sass +67 -0
- data/app/assets/stylesheets/partials/content/_table_list.sass +26 -0
- data/app/assets/stylesheets/partials/content/formtastic/_formtastic.sass +201 -0
- data/app/assets/stylesheets/partials/content/formtastic/_formtastic_cyt.sass +90 -0
- data/app/assets/stylesheets/partials/formtastic/_custom_fields.sass +2 -0
- data/app/assets/stylesheets/partials/formtastic/_formtastic_base.sass +652 -0
- data/app/assets/stylesheets/partials/jquery/_jquery_ui.sass +1461 -0
- data/app/assets/stylesheets/partials/jquery/_tooltip.sass +21 -0
- data/app/assets/stylesheets/partials/layout/_header.sass +29 -0
- data/app/assets/stylesheets/partials/layout/_navigation.sass +2 -0
- data/app/assets/stylesheets/partials/layout/navigation/_main.sass +34 -0
- data/app/assets/stylesheets/partials/layout/navigation/_sidebar.sass +18 -0
- data/app/assets/stylesheets/partials/print/_app.sass +21 -0
- data/app/assets/stylesheets/partials/print/_layout.sass +24 -0
- data/app/assets/stylesheets/print.scss +5 -0
- data/app/assets/stylesheets/screen.scss +12 -0
- data/app/controllers/account_types_controller.rb +2 -0
- data/app/controllers/accounts_controller.rb +30 -0
- data/app/controllers/application_controller.rb +12 -0
- data/app/controllers/attachments_controller.rb +15 -0
- data/app/controllers/authorized_controller.rb +24 -0
- data/app/controllers/bank_accounts_controller.rb +2 -0
- data/app/controllers/booking_imports_controller.rb +2 -0
- data/app/controllers/booking_templates_controller.rb +8 -0
- data/app/controllers/bookings_controller.rb +64 -0
- data/app/controllers/charge_booking_templates_controller.rb +2 -0
- data/app/controllers/charge_rates_controller.rb +2 -0
- data/app/controllers/companies_controller.rb +8 -0
- data/app/controllers/credit_invoices_controller.rb +29 -0
- data/app/controllers/customers_controller.rb +12 -0
- data/app/controllers/debit_invoices_controller.rb +43 -0
- data/app/controllers/direct_bookings_controller.rb +17 -0
- data/app/controllers/employees_controller.rb +3 -0
- data/app/controllers/employments_controller.rb +2 -0
- data/app/controllers/invoices_controller.rb +21 -0
- data/app/controllers/notes_controller.rb +34 -0
- data/app/controllers/overview_controller.rb +6 -0
- data/app/controllers/people_controller.rb +13 -0
- data/app/controllers/salaries_controller.rb +46 -0
- data/app/controllers/tenants_controller.rb +39 -0
- data/app/controllers/users_controller.rb +26 -0
- data/app/helpers/application_helper.rb +52 -0
- data/app/helpers/booking_helper.rb +10 -0
- data/app/helpers/booking_template_helper.rb +17 -0
- data/app/helpers/charge_rate_helper.rb +5 -0
- data/app/helpers/invoice_helper.rb +9 -0
- data/app/helpers/vat_rate_helper.rb +10 -0
- data/app/inputs/combobox_input.rb +23 -0
- data/app/inputs/date_field_input.rb +5 -0
- data/app/inputs/hour_field_input.rb +5 -0
- data/app/models/ability.rb +34 -0
- data/app/models/attachment.rb +13 -0
- data/app/models/booking_import.rb +8 -0
- data/app/models/booking_import_observer.rb +7 -0
- data/app/models/booking_reference.rb +4 -0
- data/app/models/booking_template.rb +92 -0
- data/app/models/charge_booking_template.rb +57 -0
- data/app/models/charge_rate.rb +30 -0
- data/app/models/civil_status.rb +5 -0
- data/app/models/company.rb +5 -0
- data/app/models/credit_invoice.rb +32 -0
- data/app/models/customer.rb +4 -0
- data/app/models/debit_invoice.rb +24 -0
- data/app/models/employee.rb +6 -0
- data/app/models/employment.rb +28 -0
- data/app/models/invoice.rb +145 -0
- data/app/models/line_item.rb +22 -0
- data/app/models/note.rb +8 -0
- data/app/models/person.rb +65 -0
- data/app/models/product.rb +2 -0
- data/app/models/profit.rb +9 -0
- data/app/models/religion.rb +5 -0
- data/app/models/role.rb +9 -0
- data/app/models/salary.rb +93 -0
- data/app/models/tenant.rb +43 -0
- data/app/models/user.rb +44 -0
- data/app/models/vat_rate.rb +11 -0
- data/app/uploaders/attachment_uploader.rb +12 -0
- data/app/views/account_types/_account_type.html.haml +6 -0
- data/app/views/account_types/_form.html.haml +7 -0
- data/app/views/account_types/_list.html.haml +7 -0
- data/app/views/account_types/index.html.haml +6 -0
- data/app/views/account_types/show.html.haml +6 -0
- data/app/views/accounts/_account.html.haml +12 -0
- data/app/views/accounts/_booking_item.html.haml +15 -0
- data/app/views/accounts/_booking_list.html.haml +19 -0
- data/app/views/accounts/_booking_list_footer.html.haml +2 -0
- data/app/views/accounts/_booking_list_header.html.haml +8 -0
- data/app/views/accounts/_booking_list_paginate.html.haml +5 -0
- data/app/views/accounts/_booking_list_saldo.html.haml +8 -0
- data/app/views/accounts/_booking_list_turnover.html.haml +9 -0
- data/app/views/accounts/_carry_booking.html.haml +9 -0
- data/app/views/accounts/_form.html.haml +10 -0
- data/app/views/accounts/_list_footer.html.haml +2 -0
- data/app/views/accounts/_list_header.html.haml +5 -0
- data/app/views/accounts/index.html.haml +8 -0
- data/app/views/accounts/show.html.haml +10 -0
- data/app/views/application/_form.html.haml +7 -0
- data/app/views/application/_list.html.haml +15 -0
- data/app/views/application/_search_form.html.haml +5 -0
- data/app/views/application/_show.html.haml +2 -0
- data/app/views/application/create.js.erb +3 -0
- data/app/views/application/destroy.js.erb +2 -0
- data/app/views/application/edit.html.haml +5 -0
- data/app/views/application/edit.js.erb +3 -0
- data/app/views/application/index.html.haml +7 -0
- data/app/views/application/new.html.haml +5 -0
- data/app/views/application/new.js.erb +3 -0
- data/app/views/application/show.html.haml +5 -0
- data/app/views/application/update.js.erb +3 -0
- data/app/views/attachments/_attachment.html.haml +5 -0
- data/app/views/attachments/_form.html.haml +15 -0
- data/app/views/attachments/_list.html.haml +6 -0
- data/app/views/bank_accounts/_bank_account.html.haml +1 -0
- data/app/views/booking_imports/_booking_import.html.haml +5 -0
- data/app/views/booking_imports/_form.html.haml +6 -0
- data/app/views/booking_imports/_list.html.haml +7 -0
- data/app/views/booking_imports/create.js.erb +4 -0
- data/app/views/booking_imports/index.html.haml +6 -0
- data/app/views/booking_imports/show.html.haml +6 -0
- data/app/views/booking_templates/_booking_template.html.haml +16 -0
- data/app/views/booking_templates/_form.html.haml +12 -0
- data/app/views/booking_templates/_list.html.haml +10 -0
- data/app/views/booking_templates/index.html.haml +6 -0
- data/app/views/bookings/_booking.html.haml +17 -0
- data/app/views/bookings/_form.html.haml +14 -0
- data/app/views/bookings/_list.html.haml +11 -0
- data/app/views/bookings/_new_form.html.haml +8 -0
- data/app/views/bookings/_sidebar.html.haml +7 -0
- data/app/views/bookings/_simple_form.html.haml +12 -0
- data/app/views/bookings/index.html.haml +9 -0
- data/app/views/bookings/new.html.haml +8 -0
- data/app/views/bookings/select.html.haml +11 -0
- data/app/views/bookings/show.html.haml +27 -0
- data/app/views/bookings/simple_edit.html.haml +4 -0
- data/app/views/charge_booking_templates/_charge_booking_template.html.haml +15 -0
- data/app/views/charge_booking_templates/_form.html.haml +12 -0
- data/app/views/charge_booking_templates/_list.html.haml +10 -0
- data/app/views/charge_rates/_form.html.haml +14 -0
- data/app/views/companies/_company.html.haml +5 -0
- data/app/views/companies/_form.html.haml +8 -0
- data/app/views/companies/_list.html.haml +6 -0
- data/app/views/companies/index.html.haml +6 -0
- data/app/views/companies/show.html.haml +27 -0
- data/app/views/credit_invoices/_credit_invoice.html.haml +9 -0
- data/app/views/credit_invoices/_form.html.haml +41 -0
- data/app/views/credit_invoices/_list.html.haml +20 -0
- data/app/views/credit_invoices/index.html.haml +7 -0
- data/app/views/credit_invoices/show.html.haml +56 -0
- data/app/views/customers/_customer.html.haml +5 -0
- data/app/views/customers/_form.html.haml +8 -0
- data/app/views/customers/_list.html.haml +6 -0
- data/app/views/customers/index.html.haml +6 -0
- data/app/views/customers/show.html.haml +22 -0
- data/app/views/debit_invoices/_debit_invoice.html.haml +9 -0
- data/app/views/debit_invoices/_form.html.haml +38 -0
- data/app/views/debit_invoices/_invoice_body.html.haml +8 -0
- data/app/views/debit_invoices/_invoice_info.html.haml +10 -0
- data/app/views/debit_invoices/_invoice_parties.html.haml +9 -0
- data/app/views/debit_invoices/_list.html.haml +21 -0
- data/app/views/debit_invoices/index.html.haml +7 -0
- data/app/views/debit_invoices/letter.html.haml +9 -0
- data/app/views/debit_invoices/letter.pdf.prawn +57 -0
- data/app/views/debit_invoices/show.html.haml +56 -0
- data/app/views/devise/confirmations/new.html.haml +10 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +6 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +10 -0
- data/app/views/devise/mailer/unlock_instructions.html.haml +8 -0
- data/app/views/devise/passwords/edit.html.haml +15 -0
- data/app/views/devise/passwords/new.html.haml +11 -0
- data/app/views/devise/sessions/new.html.haml +13 -0
- data/app/views/devise/shared/_links.haml +15 -0
- data/app/views/devise/unlocks/new.html.haml +11 -0
- data/app/views/direct_bookings/_form.html.haml +12 -0
- data/app/views/direct_bookings/_item.html.haml +17 -0
- data/app/views/direct_bookings/_list.html.haml +10 -0
- data/app/views/direct_bookings/_list_footer.html.haml +6 -0
- data/app/views/direct_bookings/_show.html.haml +3 -0
- data/app/views/direct_bookings/_show_all.html.haml +8 -0
- data/app/views/direct_bookings/list.js.erb +2 -0
- data/app/views/direct_bookings/new.js.erb +2 -0
- data/app/views/employees/_employee.html.haml +5 -0
- data/app/views/employees/_form.html.haml +19 -0
- data/app/views/employees/_list.html.haml +6 -0
- data/app/views/employees/index.html.haml +6 -0
- data/app/views/employees/show.html.haml +31 -0
- data/app/views/employments/_employment.html.haml +10 -0
- data/app/views/employments/_form.html.haml +24 -0
- data/app/views/employments/_list.html.haml +11 -0
- data/app/views/employments/_show.html.haml +9 -0
- data/app/views/employments/index.html.haml +5 -0
- data/app/views/invoices/_form.html.haml +13 -0
- data/app/views/invoices/_invoice.html.haml +7 -0
- data/app/views/invoices/_list.html.haml +20 -0
- data/app/views/invoices/_sidebar.html.haml +11 -0
- data/app/views/invoices/index.html.haml +17 -0
- data/app/views/invoices/show.html.haml +56 -0
- data/app/views/layouts/_flash_new.html.haml +1 -0
- data/app/views/layouts/_list_item_actions_for.html.haml +3 -0
- data/app/views/layouts/application.html.haml +46 -0
- data/app/views/line_items/_form.html.haml +6 -0
- data/app/views/line_items/_line_item.html.haml +7 -0
- data/app/views/line_items/_list_footer.html.haml +7 -0
- data/app/views/notes/_form.html.haml +10 -0
- data/app/views/notes/_list.html.haml +15 -0
- data/app/views/notes/index.html.haml +9 -0
- data/app/views/notes/show.html.haml +12 -0
- data/app/views/overview/index.html.haml +14 -0
- data/app/views/people/_form.html.haml +8 -0
- data/app/views/people/_list.html.haml +7 -0
- data/app/views/people/_person.html.haml +6 -0
- data/app/views/people/_show.html.haml +6 -0
- data/app/views/people/show.html.haml +21 -0
- data/app/views/persons/_civil.html.haml +5 -0
- data/app/views/persons/_show.html.haml +6 -0
- data/app/views/salaries/_form.html.haml +14 -0
- data/app/views/salaries/_list.html.haml +12 -0
- data/app/views/salaries/_salary.html.haml +10 -0
- data/app/views/salaries/_salary_certificate.html.haml +25 -0
- data/app/views/salaries/payslip.html.haml +40 -0
- data/app/views/salaries/show.html.haml +30 -0
- data/app/views/salaries/statistics.html.haml +6 -0
- data/app/views/tenants/_account.html.haml +7 -0
- data/app/views/tenants/_account_group_sheet.html.haml +8 -0
- data/app/views/tenants/_form.html.haml +17 -0
- data/app/views/tenants/_list.html.haml +7 -0
- data/app/views/tenants/_tenant.html.haml +7 -0
- data/app/views/tenants/balance_sheet.html.haml +43 -0
- data/app/views/tenants/index.html.haml +6 -0
- data/app/views/tenants/new.js.erb +1 -0
- data/app/views/tenants/profit_sheet.html.haml +26 -0
- data/app/views/tenants/show.html.haml +18 -0
- data/app/views/users/_demo.de-CH.html.haml +7 -0
- data/app/views/users/_demo.de.html.haml +7 -0
- data/app/views/users/_demo.html.haml +7 -0
- data/app/views/users/_form.html.haml +17 -0
- data/app/views/users/_list.html.haml +9 -0
- data/app/views/users/_show.html.haml +13 -0
- data/app/views/users/_user.html.haml +7 -0
- data/app/views/users/index.html.haml +6 -0
- data/app/views/users/new.js.erb +1 -0
- data/app/views/users/show.html.haml +14 -0
- data/lib/acts_as_csv.rb +113 -0
- data/lib/bookyt/engine.rb +18 -0
- data/lib/bookyt/version.rb +3 -0
- data/lib/float.rb +17 -0
- data/lib/pagination_list_link_renderer.rb +63 -0
- data/lib/parse_date.rb +27 -0
- data/lib/prawn/letter_document.rb +136 -0
- data/lib/raiffeisen_importer.rb +15 -0
- data/lib/recipes/bookyt.rb +15 -0
- data/lib/simple_navigation/renderer/list.rb +20 -0
- data/lib/simple_navigation/renderer/overview.rb +46 -0
- data/lib/sqlite3_extensions.rb +45 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/bookyt.rake +15 -0
- data/lib/tasks/cucumber.rake +53 -0
- data/lib/tasks/environment_seeds.rake +7 -0
- data/lib/tasks/users.rake +46 -0
- metadata +423 -0
data/app/models/note.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
class Person < ActiveRecord::Base
|
2
|
+
# Validations
|
3
|
+
validates_date :date_of_birth, :date_of_death, :allow_nil => true, :allow_blank => true
|
4
|
+
validates_presence_of :vcard
|
5
|
+
|
6
|
+
# sex enumeration
|
7
|
+
MALE = 1
|
8
|
+
FEMALE = 2
|
9
|
+
|
10
|
+
# String
|
11
|
+
def to_s(format = :default)
|
12
|
+
return unless vcard
|
13
|
+
|
14
|
+
s = vcard.full_name
|
15
|
+
|
16
|
+
case format
|
17
|
+
when :long
|
18
|
+
s += " (#{vcard.locality})" if vcard.locality
|
19
|
+
end
|
20
|
+
|
21
|
+
return s
|
22
|
+
end
|
23
|
+
|
24
|
+
# VCards
|
25
|
+
# ======
|
26
|
+
has_many :vcards, :as => :object
|
27
|
+
has_one :vcard, :as => :object
|
28
|
+
accepts_nested_attributes_for :vcard
|
29
|
+
|
30
|
+
# Search
|
31
|
+
default_scope includes(:vcard).order('IFNULL(vcards.full_name, vcards.family_name + ' ' + vcards.given_name)')
|
32
|
+
|
33
|
+
scope :by_name, lambda {|value|
|
34
|
+
includes(:vcard).where("(vcards.given_name LIKE :query) OR (vcards.family_name LIKE :query) OR (vcards.full_name LIKE :query)", :query => "%#{value}%")
|
35
|
+
}
|
36
|
+
|
37
|
+
# Constructor
|
38
|
+
def initialize(attributes = nil, options = {})
|
39
|
+
super
|
40
|
+
|
41
|
+
build_vcard unless vcard
|
42
|
+
vcard.build_address unless vcard.address
|
43
|
+
end
|
44
|
+
|
45
|
+
# Invoices
|
46
|
+
# ========
|
47
|
+
has_many :credit_invoices, :class_name => 'Invoice', :foreign_key => :customer_id, :order => 'value_date DESC'
|
48
|
+
has_many :debit_invoices, :class_name => 'Invoice', :foreign_key => :company_id, :order => 'value_date DESC'
|
49
|
+
|
50
|
+
# Charge Rates
|
51
|
+
# ============
|
52
|
+
has_many :charge_rates
|
53
|
+
|
54
|
+
# Attachments
|
55
|
+
# ===========
|
56
|
+
has_many :attachments, :as => :object
|
57
|
+
accepts_nested_attributes_for :attachments, :reject_if => proc { |attributes| attributes['file'].blank? }
|
58
|
+
|
59
|
+
# Others
|
60
|
+
# ===========
|
61
|
+
belongs_to :civil_status
|
62
|
+
belongs_to :religion
|
63
|
+
has_many :notes, :as => :note_of_sth
|
64
|
+
|
65
|
+
end
|
data/app/models/role.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
class Salary < Invoice
|
2
|
+
# Association customizing
|
3
|
+
belongs_to :employee, :foreign_key => :company_id, :class_name => 'Person'
|
4
|
+
belongs_to :employer, :foreign_key => :customer_id, :class_name => 'Person'
|
5
|
+
|
6
|
+
validates :employee, :employer, :presence => true
|
7
|
+
|
8
|
+
def employer_id=(value)
|
9
|
+
customer_id = value
|
10
|
+
end
|
11
|
+
|
12
|
+
def employee_id=(value)
|
13
|
+
company_id = value
|
14
|
+
end
|
15
|
+
|
16
|
+
# String
|
17
|
+
def to_s(format = :default)
|
18
|
+
"%s (%s / %s - %s)" % [title, company, duration_from ? I18n::localize(duration_from) : '', duration_to ? I18n::localize(duration_to) : '']
|
19
|
+
end
|
20
|
+
|
21
|
+
# Calculations
|
22
|
+
def net_amount
|
23
|
+
salary_invoice_booking = bookings.where(:debit_account_id => Account.find_by_code('2050').id).first
|
24
|
+
return 0.0 unless salary_invoice_booking
|
25
|
+
|
26
|
+
salary_invoice_booking.amount
|
27
|
+
end
|
28
|
+
|
29
|
+
def bvg_amount
|
30
|
+
bookings.by_text("BVG").sum(:amount)
|
31
|
+
end
|
32
|
+
|
33
|
+
def social_amount
|
34
|
+
result = bookings.by_text("AHV/IV/EO Arbeitnehmer").sum(:amount)
|
35
|
+
result += bookings.by_text("ALV Arbeitnehmer").sum(:amount)
|
36
|
+
result += bookings.by_text("NBU Arbeitnehmer").sum(:amount)
|
37
|
+
|
38
|
+
result
|
39
|
+
end
|
40
|
+
|
41
|
+
def ahv_amount
|
42
|
+
result = amount
|
43
|
+
result += bookings.where(:title => "Kinderzulage").sum(:amount)
|
44
|
+
|
45
|
+
result
|
46
|
+
end
|
47
|
+
|
48
|
+
# Assignment proxies
|
49
|
+
def duration_from=(value)
|
50
|
+
write_attribute(:duration_from, value)
|
51
|
+
|
52
|
+
value_as_date = self.duration_from
|
53
|
+
# Calculate value and due dates
|
54
|
+
date = Date.new(value_as_date.year, value_as_date.month, 1).in(1.month).ago(1.day)
|
55
|
+
self.value_date ||= date
|
56
|
+
self.due_date ||= date
|
57
|
+
end
|
58
|
+
|
59
|
+
# Filter/Search
|
60
|
+
# =============
|
61
|
+
scope :by_value_period, lambda {|from, to| where("date(value_date) BETWEEN ? AND ?", from, to) }
|
62
|
+
scope :by_employee_id, lambda {|value| where(:company_id => value)}
|
63
|
+
|
64
|
+
# Bookings
|
65
|
+
# ========
|
66
|
+
def self.direct_account
|
67
|
+
Account.find_by_code("5000")
|
68
|
+
end
|
69
|
+
|
70
|
+
# Build booking
|
71
|
+
#
|
72
|
+
# We need to ensure the order of creation as we depent on current balance.
|
73
|
+
def build_booking(params = {}, template_code = nil)
|
74
|
+
# Build and assign booking
|
75
|
+
super(params, 'salary:employee:ahv_iv_eo').save
|
76
|
+
super(params, 'salary:employer:ahv_iv_eo').save
|
77
|
+
super(params, 'salary:employee:alv').save
|
78
|
+
super(params, 'salary:employer:alv').save
|
79
|
+
super(params, 'salary:employee:nbu').save
|
80
|
+
super(params, 'salary:employer:nbu').save
|
81
|
+
super(params, 'salary:employer:bu').save
|
82
|
+
super(params, 'salary:employer:fak').save
|
83
|
+
super(params, 'salary:employer:vkb').save
|
84
|
+
|
85
|
+
super(params, 'salary:employee:ktg').save
|
86
|
+
super(params.merge(:person_id => employee.id), "salary:bvg").save
|
87
|
+
|
88
|
+
super(params, 'salary:invoice').save
|
89
|
+
|
90
|
+
super(params.merge(:person_id => employee.id), "salary:kz").save
|
91
|
+
super(params.merge(:person_id => employee.id), "salary:social:kz").save
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Tenant < ActiveRecord::Base
|
2
|
+
# Associations
|
3
|
+
belongs_to :company, :foreign_key => :person_id
|
4
|
+
accepts_nested_attributes_for :company
|
5
|
+
has_many :users
|
6
|
+
|
7
|
+
# Validations
|
8
|
+
validates_presence_of :company
|
9
|
+
validates_date :incorporated_on
|
10
|
+
|
11
|
+
# String
|
12
|
+
def to_s
|
13
|
+
company.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
# Fiscal Years
|
17
|
+
# ============
|
18
|
+
validates_date :fiscal_year_ends_on
|
19
|
+
|
20
|
+
def fiscal_period(year)
|
21
|
+
final_day_of_fiscal_year = Date.new(year, fiscal_year_ends_on.month, fiscal_year_ends_on.day)
|
22
|
+
first_day_of_fiscal_year = final_day_of_fiscal_year.ago(1.year).in(1.day)
|
23
|
+
|
24
|
+
return :from => first_day_of_fiscal_year.to_date, :to => final_day_of_fiscal_year.to_date
|
25
|
+
end
|
26
|
+
|
27
|
+
def fiscal_years
|
28
|
+
first_year = fiscal_year_ends_on.year
|
29
|
+
final_year = Date.today.year + 1
|
30
|
+
|
31
|
+
years = {}
|
32
|
+
(first_year..final_year).map{|year|
|
33
|
+
years[year] = fiscal_period(year)
|
34
|
+
}
|
35
|
+
|
36
|
+
return years
|
37
|
+
end
|
38
|
+
|
39
|
+
# Attachments
|
40
|
+
# ===========
|
41
|
+
has_many :attachments, :as => :object
|
42
|
+
accepts_nested_attributes_for :attachments, :reject_if => proc { |attributes| attributes['file'].blank? }
|
43
|
+
end
|
data/app/models/user.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
# Include default devise modules. Others available are:
|
3
|
+
# :token_authenticatable, :confirmable, :lockable and :timeoutable
|
4
|
+
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
|
5
|
+
|
6
|
+
# Setup accessible (or protected) attributes for your model
|
7
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me
|
8
|
+
|
9
|
+
# Tenancy
|
10
|
+
belongs_to :tenant
|
11
|
+
|
12
|
+
# Authorization roles
|
13
|
+
has_and_belongs_to_many :roles, :autosave => true
|
14
|
+
scope :by_role, lambda{|role| include(:roles).where(:name => role)}
|
15
|
+
attr_accessible :role_texts
|
16
|
+
|
17
|
+
def role?(role)
|
18
|
+
!!self.roles.find_by_name(role.to_s)
|
19
|
+
end
|
20
|
+
|
21
|
+
def role_texts
|
22
|
+
roles.map{|role| role.name}
|
23
|
+
end
|
24
|
+
|
25
|
+
def role_texts=(role_names)
|
26
|
+
self.roles = Role.where(:name => role_names)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Associations
|
30
|
+
belongs_to :person
|
31
|
+
validates_presence_of :person
|
32
|
+
accepts_nested_attributes_for :person
|
33
|
+
attr_accessible :person, :person_attributes
|
34
|
+
|
35
|
+
# Shortcuts
|
36
|
+
def current_company
|
37
|
+
person.try(:employers).try(:first)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Helpers
|
41
|
+
def to_s
|
42
|
+
person.try(:to_s) || ""
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class VatRate < ChargeRate
|
2
|
+
scope :full, where(:code => 'full')
|
3
|
+
scope :reduced, where(:code => 'reduced')
|
4
|
+
scope :special, where(:code => 'special')
|
5
|
+
scope :excluded, where(:code => 'excluded')
|
6
|
+
|
7
|
+
# String
|
8
|
+
def to_s
|
9
|
+
"%.1f%% (%s)" % [rate, I18n::translate(code, :scope => 'vat_rates.code')]
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class AttachmentUploader < CarrierWave::Uploader::Base
|
4
|
+
# Choose what kind of storage to use for this uploader:
|
5
|
+
storage :file
|
6
|
+
|
7
|
+
# Override the directory where uploaded files will be stored.
|
8
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
9
|
+
def store_dir
|
10
|
+
"system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
%tr[account]
|
2
|
+
%td= account.code
|
3
|
+
%td= link_to account.title, account_path(account, :by_value_period => params[:by_value_period])
|
4
|
+
- if @date
|
5
|
+
%td{:style => "text-align: right"}= currency_fmt(account.saldo(@date))
|
6
|
+
- elsif params[:by_value_period]
|
7
|
+
%td{:style => "text-align: right"}= currency_fmt(account.saldo(params[:by_value_period][:from]..params[:by_value_period][:to]))
|
8
|
+
- else
|
9
|
+
%td{:style => "text-align: right"}= currency_fmt(account.saldo)
|
10
|
+
%td.action-links
|
11
|
+
= list_link_for(:edit, account)
|
12
|
+
= list_link_for(:delete, account)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
%tr[@booking]
|
2
|
+
%td= @booking.value_date
|
3
|
+
%td
|
4
|
+
= link_to @booking.title, @booking, {'data-href-container' => 'tr'}
|
5
|
+
- if @booking.comments.present?
|
6
|
+
%hr{:style => "height: 1px; margin: 0"}/
|
7
|
+
%i= @booking.comments
|
8
|
+
%td= link_to @booking.reference.to_s(:reference), @booking.reference unless @booking.reference.nil?
|
9
|
+
%td.currency= (@booking.credit_account == @account) ? currency_fmt(@booking.amount) : content_tag('i', link_to(@booking.credit_account.code, account_path(@booking.credit_account), :title => @booking.credit_account.title))
|
10
|
+
%td.currency= (@booking.debit_account == @account) ? currency_fmt(@booking.amount) : content_tag('i', link_to(@booking.debit_account.code, account_path(@booking.debit_account), :title => @booking.debit_account.title))
|
11
|
+
%td.currency= currency_fmt(@saldo)
|
12
|
+
%td.action-links
|
13
|
+
= list_link_for(:edit, [@account, @booking])
|
14
|
+
= list_link_for(:delete, [@account, @booking])
|
15
|
+
= list_link_for(:copy, @booking)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
- url_params = {:controller => 'accounts', :action => 'show', :id => params[:account_id] || params[:id]}
|
2
|
+
|
3
|
+
= render 'search_form'
|
4
|
+
|
5
|
+
= paginated_section @bookings, :params => url_params.merge(:query => params[:query]) do
|
6
|
+
%table#booking_list.list.booking_list
|
7
|
+
= render 'accounts/booking_list_header'
|
8
|
+
- @saldo = @account.saldo(@bookings.first, false)
|
9
|
+
|
10
|
+
= render 'accounts/carry_booking' unless @saldo == 0
|
11
|
+
|
12
|
+
- for @booking in @bookings
|
13
|
+
- amount = @booking.amount
|
14
|
+
- amount = -(amount) if @account.is_liability_account?
|
15
|
+
- @saldo -= amount if @booking.debit_account == @account
|
16
|
+
- @saldo += amount if @booking.credit_account == @account
|
17
|
+
= render 'accounts/booking_item'
|
18
|
+
|
19
|
+
= render 'accounts/booking_list_footer' unless @bookings.empty?
|
@@ -0,0 +1,5 @@
|
|
1
|
+
%tr
|
2
|
+
- ## TODO: See http://groups.google.com/group/will_paginate/browse_thread/thread/5d702999d78e47e5
|
3
|
+
- url_params = {:controller => 'accounts', :action => 'show', :id => params[:account_id] || params[:id]}
|
4
|
+
%th{:colspan => "6", :style => "text-align: right"}= will_paginate @bookings, :params => url_params.merge(:query => params[:query])
|
5
|
+
%th
|
@@ -0,0 +1,8 @@
|
|
1
|
+
%tr#booking_list_saldo{:style => "border-top: double 2px black; background-color: grey"}
|
2
|
+
%td{:colspan => "2"}
|
3
|
+
Kontostand (per #{@bookings.last.value_date})
|
4
|
+
%td
|
5
|
+
%td
|
6
|
+
%td
|
7
|
+
%td{:style => "text-align: right"}= currency_fmt(@account.saldo(@bookings.last))
|
8
|
+
%td
|
@@ -0,0 +1,9 @@
|
|
1
|
+
- credit_turnover, debit_turnover = @account.turnover(@bookings)
|
2
|
+
%tr#booking_list_turnover{:style => "border-top: double 2px black; background-color: grey"}
|
3
|
+
%td{:colspan => "2"}
|
4
|
+
Umsatz (#{h @bookings.first.value_date} bis #{h @bookings.last.value_date})
|
5
|
+
%td
|
6
|
+
%td{:style => "text-align: right"}= currency_fmt(credit_turnover)
|
7
|
+
%td{:style => "text-align: right"}= currency_fmt(debit_turnover)
|
8
|
+
%td
|
9
|
+
%td
|