polish_invoicer 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 312fe8f98e08534aee77cd955333f5ef46d71254
4
- data.tar.gz: 4b95737c8385e6443fd496367fd4a8504cd99b75
3
+ metadata.gz: ec8fe9758194499368f36ace07d8453e715f2b26
4
+ data.tar.gz: ee5146af343630569b5e12c2615272210be1d79d
5
5
  SHA512:
6
- metadata.gz: 9ec09c10060ec883d524c1504f433ec3dfcbfbfe8a46e17ef4d8e8a9fdad515e0d62582ad130539de30fe779809792d148724e246ce43d2a2158a0815baa1a5c
7
- data.tar.gz: 6d04f34ebf85cdc467f49b3541bd98baaa8fb220430c697830b507c412f2f1292f96e3d9ea4e1281458bdb4591e36ec8e416b6fefebfc02d0ee3a860965fc5fe
6
+ metadata.gz: 3d828c4af6ae2c363ba6da680a96212eafd9aae4d28ff956c14265e11eb7f19d04936bce36636fe073477d2e55e7e05a39d0f1b638fcc84b4a0c1f02f99f4113
7
+ data.tar.gz: c964efb4d34bc9bbd83f08b0063e9bba4087ad29f55972b53793775e692d3463563f0fb9ffab8e53c4329143c22f36c85ee494b8fd8620246cf322ce3a28c375
@@ -21,6 +21,7 @@ module PolishInvoicer
21
21
  :footer, # treść umieszczana w stopce faktury (string)
22
22
  :proforma, # znacznik faktury pro-forma, domyślnie: false (boolean)
23
23
  :no_vat_reason, # podstawa prawna zwolnienia z VAT (string)
24
+ :foreign_buyer, # nabywcą jest firma spoza Polski, domyślnie: false (boolean)
24
25
  ].freeze
25
26
 
26
27
  attr_accessor(*AVAILABLE_PARAMS)
@@ -84,6 +85,7 @@ module PolishInvoicer
84
85
  @payment_type = 'Przelew'
85
86
  @paid = true
86
87
  @proforma = false
88
+ @foreign_buyer = false
87
89
  end
88
90
 
89
91
  def validate!
@@ -56,6 +56,9 @@ module PolishInvoicer
56
56
  unless [true, false].include?(@invoice.proforma)
57
57
  @errors[:proforma] = 'Znacznik faktury pro-forma musi być podany jako boolean'
58
58
  end
59
+ unless [true, false].include?(@invoice.foreign_buyer)
60
+ @errors[:foreign_buyer] = 'Znacznik zagranicznego nabywcy musi być podany jako boolean'
61
+ end
59
62
  end
60
63
 
61
64
  def check_dates
@@ -1,3 +1,3 @@
1
1
  module PolishInvoicer
2
- VERSION = '0.0.6'.freeze
2
+ VERSION = '0.0.7'.freeze
3
3
  end
@@ -1,12 +1,10 @@
1
1
  module PolishInvoicer
2
2
  class Writer
3
- attr_accessor :invoice, :template_path
3
+ attr_accessor :invoice
4
4
  attr_accessor :logger, :wkhtmltopdf_path, :wkhtmltopdf_command
5
5
 
6
6
  def initialize(invoice)
7
7
  @invoice = invoice
8
- default_template_path = File.expand_path('../../../tpl/invoice.slim', __FILE__)
9
- @template_path = @invoice.template_path || default_template_path
10
8
  @logger = @invoice.logger
11
9
  @wkhtmltopdf_path = @invoice.wkhtmltopdf_path
12
10
  @wkhtmltopdf_command = @invoice.wkhtmltopdf_command
@@ -22,6 +20,13 @@ module PolishInvoicer
22
20
  @writer.save_to_pdf(path)
23
21
  end
24
22
 
23
+ def template_path
24
+ tpl = 'invoice.slim'
25
+ tpl = 'invoice-en.slim' if invoice.foreign_buyer
26
+ tpl = 'proforma.slim' if invoice.proforma
27
+ invoice.template_path || File.expand_path("../../../tpl/#{tpl}", __FILE__)
28
+ end
29
+
25
30
  private
26
31
 
27
32
  def create_writer