rs.ge 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +87 -3
- data/lib/rs.rb +1 -0
- data/lib/rs/print.rb +324 -0
- data/lib/rs/version.rb +1 -1
- data/lib/rs/waybill.rb +1 -0
- data/rs.gemspec +2 -0
- data/spec/rs/pdf_spec.rb +20 -0
- data/tmp/waybill.pdf +29957 -3
- metadata +44 -12
data/README.md
CHANGED
@@ -8,7 +8,9 @@
|
|
8
8
|
|
9
9
|
გამოყენებისათვის უნდა ჩასვათ შემდეგი ხაზი თქვენს Gemfile-ში:
|
10
10
|
|
11
|
-
|
11
|
+
```
|
12
|
+
gem 'rs.ge', '~> 0.0.7'
|
13
|
+
```
|
12
14
|
|
13
15
|
შემდეგი გამოყენება ძალიან მარტივია:
|
14
16
|
|
@@ -18,6 +20,88 @@ require 'rs'
|
|
18
20
|
puts RS.what_is_my_ip # თქვენს IP მისამართს დაბეჭდავს კონსოლში
|
19
21
|
```
|
20
22
|
|
21
|
-
##
|
23
|
+
## სისტემური ფუნქციები
|
24
|
+
|
25
|
+
თქვენი IP-ს გასაგებად შეგიძლიათ გამოიყენოთ `what_is_my_ip` ფუნქცია:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
my_ip = RS.what_is_my_ip
|
29
|
+
```
|
30
|
+
|
31
|
+
სერვისის სხვა მეთოდების გამოსაყენებლად უნდა გქონდეთ შექმნილი სერვისის მომხმარებელი.
|
32
|
+
სერვისის მომხმარებლის შესაქმენლად დაგჭირდებათ თქვენს ორგანიზაციაზე მინიჭებული მომხმარებლის სახელი და პაროლი.
|
33
|
+
|
34
|
+
ახალი სერვისის მომხმარებლის შესაქმნელად გამოიყენეთ `create_service_user` ფუნქცია:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
was_created = RS.create_service_user(params)
|
38
|
+
```
|
39
|
+
|
40
|
+
`params` წარმოადგენს შემდეგი მონაცემების ჰეშს (ყველა პარამეტრი აუცილებელია):
|
41
|
+
|
42
|
+
- `user_name` — თქვენი ორგანიზაციის მომხმარებლის სახელი;
|
43
|
+
- `user_password` — თქვენი ორგანიზაციის პაროლი;
|
44
|
+
- `ip` — IP მისამართი, რომლიდანაც შეგიძლიათ იმუშაოთ;
|
45
|
+
- `su` — ახალი სერვისის მომხმარებლის სახელი;
|
46
|
+
- `sp` — სერვისის მომხმარებლის პაროლი.
|
47
|
+
|
48
|
+
ეს ბუნქცია აბრუნებს `boolean` ტიპის მნიშვნელობას: თუ მომხმარებელი შეიქმნა, ბრუნდება `true`, ხოლო `false` — წინააღმდეგ შემთხვევაში. თუ რატომ არ მოხდა მომხმარებლის გახსნა შეიძლება მხოლოდ ვივარაუდოდ: ამის შესახებ rs-ის სერვისი არანაირ პასუხს არ იძლევა.
|
49
|
+
|
50
|
+
ძალაინ მნიშვნელოვანი ფუნქციაა `check_service_user`, რომელიც გარდა იმისა, რომ ამოწმებს ახლად შექმნილი მომხმარებლის სახელს და პაროლს, ასევე გაძლევთ შანსს გაიგოთ თქვენი ორგანიზაციის გადამხდელის ID. ამ ფუნქციის გამოძახება ასე გამოიყურება:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
user = RS.check_service_user(params)
|
54
|
+
```
|
55
|
+
|
56
|
+
გადასაცემი პარამეტრების სია გაცილებით მოკრძალებულია:
|
57
|
+
|
58
|
+
- `su` — სერვისის მომხმარებლის სახელი;
|
59
|
+
- `sp` — სერვისის მომხმარებლის პაროლი.
|
60
|
+
|
61
|
+
თუ `su` და `sp` პარამეტრების სწორადაა მოწოდებულია, მაშინ `RS::User` ობიექტი ბრუნდება, რომელიც შეიცავს `payer_id` თვისებას, სადაც თქვენი ორგანიზაციის გადამხდელის საიდენტიფიკაციო კოდია ჩაწერილი. თუ ავტორიზაციის მონაცემები არასწორადაა მიწოდებული, ეს მეთოდი დააბრუნებს `nil` მნიშვნელობას.
|
62
|
+
|
63
|
+
ასევე მარტივია მომხმარებლის მონაცემების შეცვლა. ამისათვის `update_service_user` მეთოდი შეგიძლიათ გამოიყენოთ:
|
64
|
+
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
was_updated = RS.create_service_user(params)
|
68
|
+
```
|
69
|
+
|
70
|
+
`params` წარმოადგენს მონაცემების ჰეშს, რომელიც მსგავსია იმისა, რასაც გადავცემდით `create_service_user` ფუნქციის გამოძახებისა:
|
71
|
+
|
72
|
+
- `user_name` — თქვენი ორგანიზაციის მომხმარებლის სახელი;
|
73
|
+
- `user_password` — თქვენი ორგანიზაციის პაროლი;
|
74
|
+
- `ip` — IP მისამართი, რომლიდანაც შეგიძლიათ იმუშაოთ;
|
75
|
+
- `su` — სერვისის მომხმარებლის სახელი;
|
76
|
+
- `sp` — სერვისის მომხმარებლის პაროლი.
|
77
|
+
|
78
|
+
თქვენი ორგანიზაციის მომხმარებელთა სიის სანახავად გამოიყენეთ `get_service_users` მეთოდი:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
users = RS.get_service_users(params)
|
82
|
+
```
|
83
|
+
|
84
|
+
პარამეტრებში უნდა გადაეცეს შემდეგი მონაცემები:
|
85
|
+
|
86
|
+
- `user_name` — თქვენი ორგანიზაციის მომხმარებლის სახელი;
|
87
|
+
- `user_password` — თქვენი ორგანიზაციის პაროლი.
|
88
|
+
|
89
|
+
ეს ფუნქცია აბრუნებს `RS::User` ტიპის (მომხმარებლის კლასი) ობიექტების მასივს.
|
90
|
+
|
91
|
+
ბოლო სასარგებლო სისტემური ფუნქციაა `get_name_from_tin`, რომლის დახმარებით შეგიძლიათ ორგანიზაციის საიდენტიფიკაციო ნომრიდან (ან პირადი ნომრიდან) მიიღოთ ამ ორგანიზაციის (პირის) დასახელება.
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
name = RS.get_name_from_tin(params)
|
95
|
+
```
|
96
|
+
|
97
|
+
- `su` — სერვისის მომხმარებლის სახელი;
|
98
|
+
- `sp` — სერვისის მომხმარებლის პაროლი;
|
99
|
+
- `tin` — საიდენტიფიკაციო ნომერი ან პირადი ნომერი.
|
100
|
+
|
101
|
+
## ცნობარის ფუნქციები
|
102
|
+
|
103
|
+
TODO:
|
104
|
+
|
105
|
+
## ზედნადებთან მუშაობა
|
22
106
|
|
23
|
-
TODO:
|
107
|
+
TODO:
|
data/lib/rs.rb
CHANGED
data/lib/rs/print.rb
ADDED
@@ -0,0 +1,324 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
require 'c12-commons'
|
4
|
+
|
5
|
+
module RS
|
6
|
+
|
7
|
+
def self.print_waybill(waybill, file, opts = {})
|
8
|
+
C12::PDF::Document.generate file, :page_size => 'A4', :margin => [15, 15] do |pdf|
|
9
|
+
render_waybill waybill, pdf, opts
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
HIGHLIGHT = 'eeeeee'
|
16
|
+
NUM_CELL_WIDTH = 18
|
17
|
+
DEF_FONT_SIZE = 7
|
18
|
+
SMALLER_FONT_SIZE = 6
|
19
|
+
SMALL_FONT_SIZE = 5
|
20
|
+
FOOTER_HEIGHT = 250
|
21
|
+
|
22
|
+
def self.render_waybill(waybill, pdf, opts = {})
|
23
|
+
pdf.change_font :default, DEF_FONT_SIZE
|
24
|
+
render_cell_01(waybill, pdf)
|
25
|
+
pdf.move_down 10
|
26
|
+
render_cell_02_and_03(waybill, pdf)
|
27
|
+
pdf.move_down 10
|
28
|
+
render_cells_04_and_05(waybill, pdf)
|
29
|
+
pdf.move_down 10
|
30
|
+
render_cells_06_07_and_08(waybill, pdf)
|
31
|
+
pdf.move_down 10
|
32
|
+
render_cells_09_and_10(waybill, pdf)
|
33
|
+
pdf.move_down 10
|
34
|
+
render_cells_11_and_12(waybill, pdf)
|
35
|
+
pdf.move_down 20
|
36
|
+
# items and footer
|
37
|
+
pdf.change_font :serif, DEF_FONT_SIZE + 2
|
38
|
+
pdf.text 'სასაქონლო ზედნადების ცხრილი', :align => :center
|
39
|
+
pdf.move_down 10
|
40
|
+
pdf.change_font :default, DEF_FONT_SIZE
|
41
|
+
last_index = render_items waybill, 0, pdf
|
42
|
+
pdf.move_down 5
|
43
|
+
render_footer(waybill, pdf, 0, last_index)
|
44
|
+
render_remaining_items(waybill, last_index + 1, pdf)
|
45
|
+
# numerate pages
|
46
|
+
pages = pdf.page_count
|
47
|
+
(1..pages).each do |i|
|
48
|
+
pdf.go_to_page i
|
49
|
+
pdf.bounding_box [0,0], :width => 300, :height => 15 do
|
50
|
+
pdf.text opts[:bottom_text], :inline_format => true
|
51
|
+
end if opts[:bottom_text]
|
52
|
+
txt = "გვერდი #{i} / #{pages}-დან"
|
53
|
+
txt_w = pdf.width_of txt
|
54
|
+
pdf.bounding_box [pdf.bounds.right - pdf.bounds.left - txt_w, 0], :width => txt_w, :height => 15 do
|
55
|
+
pdf.text txt
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.render_remaining_items(waybill, from_index, pdf)
|
62
|
+
return if waybill.items.size < from_index
|
63
|
+
pdf.start_new_page
|
64
|
+
pdf.change_font :serif, 10
|
65
|
+
pdf.text "სასაქონლო ზედნადები №#{waybill.number}", :align => :center
|
66
|
+
pdf.change_font :default, DEF_FONT_SIZE
|
67
|
+
pdf.move_down 20
|
68
|
+
last_index = render_items waybill, from_index, pdf
|
69
|
+
pdf.move_down 5
|
70
|
+
render_footer(waybill, pdf, from_index, last_index)
|
71
|
+
render_remaining_items(waybill, last_index + 1, pdf)
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.render_cell_01(waybill, pdf)
|
75
|
+
items = [['', 'სასაქონლო ზედნადები №', '1', '', waybill.number]]
|
76
|
+
cols = place_table_into_center [0, 150, NUM_CELL_WIDTH, 5, 100], pdf
|
77
|
+
tbl = pdf.make_table items, :cell_style => {:padding => 4, :align => :center}, :column_widths => cols do
|
78
|
+
column(0..1).style(:borders => [], :align => :left, :size => DEF_FONT_SIZE + 2)
|
79
|
+
column(2).style(:background_color => HIGHLIGHT)
|
80
|
+
column(3).style(:borders => [])
|
81
|
+
end
|
82
|
+
tbl.draw
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.render_cell_02_and_03(waybill, pdf)
|
86
|
+
items1 = [['', '2', '', C12::KA.format_date(waybill.activate_date), '', '3', '', waybill.activate_date.strftime('%H:%M')]]
|
87
|
+
items2 = [['', '', 'თარიღი (რიცხვი, თვე, წელი)', '', '', 'დრო (საათი, წუთი)']]
|
88
|
+
cols1 = place_table_into_center [0, NUM_CELL_WIDTH, 5, 80, 32, NUM_CELL_WIDTH, 5, 80], pdf
|
89
|
+
cols2 = place_table_into_center [0, NUM_CELL_WIDTH + 5, 80, 32, NUM_CELL_WIDTH + 5, 80], pdf
|
90
|
+
tbl1 = pdf.make_table items1, :cell_style => {:padding => 4, :align => :center}, :column_widths => cols1 do
|
91
|
+
column(0).style({:borders => []})
|
92
|
+
column(1).style({:background_color => HIGHLIGHT})
|
93
|
+
column(2).style({:borders => []})
|
94
|
+
column(4).style({:borders => []})
|
95
|
+
column(5).style({:background_color => HIGHLIGHT})
|
96
|
+
column(6).style({:borders => []})
|
97
|
+
end
|
98
|
+
tbl2 = pdf.make_table items2, :cell_style => {:padding => 1, :align => :center, :borders => [], :size => SMALL_FONT_SIZE}, :column_widths => cols2
|
99
|
+
tbl1.draw
|
100
|
+
tbl2.draw
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.render_cells_04_and_05(waybill, pdf)
|
104
|
+
tbl1 = tax_code_box(pdf, 'გამყიდველი (გამგზავნი)', '4', waybill.seller_tin)
|
105
|
+
tbl2 = tax_code_box(pdf, 'მყიდველი (მიმღები)', '5', waybill.buyer_tin)
|
106
|
+
items = [[tbl1, '', tbl2]]
|
107
|
+
widths = [tbl1.width, pdf.bounds.width/2 - tbl1.width, tbl2.width]
|
108
|
+
pdf.table items, :cell_style => {:padding => 0, :borders => []}, :column_widths => widths
|
109
|
+
pdf.move_down 5
|
110
|
+
items = [[nvl(waybill.seller_name, ''), '', nvl(waybill.buyer_name, '')], ['დასახელება, ან სახელი და გვარი', '', 'დასახელება, ან სახელი და გვარი']]
|
111
|
+
pdf.table items, :cell_style => {:padding => 0, :borders => [], :align => :center}, :column_widths => [pdf.bounds.width/2 - 5, 10, pdf.bounds.width/2 - 5] do
|
112
|
+
row(0).style(:borders => [:bottom], :padding => 5, :size => DEF_FONT_SIZE + 1)
|
113
|
+
column(1).style(:borders => [])
|
114
|
+
row(1).style(:size => SMALL_FONT_SIZE)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.render_cells_06_07_and_08(waybill, pdf)
|
119
|
+
items1 = [['6', 'ოპერაციის შინაარსი', RS::WaybillType::NAMES[waybill.type]]]
|
120
|
+
tbl1 = pdf.make_table items1, :cell_style => {:align => :center}, :column_widths => [NUM_CELL_WIDTH, 70, 100] do
|
121
|
+
column(0).style(:background_color => HIGHLIGHT)
|
122
|
+
column(1).style(:borders => [], :size => DEF_FONT_SIZE - 1)
|
123
|
+
end
|
124
|
+
items2 = [['7', '', waybill.start_address], ['', '', 'ტრანსპორტირების დაწყების ადგილი (მისამართი)'],
|
125
|
+
['8', '', waybill.end_address ], ['', '', 'ტრანსპორტირების დასრულების ადგილი (მისამართი)']]
|
126
|
+
tbl2 = pdf.make_table items2, :column_widths => [NUM_CELL_WIDTH, 5, pdf.bounds.width - NUM_CELL_WIDTH - 5 - 10 - tbl1.width] do
|
127
|
+
column(0).style(:align => :center)
|
128
|
+
column(1).style(:borders => [])
|
129
|
+
column(0).row(0).style(:background_color => HIGHLIGHT)
|
130
|
+
column(0).row(2).style(:background_color => HIGHLIGHT)
|
131
|
+
row(1).style(:align => :center, :size => SMALL_FONT_SIZE, :padding => [0, 0, 5, 0], :borders => [])
|
132
|
+
row(3).style(:align => :center, :size => SMALL_FONT_SIZE, :padding => 0, :borders => [])
|
133
|
+
end
|
134
|
+
pdf.table [[tbl1, '', tbl2]], :column_widths => [nil, 10, nil], :cell_style => {:borders => []}
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.render_cells_09_and_10(waybill, pdf)
|
138
|
+
items = [['', '9', '', RS::TransportType::NAMES[waybill.transport_type_id], '', '10', '', waybill.car_number],
|
139
|
+
['', '', '', 'ტრანსპორტირების სახე', '', '', '', 'სატრანსპორტო საშუალების სახელმწიფო ნომერი']]
|
140
|
+
column_widths = place_table_into_center [0, NUM_CELL_WIDTH, 5, 120, 10, NUM_CELL_WIDTH, 5, 120], pdf
|
141
|
+
pdf.table items, :column_widths => column_widths, :cell_style => {:align => :center, :padding => 4} do
|
142
|
+
column(0).style(:borders => [])
|
143
|
+
column(2).style(:borders => [])
|
144
|
+
column(4).style(:borders => [])
|
145
|
+
column(6).style(:borders => [])
|
146
|
+
row(0).column(1).style(:background_color => HIGHLIGHT)
|
147
|
+
row(0).column(5).style(:background_color => HIGHLIGHT)
|
148
|
+
row(1).style(:size => SMALL_FONT_SIZE, :borders => [], :padding => 0)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.render_cells_11_and_12(waybill, pdf)
|
153
|
+
t11 = tax_code_box(pdf, 'სატრანსპორტო საშუალების მძღოლის პირადი ნომერი', '11', waybill.driver_tin, :caption_size => DEF_FONT_SIZE - 1)
|
154
|
+
t12A = pdf.make_table [['12', '', number_format(waybill.transportation_cost)], ['', '', 'თანხა ლარებში']], :column_widths => [NUM_CELL_WIDTH, 5, 100], :cell_style => {:padding => 4, :align => :center} do
|
155
|
+
column(1).style(:borders => [])
|
156
|
+
column(0).row(0).style(:background_color => HIGHLIGHT)
|
157
|
+
row(1).style(:borders => [], :size => SMALL_FONT_SIZE, :padding => 0)
|
158
|
+
end
|
159
|
+
t12 = pdf.make_table [['გამყიდველის (გამგზავნის) / მყიდველის (მიმღების) მიერ გაწეული ტრანსპორტირების ხარჯი', t12A]], :cell_style => {:borders => [], :padding => 0}, :column_widths => [150] do
|
160
|
+
column(0).style(:size => DEF_FONT_SIZE - 1)
|
161
|
+
end
|
162
|
+
pdf.table [[t11, '', t12]], :cell_style => {:borders => []}
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.render_items(waybill, from, pdf)
|
166
|
+
col_widths = [20, pdf.bounds.width - 20 - 55*5, 55, 55, 55, 55, 55]
|
167
|
+
items = [['№', 'საქონლის დასახელება', 'საქონლის კოდი', 'საქონლის ზომის ერთეული', 'საქონლის რაოდენობა', 'საქონლის ერთეულის ფასი*', 'საქონლის ფასი*'], ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII']]
|
168
|
+
pdf.table items, :column_widths => col_widths, :cell_style => {:align => :center, :valign => :center, :size => SMALLER_FONT_SIZE} do
|
169
|
+
row(1).style(:padding => 2)
|
170
|
+
end
|
171
|
+
index = from
|
172
|
+
nil_from = nil_to = nil
|
173
|
+
while true do
|
174
|
+
item = waybill.items[index]
|
175
|
+
item_table = render_item(index - from, item, col_widths, pdf)
|
176
|
+
y = pdf.y - item_table.height
|
177
|
+
if y > FOOTER_HEIGHT
|
178
|
+
item_table.draw
|
179
|
+
else
|
180
|
+
index -= 1 unless item.nil?
|
181
|
+
break
|
182
|
+
end
|
183
|
+
if item.nil?
|
184
|
+
nil_from = pdf.y - 5 if nil_from.nil?
|
185
|
+
nil_to = pdf.y - 5
|
186
|
+
else
|
187
|
+
index += 1
|
188
|
+
end
|
189
|
+
end
|
190
|
+
if nil_from and nil_from > nil_to
|
191
|
+
pdf.stroke_color('ff0000')
|
192
|
+
[[10, nil_from, pdf.bounds.width - 10, nil_from],
|
193
|
+
[10, nil_from, pdf.bounds.width - 10, nil_to],
|
194
|
+
[10, nil_to, pdf.bounds.width - 10, nil_to],
|
195
|
+
[10, nil_to, pdf.bounds.width - 10, nil_from],].each { |p| pdf.stroke_line(*p) }
|
196
|
+
pdf.stroke_color('000000')
|
197
|
+
end
|
198
|
+
index
|
199
|
+
end
|
200
|
+
|
201
|
+
def self.render_item(num, item, widths, pdf)
|
202
|
+
if item
|
203
|
+
items = [[num + 1, item.prod_name, item.bar_code, item.unit_name, number_format(item.quantity, 5), number_format(item.price), number_format(item.quantity * item.price)]]
|
204
|
+
else
|
205
|
+
items = [[' ']*7]
|
206
|
+
end
|
207
|
+
pdf.make_table items, :column_widths => widths, :cell_style => {:size => SMALLER_FONT_SIZE} do
|
208
|
+
column(0).style(:align => :right)
|
209
|
+
column(2).style(:align => :center)
|
210
|
+
column(3).style(:align => :center)
|
211
|
+
column(4).style(:align => :right)
|
212
|
+
column(5).style(:align => :right)
|
213
|
+
column(6).style(:align => :right)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def self.render_footer(waybill, pdf, from, to)
|
218
|
+
render_cell_13(waybill, pdf, from, to)
|
219
|
+
pdf.move_down 20
|
220
|
+
render_cells_14_and_15(waybill, pdf)
|
221
|
+
pdf.move_down 5
|
222
|
+
render_cells_16_and_17(waybill, pdf)
|
223
|
+
pdf.move_down 20
|
224
|
+
render_cell_18(waybill, pdf)
|
225
|
+
pdf.move_down 5
|
226
|
+
render_cell_19(waybill, pdf)
|
227
|
+
pdf.move_down 10
|
228
|
+
pdf.text '* დღგ-ს გადამხდელთათვის დღგ-ს ჩათვლით, აქციზის გადამხდელთათვის აქციზურ საქონელზე დღგ-ს და აქციზის ჩათვლით', :size => SMALLER_FONT_SIZE
|
229
|
+
end
|
230
|
+
|
231
|
+
def self.render_cell_13(waybill, pdf, from, to)
|
232
|
+
total = 0
|
233
|
+
waybill.items[from..to].each {|item| total += item.price * item.quantity }
|
234
|
+
items = [['13', '', "#{number_format total} ლარი", '', C12::KA::tokenize(total*1.0, :currency => 'ლარი', :currency_minor => 'თეთრი')]]
|
235
|
+
pdf.table items, :column_widths => [NUM_CELL_WIDTH, 5, 120, 5, pdf.bounds.width - NUM_CELL_WIDTH - 130] do
|
236
|
+
column(0).style(:background_color => HIGHLIGHT)
|
237
|
+
column(1).style(:borders => [])
|
238
|
+
column(2).style(:align => :center)
|
239
|
+
column(3).style(:borders => [])
|
240
|
+
column(4).style(:align => :center)
|
241
|
+
end
|
242
|
+
pdf.move_down 2
|
243
|
+
pdf.text 'მიწოდებული საქონლის მთლიანი თანხა (ციფრებით და სიტყვიერად)', :align => :center, :size => SMALL_FONT_SIZE
|
244
|
+
end
|
245
|
+
|
246
|
+
def self.render_cells_14_and_15(waybill, pdf)
|
247
|
+
items = [['14', '', waybill.seller_info, '', '15', '', waybill.buyer_info], ['','', 'გამყიდველი (გამგზავნი) / საქონლის ჩაბარებაზე უფლებამოსილი პირი (თანამდებობა, სახელი და გვარი)', '', '', '', 'მყიდველი (მიმღები), საქონლის ჩაბარებაზე უფლებამოსილი პირი (თანამდებობა, სახელი და გვარი)']]
|
248
|
+
w = (pdf.bounds.width - 2 * NUM_CELL_WIDTH - 20) / 2
|
249
|
+
pdf.table items, :column_widths => [NUM_CELL_WIDTH, 5, w, 10, NUM_CELL_WIDTH, 5, w], :cell_style => {:align => :center} do
|
250
|
+
row(1).style(:borders => [], :size => SMALL_FONT_SIZE, :padding => 2)
|
251
|
+
row(0).column(1).style(:borders => [])
|
252
|
+
row(0).column(3).style(:borders => [])
|
253
|
+
row(0).column(5).style(:borders => [])
|
254
|
+
row(0).column(0).style(:background_color => HIGHLIGHT)
|
255
|
+
row(0).column(4).style(:background_color => HIGHLIGHT)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
def self.render_cells_16_and_17(waybill, pdf)
|
260
|
+
items = [['', '16', '', '', '', '17', '', ''], ['', '', '', 'ხელმოწერა', '', '', '', 'ხელმოწერა']]
|
261
|
+
widths = place_table_into_center [0, NUM_CELL_WIDTH, 5, 150, 10, NUM_CELL_WIDTH, 5, 150], pdf
|
262
|
+
pdf.table items, :column_widths => widths do
|
263
|
+
column(0).style(:borders => [])
|
264
|
+
row(0).column(1).style(:background_color => HIGHLIGHT)
|
265
|
+
row(0).column(5).style(:background_color => HIGHLIGHT)
|
266
|
+
column(2).style(:borders => [])
|
267
|
+
column(4).style(:borders => [])
|
268
|
+
column(6).style(:borders => [])
|
269
|
+
row(1).style(:borders => [], :size => SMALL_FONT_SIZE, :padding => 2, :align => :center)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
def self.render_cell_18(waybill, pdf)
|
274
|
+
d = waybill.delivery_date ? C12::KA.format_date(waybill.delivery_date) : ' '
|
275
|
+
t = waybill.delivery_date ? waybill.delivery_date.strftime('%H:%M') : ' '
|
276
|
+
items = [['', '18', 'მიწოდებული საქონლის ჩაბარების', d, '', t], ['', '', '', 'თარიღი (რიცხვი, თვე, წელი)', '', 'დრო (საათი, წუთი)']]
|
277
|
+
widths = place_table_into_center [0, NUM_CELL_WIDTH, 150, 130, 5, 50], pdf
|
278
|
+
pdf.table items, :column_widths => widths do
|
279
|
+
column(0).style(:borders => [])
|
280
|
+
row(0).column(1).style(:background_color => HIGHLIGHT)
|
281
|
+
column(2).style(:borders => [])
|
282
|
+
column(4).style(:borders => [])
|
283
|
+
row(0).style(:align => :center)
|
284
|
+
row(1).style(:borders => [], :align => :center, :size => SMALL_FONT_SIZE, :padding => 2)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def self.render_cell_19(waybill, pdf)
|
289
|
+
items = [['19', '', waybill.comment], ['', '', 'შენიშვნა']]
|
290
|
+
pdf.table items, :column_widths => [NUM_CELL_WIDTH, 5, pdf.bounds.width - NUM_CELL_WIDTH - 5] do
|
291
|
+
column(0).row(0).style(:background_color => HIGHLIGHT)
|
292
|
+
column(1).row(0).style(:borders => [])
|
293
|
+
row(1).style(:borders => [], :size => SMALL_FONT_SIZE, :align => :center, :padding => 2)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
# Resize the first column so that the rest of the table to be placed in the center of the area.
|
298
|
+
def self.place_table_into_center(column_widths, pdf)
|
299
|
+
tbl_width = column_widths.inject {|sum, n| sum + n }
|
300
|
+
column_widths[0] = (pdf.bounds.width - tbl_width) / 2
|
301
|
+
column_widths
|
302
|
+
end
|
303
|
+
|
304
|
+
# Prepare table with tax code.
|
305
|
+
def self.tax_code_box(pdf, title, number, tax_code, opts = {})
|
306
|
+
# tax code table
|
307
|
+
tax_chars = empty?(tax_code) ? [' '] * 11 : tax_code.split(//)
|
308
|
+
tax_chars = tax_chars[0..11] if tax_chars.size > 11
|
309
|
+
items = [[number, ''] + tax_chars]
|
310
|
+
widths = [NUM_CELL_WIDTH, 5] + ([12] * tax_chars.size)
|
311
|
+
t1 = pdf.make_table items, :cell_style => {:padding => 4, :align => :center}, :column_widths => widths do
|
312
|
+
column(0).style({:background_color => HIGHLIGHT})
|
313
|
+
column(1).style(:borders => [])
|
314
|
+
end
|
315
|
+
# combine with caption
|
316
|
+
caption_width = opts[:caption_width] || 90
|
317
|
+
table = pdf.make_table [[title, t1]], :cell_style => {:padding => 0, :borders => []}, :column_widths => [caption_width] do
|
318
|
+
column(0).style(:valign => :center)
|
319
|
+
column(0).style(:size => opts[:caption_size]) if opts[:caption_size]
|
320
|
+
end
|
321
|
+
table
|
322
|
+
end
|
323
|
+
|
324
|
+
end
|
data/lib/rs/version.rb
CHANGED
data/lib/rs/waybill.rb
CHANGED
@@ -108,6 +108,7 @@ module RS
|
|
108
108
|
STATUS_CLOSED = 2
|
109
109
|
attr_accessor :id, :type, :status, :parent_id, :number
|
110
110
|
attr_accessor :seller_id # გამყიდველის უნიკალური კოდი
|
111
|
+
attr_accessor :seller_tin, :seller_name
|
111
112
|
attr_accessor :buyer_tin, :check_buyer_tin, :buyer_name
|
112
113
|
attr_accessor :seller_info, :buyer_info # გამყიდველის/მყიდველის თანამდებობა, სახელი და გვარი
|
113
114
|
attr_accessor :driver_tin, :check_driver_tin, :driver_name
|