einvoice 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +254 -94
- data/lib/einvoice.rb +0 -1
- data/lib/einvoice/connection.rb +0 -5
- data/lib/einvoice/donation_unit_list.json +879 -0
- data/lib/einvoice/result.rb +1 -1
- data/lib/einvoice/tradevan/model/issue_data.rb +1 -1
- data/lib/einvoice/tradevan/provider.rb +0 -1
- data/lib/einvoice/tradevan/validator/issue_data_validator.rb +10 -0
- data/lib/einvoice/version.rb +1 -1
- metadata +3 -15
- data/lib/einvoice/neweb/model/base.rb +0 -39
- data/lib/einvoice/neweb/model/contact.rb +0 -21
- data/lib/einvoice/neweb/model/customer_defined.rb +0 -19
- data/lib/einvoice/neweb/model/invoice.rb +0 -70
- data/lib/einvoice/neweb/model/invoice_item.rb +0 -27
- data/lib/einvoice/neweb/model/pre_invoice.rb +0 -18
- data/lib/einvoice/neweb/model/query.rb +0 -43
- data/lib/einvoice/neweb/model/seller_invoice.rb +0 -18
- data/lib/einvoice/neweb/provider.rb +0 -67
- data/lib/einvoice/neweb/result.rb +0 -32
- data/lib/einvoice/neweb/validator/invoice_item_validator.rb +0 -43
- data/lib/einvoice/neweb/validator/invoice_validator.rb +0 -54
- data/lib/faraday/request/digest_neweb.rb +0 -22
@@ -1,43 +0,0 @@
|
|
1
|
-
module Einvoice
|
2
|
-
module Neweb
|
3
|
-
module Validator
|
4
|
-
class QuantityValidator < ActiveModel::EachValidator
|
5
|
-
include Einvoice::Neweb::Validator
|
6
|
-
|
7
|
-
def validate_each(record, attribute, value)
|
8
|
-
unless valid_float?(value)
|
9
|
-
record.errors.add attribute, options[:message] || :invalid
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class UnitPriceValidator < ActiveModel::EachValidator
|
15
|
-
include Einvoice::Neweb::Validator
|
16
|
-
|
17
|
-
def validate_each(record, attribute, value)
|
18
|
-
unless valid_float?(value)
|
19
|
-
record.errors.add attribute, options[:message] || :invalid
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class AmountValidator < ActiveModel::EachValidator
|
25
|
-
include Einvoice::Neweb::Validator
|
26
|
-
|
27
|
-
def validate_each(record, attribute, value)
|
28
|
-
unless valid_float?(value)
|
29
|
-
record.errors.add attribute, options[:message] || :invalid
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def valid_float?(value)
|
35
|
-
integer, digit = value.to_s.split(".")[0..1]
|
36
|
-
float_value = value.to_f.to_s
|
37
|
-
|
38
|
-
return false if integer.nil? || digit.nil? || integer.delete("-").size > 12 || digit.try(:size) > 4
|
39
|
-
return false if integer != float_value.split(".")[0] || digit != float_value.split(".")[1]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Einvoice
|
2
|
-
module Neweb
|
3
|
-
module Validator
|
4
|
-
class BuyerNameValidator < ActiveModel::EachValidator
|
5
|
-
def validate_each(record, attribute, value)
|
6
|
-
if record.buyer_id.to_s == "0000000000" &&
|
7
|
-
value.present? && (value.ascii_only? ? value.size > 4 : value.size > 2)
|
8
|
-
record.errors.add attribute, options[:message] || :invalid
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class DonateMarkValidator < ActiveModel::EachValidator
|
14
|
-
def validate_each(record, attribute, value)
|
15
|
-
if value == "1" && record.n_p_o_b_a_n.blank?
|
16
|
-
record.errors.add attribute, options[:message] || :invalid
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class CarrierId1Validator < ActiveModel::EachValidator
|
22
|
-
def validate_each(record, attribute, value)
|
23
|
-
if (record.print_mark.to_s == "Y" && value.present?) || (record.print_mark.to_s == "N" && value.blank?)
|
24
|
-
record.errors.add attribute, options[:message] || :invalid
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class CarrierId2Validator < ActiveModel::EachValidator
|
30
|
-
def validate_each(record, attribute, value)
|
31
|
-
if (record.print_mark.to_s == "Y" && value.present?) || (record.print_mark.to_s == "N" && value.blank?)
|
32
|
-
record.errors.add attribute, options[:message] || :invalid
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
class PrintMarkValidator < ActiveModel::EachValidator
|
38
|
-
def validate_each(record, attribute, value)
|
39
|
-
if value == "Y" && (record.carrier_id1.present? || record.carrier_id2.present? || record.donate_mark == "Y")
|
40
|
-
record.errors.add attribute, options[:message] || :invalid
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class TotalAmountValidator < ActiveModel::EachValidator
|
46
|
-
def validate_each(record, attribute, value)
|
47
|
-
unless value != record.attributes.values_at("sales_amount", "free_tax_sales_amount", "zero_tax_sales_amount", "tax_amount").map(&:to_i).inject(&:+)
|
48
|
-
record.errors.add attribute, options[:message] || :invalid
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
|
3
|
-
module Faraday
|
4
|
-
class Request::DigestNeweb < Faraday::Middleware
|
5
|
-
dependency do
|
6
|
-
require 'digest' unless defined?(::Digest)
|
7
|
-
end
|
8
|
-
|
9
|
-
def initialize(app, secret)
|
10
|
-
super(app)
|
11
|
-
@secret = secret
|
12
|
-
end
|
13
|
-
|
14
|
-
def call(env)
|
15
|
-
xmldata = env[:body][:xmldata]
|
16
|
-
env[:body][:hash] = Digest::MD5.hexdigest(xmldata + @secret)
|
17
|
-
@app.call env
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
Faraday::Request.register_middleware digest_neweb: Faraday::Request::DigestNeweb
|