russian_invoices 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fd65e61aa0704b741c8fb3a23179ab420a7de7d3
4
+ data.tar.gz: b3e644cc6500cd7c4d34272991d718d859dc95e8
5
+ SHA512:
6
+ metadata.gz: 24c411f38a3d287345ab1bbaf66a905ade9c0561d50150145fb0057d2128dfaf322291ef5b654f67b8622c319e948d279bfcc065133477f55ef9e1f6157c4f6c
7
+ data.tar.gz: 4ecbc88d8c81b6686f5306fe3f43754cbddc24c726d48ccc9a09927f926daf5f6c4f0f3d1c23a5f9645bd597408be3d7211fdba1d05a85d82c78f427fd68a36f
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ require 'rdoc/task'
9
+
10
+ RDoc::Task.new(:rdoc) do |rdoc|
11
+ rdoc.rdoc_dir = 'rdoc'
12
+ rdoc.title = 'RussianInvoices'
13
+ rdoc.options << '--line-numbers'
14
+ rdoc.rdoc_files.include('README.rdoc')
15
+ rdoc.rdoc_files.include('lib/**/*.rb')
16
+ end
17
+
18
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
19
+ load 'rails/tasks/engine.rake'
20
+
21
+ Bundler::GemHelper.install_tasks
22
+
23
+ Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
24
+ require 'rspec/core'
25
+ require 'rspec/core/rake_task'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+ task default: :spec
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,60 @@
1
+ module RussianInvoices
2
+ module HelperMethods
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ helper_method HelperMethods.instance_methods
7
+ end
8
+
9
+ def generate_document(doc, save_to_file=true)
10
+ @doc = doc
11
+ pdf = get_pdf(obj_type(doc), doc.landscape?)
12
+ if save_to_file
13
+ tmp_file = Tempfile.new(pdf[:document_type])
14
+ tmp_file << pdf[:body]
15
+ tmp_file.close
16
+ tmp_file
17
+ else
18
+ pdf[:body]
19
+ end
20
+ end
21
+
22
+ def generate_document_str(doc)
23
+ generate_document(doc, false)
24
+ end
25
+
26
+ def render_pdf_document(doc, download=false)
27
+ pdf_str = generate_document(doc, false)
28
+ filename = obj_type(doc) + '.pdf'
29
+ disposition = download ? 'attachment' : 'inline'
30
+ send_data(pdf_str, filename: filename, disposition: disposition, type: 'application/pdf')
31
+ end
32
+
33
+ def download_pdf_document(doc)
34
+ render_pdf_document(doc, true)
35
+ end
36
+
37
+ private
38
+
39
+ def get_pdf(type, landscape=false)
40
+ orientation = landscape ? 'Landscape' : 'Portrait'
41
+ str = render_to_string(
42
+ pdf: type.to_s,
43
+ template: template_path(type),
44
+ layout: RussianInvoices::LAYOUTS[:pdf],
45
+ encoding: 'UTF-8',
46
+ orientation: orientation
47
+ )
48
+ { body: str.force_encoding("UTF-8"), document_type: type }
49
+ end
50
+
51
+ def obj_type(obj)
52
+ obj.class.name.split('::').last.underscore
53
+ end
54
+
55
+ def template_path(type)
56
+ "/russian_invoices/documents/#{ type.to_s }.html.haml"
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,5 @@
1
+ module RussianInvoices
2
+ class ApplicationController < ActionController::Base
3
+ include RussianInvoices::HelperMethods
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module RussianInvoices
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module RussianInvoices
2
+ module CommercialInvoicesHelper
3
+ end
4
+ end
@@ -0,0 +1,51 @@
1
+ class RussianInvoices::BaseModel
2
+
3
+ include ActiveModel::Model
4
+ define_model_callbacks :save
5
+
6
+ def initialize(attributes = {})
7
+ self.attributes = attributes
8
+ end
9
+
10
+ def persisted?
11
+ false
12
+ end
13
+
14
+ def save
15
+ run_callbacks :save do
16
+ valid?
17
+ end
18
+ end
19
+
20
+ def save!
21
+ if save
22
+ true
23
+ else
24
+ raise RussianInvoices::ValidationError
25
+ end
26
+ end
27
+
28
+ def landscape?
29
+ false
30
+ end
31
+
32
+ class << self
33
+
34
+ def create(attributes)
35
+ obj = new(attributes)
36
+ obj.save!
37
+ obj
38
+ end
39
+ alias create! create
40
+
41
+ end
42
+
43
+ private
44
+
45
+ def attributes=(attributes)
46
+ attributes.each do |name, value|
47
+ send("#{name}=", value)
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,21 @@
1
+ class RussianInvoices::CertificateOfCompletion < RussianInvoices::BaseModel
2
+
3
+ attr_accessor :number, :from_date,
4
+ :customer_name, :customer_inn, :customer_kpp, :customer_address,
5
+ :performer_name, :performer_inn, :performer_kpp, :performer_address,
6
+ :goods, :summ, :nds, :performer_signature, :performer_stamp
7
+
8
+ validates :nds, numericality: true
9
+ validates_presence_of :number, :from_date,
10
+ :customer_name, :customer_inn, :customer_kpp, :customer_address,
11
+ :performer_name, :performer_inn, :performer_kpp, :performer_address
12
+
13
+ def total_summ
14
+ goods.sum{ |good| good[:quantity]*good[:price] }.round(2)
15
+ end
16
+
17
+ def nds_summ
18
+ (total_summ * nds / 100).round(2)
19
+ end
20
+
21
+ end
@@ -0,0 +1,53 @@
1
+ class RussianInvoices::CommercialInvoice < RussianInvoices::BaseModel
2
+
3
+ attr_accessor :invoice_number, :invoice_from_date, :correction_number, :correction_date,
4
+ :vendor_name, :vendor_address, :vendor_inn, :vendor_kpp,
5
+ :shipper_name, :shipper_address,
6
+ :consignee_name, :consignee_address, :to_the_payment_documents,
7
+ :buyer_name, :buyer_address, :buyer_inn, :buyer_kpp,
8
+ :currency_name, :currency_code,
9
+ :goods, :chief_organization, :chief_accountant,
10
+ :chief_organization_signature, :chief_accountant_signature,
11
+ :stamp
12
+
13
+ validates_presence_of :invoice_number, :invoice_from_date,
14
+ :vendor_name, :vendor_address, :vendor_inn, :vendor_kpp,
15
+ :shipper_name,
16
+ :consignee_name, :consignee_address, :to_the_payment_documents,
17
+ :buyer_name, :buyer_address, :buyer_inn, :buyer_kpp
18
+ GOOD_FIELDS = %w(name code unit quantity price excise_price tax digital_code country number_of_customs_declaration buyer_tax_summ summ)
19
+
20
+ before_save :prepare_data
21
+
22
+ def landscape?
23
+ true
24
+ end
25
+
26
+ def shipper
27
+ shipper_name
28
+ "#{ shipper_name }, Адрес: #{ shipper_address }" unless shipper_address.blank?
29
+ end
30
+
31
+ def consignee
32
+ consignee_name
33
+ "#{ consignee_name }, Адрес: #{ consignee_address }" unless consignee_address.blank?
34
+ end
35
+
36
+ protected
37
+
38
+ def prepare_data
39
+ self.invoice_number = invoice_number.to_s.rjust(6, '0')
40
+ self.correction_number = if correction_number
41
+ invoice_number.to_s.rjust(3, '0')
42
+ else
43
+ '---'
44
+ end
45
+ self.correction_date ||= '---'
46
+ goods.each do |good|
47
+ GOOD_FIELDS.each do |field|
48
+ good[field.to_sym] ||= '---'
49
+ end
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,11 @@
1
+ class RussianInvoices::Contract < RussianInvoices::BaseModel
2
+
3
+ attr_accessor :number, :from_date, :name, :city, :body,
4
+ :customer_details, :customer_position, :customer_signature, :customer_stamp,
5
+ :performer_details, :performer_position, :performer_signature, :performer_stamp
6
+
7
+ validates_presence_of :name, :number, :city, :from_date, :body,
8
+ :customer_details, :performer_details,
9
+ :customer_position, :performer_position
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{ :'http-equiv' => 'Content-Type', content: 'text/html; charset=utf-8' }
5
+ %style{ type: 'text/css' }
6
+ :sass
7
+ body
8
+ font-size: 12px
9
+ font-family: Tahoma, Geneva, sans-serif
10
+ %body
11
+ = yield
@@ -0,0 +1,133 @@
1
+ :css
2
+ .act_st1 {
3
+ border-top: 2px solid #000;
4
+ border-left: 2px solid #000;
5
+ color: #000;
6
+ font-weight: bold;
7
+ font-size: 12px;
8
+ font-style: normal;
9
+ text-align: center;
10
+ font-family: Arial,Verdanaa, sans-serif;
11
+ line-height: 1.3;
12
+ }
13
+ .act_st2 {
14
+ border-top: 2px solid #000;
15
+ border-left: 2px solid #000;
16
+ color: #000;
17
+ font-weight: bold;
18
+ font-size: 12px;
19
+ font-style: normal;
20
+ text-align: center;
21
+ font-family: Arial,Verdanaa, sans-serif;
22
+ line-height: 1.3;
23
+ }
24
+ .act_st3 {
25
+ border-top: 2px solid #000;
26
+ line-height: 0;
27
+ }
28
+
29
+ %table{ width: 720, cellspacing: 0, cellpadding: 0, bgcolor: '#fff', style: 'margin: 0; padding: 0; border: 0 none; border-collapse: collapse; background-color: #fff;' }
30
+ %tr
31
+ %td{ colspan: 2, valign: 'top', style: 'color: #000; border-bottom: 2px solid #000; font-size: 19px; font-style: normal; font-weight: bold; text-align: left; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' }= "Акт № #{ @doc.number } от #{ @doc.from_date }"
32
+ %tr
33
+ %td{ colspan: 2, height: 10 }
34
+ %tr
35
+ %td{ width: 90, valign: 'middle', style: 'color: #000; font-size: 12px; font-style: normal; text-align: left; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' } Заказчик:
36
+ %td{ valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: bold; text-align: left; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' }
37
+ = @doc.customer_name
38
+ ИНН/КПП :
39
+ = @doc.customer_inn
40
+ \/
41
+ = @doc.customer_kpp
42
+ ,
43
+ = @doc.customer_address
44
+ %tr
45
+ %td{ colspan: 2, height: 10 }
46
+ %tr
47
+ %td{ width: 90, valign: 'middle', style: 'color: #000; font-size: 12px; font-style: normal; text-align: left; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' } Исполнитель:
48
+ %td{ valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: bold; text-align: left; font-family: Arial,Verdana,sans-serif; line-height: 1.3;'}
49
+ = @doc.performer_name
50
+ = "ИНН/КПП #{ @doc.performer_inn } / #{ @doc.performer_kpp },"
51
+ = @doc.performer_address
52
+ %tr
53
+ %td{ colspan: 2, height: 10 }
54
+ %tr
55
+ %td{ colspan: 2 }
56
+ %table{ width: '100%', cellspacing: 0, cellpadding: 0 }
57
+ %tr
58
+ %td.act_st1{ width: 42, height: 25, valign: 'middle' } №
59
+ %td.act_st1{ width: 360, valign: 'middle' } Наименование работ, услуг
60
+ %td.act_st1{ width: 76, valign: 'middle' } Кол-во
61
+ %td.act_st1{ width: 42, valign: 'middle' } Ед.
62
+ %td.act_st1{ width: 86, valign: 'middle' } Цена
63
+ %td.act_st1{ valign: 'middle', style: 'border-right: 2px solid #000;' } Сумма
64
+ - @doc.goods.each_with_index do |good, index|
65
+ %tr
66
+ %td.act_st2{ height: 20, valign: 'top' }= index+1
67
+ %td.act_st2{ valign: 'top' }= good[:name]
68
+ %td.act_st2{ valign: 'top' }= good[:quantity].to_f
69
+ %td.act_st2{ valign: 'top' }= good[:unit]
70
+ %td.act_st2{ valign: 'top' }= good[:price].to_f.round(2)
71
+ %td.act_st2{ valign: 'top', style: 'border-right: 2px solid #000;' }= (good[:price].to_f * good[:quantity].to_f).round(2)
72
+ %tr
73
+ %td.act_st3{ colspan: 6 }
74
+ %tr
75
+ %td{ colspan: 2, height: 10 }
76
+ %tr
77
+ %td{ colspan: 2 }
78
+ %table{ width: '100%', cellspacing: 0, cellpadding: 0 }
79
+ %tr
80
+ %td
81
+ %td{ width: 148, valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: bold; text-align: right; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' } Итого:
82
+ %td{ width: 88, valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: normal; text-align: right; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' }= @doc.summ
83
+ - if @doc.nds && !@doc.nds.zero?
84
+ %tr
85
+ %td
86
+ %td{ valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: bold; text-align: right; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' } В том числе НДС:
87
+ %td{ valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: normal; text-align: right; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' }= @doc.nds_summ
88
+ - else
89
+ %tr
90
+ %td
91
+ %td{ valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: bold; text-align: right; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' } Без налога (НДС):
92
+ %td{ valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: normal; text-align: right; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' } &mdash;
93
+ %tr
94
+ %td
95
+ %td{ valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: bold; text-align: right; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' } Всего к оплате:
96
+ %td{ valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: normal; text-align: right; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' }= @doc.total_summ
97
+ %tr
98
+ %td{ colspan: 2, height: 10 }
99
+ %tr
100
+ %td{ colspan: 2, valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; text-align: left; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' }
101
+ %div Всего оказано услуг
102
+ = @doc.goods.length
103
+ , на сумму
104
+ = @doc.total_summ
105
+ руб.
106
+ %div{ style: 'font-weight: bold;' } Сумма прописью:
107
+ = RuPropisju.rublej(@doc.total_summ).mb_chars.capitalize.to_s
108
+ %tr
109
+ %td{ colspan: 2, height: 20 }
110
+ %tr
111
+ %td{ colspan: 2, valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; text-align: left; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' } Вышеперечисленные услуги выполнены полностью и в срок. Заказчик претензий по объему, качеству и срокам оказания услуг не имеет.
112
+ %tr
113
+ %td{ style: 'border-bottom: 2px solid #000;" colspan: 2 height: 10' }
114
+ %tr
115
+ %td{ colspan: 2, height: 20 }
116
+ %tr
117
+ %td{ colspan: 2 }
118
+ %table{ width: '100%', cellspacing: 0, cellpadding: 0 }
119
+ %tr
120
+ %td{ valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: bold; text-align: left; font-family: Arial,Verdana,sans-serif; line-height: 1.3; width: 85px;' } Исполнитель
121
+ %td{ width: 30 }
122
+ %td{ width: 300, valign: 'top', style: 'color: #000; font-size: 11px; border-bottom: 1px solid #000; font-style: normal; font-weight: normal; text-align: center; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' }
123
+ %img{ src: @doc.performer_signature, style: 'max-width: 200px' }
124
+ %td{ width: 30 }
125
+ %td{ valign: 'top', style: 'color: #000; font-size: 12px; font-style: normal; font-weight: bold; text-align: left; font-family: Arial,Verdana,sans-serif; line-height: 1.3; width: 60px;' } Заказчик
126
+ %td{ width: 30 }
127
+ %td{ width: 300, valign: 'top', style: 'color: #000; font-size: 11px; border-bottom: 1px solid #000; font-style: normal; font-weight: normal; text-align: center; font-family: Arial,Verdana,sans-serif; line-height: 1.3;' }
128
+ %table{ style: 'width:100%; margin-top: 20px;' }
129
+ %tbody
130
+ %tr
131
+ %td{ style: 'width: 50%; text-align: left; padding-left: 95px;' }
132
+ %img{ src: @doc.performer_stamp, style: 'max-width: 200px' }
133
+ %td{ style: 'width: 50%; text-align: left; padding-left: 25px;' }
@@ -0,0 +1,173 @@
1
+ :css
2
+ #right_header {
3
+ float: right;
4
+ text-align: right;
5
+ width: 200px;
6
+ font-size: 8px;
7
+ }
8
+ .clearfix {
9
+ clear: both;
10
+ width: 100%;
11
+ height: 1px;
12
+ }
13
+ #header {
14
+ margin-top: 20px;
15
+ font-weight: bold;
16
+ font-size: 16px;
17
+ }
18
+ #top_details {
19
+ margin-top: 7px;
20
+ font-size: 11px;
21
+ }
22
+ #goods {
23
+ margin-top: 15px;
24
+ width: 100%;
25
+ font-size: 11px;
26
+ }
27
+ #goods th {
28
+ border-top: solid 1px #000;
29
+ border-left: solid 1px #000;
30
+ font-weight: normal;
31
+ padding: 3px 2px 2px 1px;
32
+ }
33
+ #goods thead tr th:last-child{
34
+ border-right: solid 1px #000;
35
+ }
36
+ #goods thead tr th.without_right_border{
37
+ border-right: none;
38
+ }
39
+ #goods td {
40
+ border-top: solid 1px #000;
41
+ border-left: solid 1px #000;
42
+ font-weight: normal;
43
+ padding: 3px 4px 4px 1px;
44
+ text-align: center;
45
+ }
46
+ #goods tbody tr td:first-child{
47
+ text-align: left;
48
+ }
49
+ #goods tbody tr td:last-child{
50
+ border-right: solid 1px #000;
51
+ }
52
+ #goods tr.last td{
53
+ border-bottom: solid 1px #000;
54
+ }
55
+ #goods td.with_bottom{
56
+ border-bottom: solid 1px #000;
57
+ }
58
+ #document
59
+ #right_header
60
+ ПРИЛОЖЕНИЕ № 1
61
+ %br
62
+ к постановлению Правительства
63
+ %br
64
+ Российской Федерации
65
+ %br
66
+ от 26 декабря 2011 г. № 1137
67
+ .clearfix
68
+ #header
69
+ СЧЕТ-ФАКТУРА №
70
+ = @doc.invoice_number
71
+ от
72
+ = @doc.invoice_from_date
73
+ %br
74
+ ИСПРАВЛЕНИЕ №
75
+ = @doc.correction_number
76
+ от
77
+ = @doc.correction_date
78
+ #top_details
79
+ %strong Продавец:
80
+ = @doc.vendor_name
81
+ %br
82
+ %strong Адрес:
83
+ = @doc.vendor_address
84
+ %br
85
+ %strong ИНН/КПП продавца:
86
+ = "#{ @doc.vendor_inn }/#{ @doc.vendor_kpp }"
87
+ %br
88
+ %strong Грузоотправитель и его адрес:
89
+ = @doc.shipper
90
+ %br
91
+ %strong Грузополучатель и его адрес:
92
+ = @doc.consignee
93
+ %br
94
+ %strong К платежно-расчетному документу
95
+ = @doc.to_the_payment_documents
96
+ %br
97
+ %strong Покупатель:
98
+ = @doc.buyer_name
99
+ %br
100
+ %strong Адрес:
101
+ = @doc.buyer_address
102
+ %br
103
+ %strong ИНН/КПП покупателя:
104
+ = "#{ @doc.buyer_inn }/#{ @doc.buyer_kpp } "
105
+ %br
106
+ %strong Валюта: наименование, код:
107
+ = "#{ @doc.currency_name }, #{ @doc.currency_code }"
108
+ %table#goods{ cellspacing: 0, cellpadding: 0 }
109
+ %thead
110
+ %tr
111
+ %th{ rowspan: 2, width: '160px' }
112
+ Наименование товара (описание выполненных работ, оказанных услуг), имущественного права
113
+ %th{ colspan: 2 } Единица измерения
114
+ %th{ rowspan: 2 } Коли- чество (объ- ем)
115
+ %th{ rowspan: 2 } Цена (тариф) за единицу измерения
116
+ %th{ rowspan: 2, width: '100px' } Стоимость товаров (работ, услуг), имущественных прав без налога-всего
117
+ %th{ rowspan: 2 } В том числе сумма акциза
118
+ %th{ rowspan: 2 } Налого- вая ставка
119
+ %th{ rowspan: 2, width: '50px' } Сумма налога, предъяв- ляемая покупа- телю
120
+ %th{ rowspan: 2 } Стоимость товаров (работ, услуг), имущественных прав с налогом - всего
121
+ %th{ colspan: 2, width: '150px' } Страна происхождения товара
122
+ %th{ rowspan: 2, width: '140px' } Номер таможенной декларации
123
+ %tr
124
+ %th{ width: '23px;' } код
125
+ %th
126
+ условное обозначение
127
+ %nobr (национальное)
128
+ %th
129
+ цифро- вой
130
+ %nobr код
131
+ %th.without_right_border краткое наимено- вание
132
+ %tr
133
+ %th 1
134
+ %th 2
135
+ %th 2а
136
+ %th 3
137
+ %th 4
138
+ %th 5
139
+ %th 6
140
+ %th 7
141
+ %th 8
142
+ %th 9
143
+ %th 10
144
+ %th 10а
145
+ %th 11
146
+ %tbody
147
+ - @doc.goods.each do |good|
148
+ - quantity = good[:quantity].to_f.to_s.split('.')
149
+ %tr
150
+ - last_class = @doc.goods.last == good ? 'with_bottom' : nil
151
+ %td= good[:name]
152
+ %td= good[:code]
153
+ %td= good[:unit]
154
+ %td= "#{ quantity.first }.#{ quantity.last.ljust(3, '0') } "
155
+ %td= good[:price].to_f
156
+ %td= good[:price].to_f*good[:quantity].to_f
157
+ %td
158
+ - if good[:excise_price].blank?
159
+ Без акциза
160
+ - else
161
+ = good[:excise_price].to_f
162
+ %td= good[:tax]
163
+ %td= good[:buyer_tax_summ]
164
+ %td= good[:summ]
165
+ %td{ class: last_class }= good[:digital_code]
166
+ %td{ class: last_class }= good[:country]
167
+ %td{ class: last_class }= good[:number_of_customs_declaration]
168
+ %tr.last
169
+ %td{ colspan: 5 }
170
+ %td= @doc.goods.map { |g| g[:price]*g[:quantity] }.sum.to_s
171
+ %td{ colspan: 2 } X
172
+ %td= @doc.goods.map { |g| g[:buyer_tax_summ].to_f }.sum.to_s
173
+ %td= @doc.goods.map { |g| g[:summ].to_f }.sum.to_s
@@ -0,0 +1,96 @@
1
+ %style{ type: 'text/css' }
2
+ :sass
3
+ #document_body
4
+ font-size: 12px
5
+ font-family: Tahoma, Geneva, sans-serif
6
+ #header
7
+ font-weight: bold
8
+ font-size: 16px
9
+ #header_table
10
+ font-size: 13px
11
+ width: 100%
12
+ td
13
+ width: 50%
14
+ .city
15
+ text-align: left
16
+ .date
17
+ text-align: right
18
+ #doc_body
19
+ font-size: 12px
20
+ #footer
21
+ margin-top: 30px
22
+ font-size: 12px
23
+ font-family: Tahoma, Geneva, sans-serif
24
+ .header
25
+ display: block
26
+ width: 100%
27
+ text-align: center
28
+ font-size: 14px
29
+ font-weight: bold
30
+ table.details
31
+ margin-top: 40px
32
+ width: 100%
33
+ th
34
+ text-align: center
35
+ font-size: 13px
36
+ td
37
+ width: 50%
38
+ vertical-align: top
39
+ padding-top: 10px
40
+ td:first-of-type
41
+ padding-right: 15px
42
+ td:last-of-type
43
+ padding-left: 15px
44
+ tr.positions
45
+ td:first-of-type
46
+ padding-left: 15px
47
+ td:last-of-type
48
+ padding-left: 30px
49
+ tr.signature td
50
+ min-height: 50px
51
+ vertical-align: bottom
52
+
53
+ #document_body
54
+ %h1#header{ align: 'center' }
55
+ Договор
56
+ = @doc.name
57
+
58
+ = @doc.number
59
+ %table#header_table
60
+ %tbody
61
+ %tr
62
+ %td.city
63
+ г.
64
+ = @doc.city
65
+ %td.date
66
+ = @doc.from_date
67
+ #doc_body
68
+ != @doc.body
69
+ #footer
70
+ %span.header Реквизиты и подписи сторон
71
+ %table.details
72
+ %thead
73
+ %tr
74
+ %th Заказчик
75
+ %th Исполнитель
76
+ %tbody
77
+ %tr
78
+ %td
79
+ != @doc.customer_details
80
+ %td
81
+ != @doc.performer_details
82
+ %tr.positions
83
+ %td= @doc.customer_position
84
+ %td= @doc.performer_position
85
+ %tr.positions.signature
86
+ %td
87
+ %img{ src: @doc.customer_signature, width: '200px' }
88
+ ________________________________
89
+ %td
90
+ %img{ src: @doc.performer_signature, width: '200px' }
91
+ ________________________________
92
+ %tr.positions
93
+ %td
94
+ %img{ src: @doc.customer_stamp, style: 'max-width: 200px;' }
95
+ %td
96
+ %img{ src: @doc.performer_stamp, style: 'max-width: 200px;' }
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ RussianInvoices::Engine.routes.draw do
2
+
3
+ namespace :documents do
4
+ resources :commercial_invoices, only: :new
5
+ end
6
+
7
+ end
@@ -0,0 +1,18 @@
1
+ require 'wicked_pdf'
2
+ require 'haml-rails'
3
+ require 'ru_propisju'
4
+ require "russian_invoices/engine"
5
+ require "russian_invoices/settings"
6
+ require "russian_invoices/errors"
7
+
8
+ module RussianInvoices
9
+
10
+ class Engine < ::Rails::Engine
11
+ config.generators do |g|
12
+ g.test_framework :rspec, fixture: false
13
+ g.assets false
14
+ g.helper false
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,5 @@
1
+ module RussianInvoices
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace RussianInvoices
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module RussianInvoices
2
+
3
+ ValidationError = Class.new(StandardError)
4
+ UndefinedDocumentType = Class.new(StandardError)
5
+
6
+ end
@@ -0,0 +1,5 @@
1
+ module RussianInvoices
2
+
3
+ LAYOUTS = { pdf: 'russian_invoices/application.html.haml' }
4
+
5
+ end
@@ -0,0 +1,3 @@
1
+ module RussianInvoices
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :russian_invoices do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: russian_invoices
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Your name
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sqlite3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: haml-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sass-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: wicked_pdf
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: wkhtmltopdf-binary
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: ru_propisju
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Description of RussianInvoices.
126
+ email:
127
+ - Your email
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - MIT-LICENSE
133
+ - Rakefile
134
+ - app/assets/javascripts/russian_invoices/application.js
135
+ - app/assets/javascripts/russian_invoices/commercial_invoices.js
136
+ - app/assets/stylesheets/russian_invoices/application.css
137
+ - app/assets/stylesheets/russian_invoices/commercial_invoices.css
138
+ - app/controllers/concerns/russian_invoices/helper_methods.rb
139
+ - app/controllers/russian_invoices/application_controller.rb
140
+ - app/helpers/russian_invoices/application_helper.rb
141
+ - app/helpers/russian_invoices/commercial_invoices_helper.rb
142
+ - app/models/russian_invoices/base_model.rb
143
+ - app/models/russian_invoices/certificate_of_completion.rb
144
+ - app/models/russian_invoices/commercial_invoice.rb
145
+ - app/models/russian_invoices/contract.rb
146
+ - app/views/layouts/russian_invoices/application.html.haml
147
+ - app/views/russian_invoices/documents/certificate_of_completion.html.haml
148
+ - app/views/russian_invoices/documents/commercial_invoice.html.haml
149
+ - app/views/russian_invoices/documents/contract.html.haml
150
+ - config/routes.rb
151
+ - lib/russian_invoices.rb
152
+ - lib/russian_invoices/engine.rb
153
+ - lib/russian_invoices/errors.rb
154
+ - lib/russian_invoices/settings.rb
155
+ - lib/russian_invoices/version.rb
156
+ - lib/tasks/russian_invoices_tasks.rake
157
+ homepage: ''
158
+ licenses:
159
+ - MIT
160
+ metadata: {}
161
+ post_install_message:
162
+ rdoc_options: []
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ requirements: []
176
+ rubyforge_project:
177
+ rubygems_version: 2.4.5
178
+ signing_key:
179
+ specification_version: 4
180
+ summary: Summary of RussianInvoices.
181
+ test_files: []