einvoice 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/einvoice.gemspec +1 -1
- data/lib/einvoice/tradevan/model/issue_data.rb +34 -18
- data/lib/einvoice/tradevan/validator/issue_data_validator.rb +12 -14
- data/lib/einvoice/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e67b4a1d7f59b394250f8295a9f8d6ce6cdc317889fc0da6187593e5bfbd2ce
|
4
|
+
data.tar.gz: c629f5f2ff8090e2eaf8adb9b17510846c7cd14bf11c4d5281e49cdb15ec69f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eba328d0b736a2bf1f563d7c5f67f2cb91eee0638fdbfb086b5a0f566037d0882b4e52914fef5570e148dc288a023eeb3bf9bf1331e40a64cc103427e7e8ad35
|
7
|
+
data.tar.gz: 3f8936270bb7164651fae848cdc4cafafaac67a4d63a39aed89432bb2201010d3b3f24f028b0fb533552d0592515f91f1fa15802125a2a7479f9f7550353cca4
|
data/einvoice.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
31
31
|
spec.add_development_dependency "pry"
|
32
32
|
spec.add_development_dependency "rspec"
|
33
|
-
spec.add_development_dependency "
|
33
|
+
spec.add_development_dependency "factory_bot"
|
34
34
|
spec.add_development_dependency "shoulda-matchers"
|
35
35
|
spec.add_development_dependency "vcr"
|
36
36
|
spec.add_development_dependency "webmock"
|
@@ -8,6 +8,7 @@ module Einvoice
|
|
8
8
|
:orgUn,
|
9
9
|
:type,
|
10
10
|
:saleIdentifier,
|
11
|
+
:allowanceIdentifier,
|
11
12
|
:transactionNumber,
|
12
13
|
:transactionDate,
|
13
14
|
:transactionTime,
|
@@ -20,9 +21,10 @@ module Einvoice
|
|
20
21
|
:allowanceExclusiveAmount,
|
21
22
|
:allowanceTax,
|
22
23
|
:allowancePaperReturned,
|
24
|
+
:allowanceInclusiveAmount,
|
23
25
|
:paperPrintMode,
|
24
26
|
:invoiceAlarmMode,
|
25
|
-
:
|
27
|
+
:invoicePaperReturned,
|
26
28
|
:donate,
|
27
29
|
:donationUnit,
|
28
30
|
:carrierType,
|
@@ -35,6 +37,7 @@ module Einvoice
|
|
35
37
|
:receiverAddrRoad,
|
36
38
|
:receiverEmail,
|
37
39
|
:receiverMobile,
|
40
|
+
:allowaDeclaration,
|
38
41
|
:idViewId,
|
39
42
|
:memberId,
|
40
43
|
:checkNumber,
|
@@ -54,44 +57,58 @@ module Einvoice
|
|
54
57
|
validates :companyUn, presence: true, length: { is: 8 }
|
55
58
|
validates :orgId, presence: true, length: { is: 5 }
|
56
59
|
validates :orgUn, length: { is: 8 }, allow_blank: true
|
57
|
-
validates :type, presence: true, length: { is: 1 }, inclusion: { in: %w(I R G H) }
|
58
|
-
validates :saleIdentifier, presence: true, length: { maximum: 100 }, saleIdentifier: true
|
60
|
+
validates :type, presence: true, length: { is: 1 }, inclusion: { in: %w(I R G H A) }
|
59
61
|
validates :transactionNumber, presence: true, length: { maximum: 50 }
|
60
62
|
validates :transactionDate, presence: true, length: { is: 8 }, format: { with: /\A\d{8}\Z/ }
|
61
|
-
validates :transactionTime, presence: true, length: { is: 8 }, format: { with: /\A\d{2}\:\d{2}\:\d{2}\Z/ }
|
62
|
-
validates :total, presence: true, length: { maximum: 20 }, total: true
|
63
63
|
validates :transactionSource, length: { maximum: 50 } # Public Affair Firm presence: true
|
64
64
|
validates :transactionTarget, length: { maximum: 50 } # Public Affair Firm presence: true
|
65
65
|
validates :paperPrintMode, presence: true, length: { is: 1 }, inclusion: { in: %w(0 1 2 3 4) }
|
66
66
|
validates :invoiceAlarmMode, presence: true, length: { is: 1 }, inclusion: { in: %w(0 1 2 3 4 5 6) }
|
67
|
-
validates :
|
68
|
-
validates :carrierType, presence: true, length: { is: 6 }, if: proc { self.paperPrintMode.to_i == 0 && self.donate == 'N' }
|
69
|
-
validates :buyerUn, length: { is: 8 }, allow_blank: true
|
70
|
-
validates :buyerTitle, length: { maximum: 60 }, allow_blank: true
|
67
|
+
validates :invoicePaperReturned, presence: true, length: { maximum: 1 }, inclusion: { in: %w(Y N) }, invoicePaperReturned: true, if: proc { self.type == 'A' || (self.buyerUn.blank? && self.paperPrintMode.to_i != 0) }
|
68
|
+
validates :carrierType, presence: true, length: { is: 6 }, if: proc { self.paperPrintMode.to_i == 0 && self.donate == 'N' && self.type != 'A' }
|
69
|
+
validates :buyerUn, length: { is: 8 }, allow_blank: true, unless: proc { %w(A H).include?(self.type) }
|
70
|
+
validates :buyerTitle, length: { maximum: 60 }, allow_blank: true, unless: proc { %w(A H).include?(self.type) }
|
71
71
|
validates :idViewId, allow_blank: true, length: { maximum: 10 }
|
72
72
|
validates :memberId, allow_blank: true, length: { maximum: 50 }
|
73
73
|
validates :itemList, presence: true, itemList: true
|
74
74
|
|
75
|
+
# Type I R G H
|
76
|
+
validates :saleIdentifier, presence: true, length: { maximum: 100 }, saleIdentifier: true, if: proc { %w(I R G H).include?(self.type) }
|
77
|
+
|
78
|
+
# Type A H
|
79
|
+
validates :allowanceIdentifier, presence: true, length: { maximum: 100 }, allowanceIdentifier: true, if: proc { %w(A H).include?(self.type) }
|
80
|
+
validates :allowanceExclusiveAmount, presence: true, length: { maximum: 20 }, if: proc { %w(A H).include?(self.type) }
|
81
|
+
validates :allowanceTax, presence: true, length: { maximum: 8 }, if: proc { %w(A H).include?(self.type) }
|
82
|
+
validates :allowancePaperReturned, presence: true, length: { is: 1 }, inclusion: { in: %w(Y N) }, if: proc { %w(A H).include?(self.type) }
|
83
|
+
validates :allowanceInclusiveAmount, presence: true, length: { maximum: 20 }, if: proc { %w(A H).include?(self.type) }
|
84
|
+
|
75
85
|
# Type R G H
|
76
86
|
validates :invoiceNumber, presence: true, length: { is: 10 }, if: proc { %w(R G H).include?(self.type) }
|
77
87
|
|
78
88
|
# Type H
|
79
89
|
validates :allowanceNumber, presence: true, length: { is: 16 }, allowanceNumber: true, if: proc { self.type == 'H' }
|
80
90
|
validates :allowanceDate, presence: true, length: { is: 8 }, format: { with: /\A\d{8}\Z/ }, if: proc { self.type == 'H' }
|
81
|
-
|
82
|
-
|
83
|
-
validates :
|
91
|
+
|
92
|
+
# Type A
|
93
|
+
validates :allowaDeclaration, allow_blank: true, length: { is: 6 }, format: { with: /\A\d{6}\Z/ }, if: proc { self.type == 'A' }
|
84
94
|
|
85
95
|
# Type I R G
|
96
|
+
validates :transactionTime, presence: true, length: { is: 8 }, format: { with: /\A\d{2}\:\d{2}\:\d{2}\Z/ }, if: proc { %w(I R G).include?(self.type) }
|
97
|
+
validates :total, presence: true, length: { maximum: 20 }, total: true, if: proc { %w(I R G).include?(self.type) }
|
86
98
|
validates :donate, presence: true, length: { is: 1 }, if: proc { %w(I R G).include?(self.type) && self.buyerUn.blank? && self.paperPrintMode.to_i == 0 }
|
87
99
|
validates :donationUnit, presence: true, length: { maximum: 10 }, donationUnit: true, if: proc { %w(I R G).include?(self.type) && self.donate == 'Y' }
|
88
100
|
validates :carrierId, presence: true, length: { maximum: 64 }, if: proc { %w(I R G).include?(self.type) && self.paperPrintMode.to_i == 0 && self.donate == 'N' }
|
89
101
|
validates :carrierIdHidden, presence: true, length: { maximum: 64 }, if: proc { %w(I R G).include?(self.type) && self.paperPrintMode.to_i == 0 && self.donate == 'N' }
|
90
|
-
|
91
|
-
|
92
|
-
validates :
|
93
|
-
validates :
|
94
|
-
validates :
|
102
|
+
|
103
|
+
# Type I R G A
|
104
|
+
validates :receiverName, allow_blank: true, length: { maximum: 30 }, if: proc { %w(I R G A).include?(self.type) }
|
105
|
+
validates :receiverAddrZip, allow_blank: true, length: { maximum: 5 }, if: proc { %w(I R G A).include?(self.type) }
|
106
|
+
validates :receiverAddrRoad, allow_blank: true, length: { maximum: 100 }, if: proc { %w(I R G A).include?(self.type) }
|
107
|
+
validates :receiverEmail, allow_blank: true, length: { maximum: 80 }, if: proc { %w(I R G A).include?(self.type) }
|
108
|
+
validates :receiverMobile, allow_blank: true, length: { maximum: 15 }, if: proc { %w(I R G A).include?(self.type) }
|
109
|
+
|
110
|
+
# Type I G
|
111
|
+
validates :tax, allow_blank: true, length: { maximum: 20 }, if: proc { %w(I G).include?(self.type) }
|
95
112
|
|
96
113
|
# Type G
|
97
114
|
validates :checkNumber, allow_blank: true, length: { is: 4 }, if: proc { self.type == 'G' }
|
@@ -100,7 +117,6 @@ module Einvoice
|
|
100
117
|
validates :texclusiveAmount, allow_blank: true, length: { maximum: 20 }, if: proc { self.type == 'G' }
|
101
118
|
validates :oeclusiveAmount, allow_blank: true, length: { maximum: 20 }, if: proc { self.type == 'G' }
|
102
119
|
validates :zexclusiveAmount, allow_blank: true, length: { maximum: 20 }, if: proc { self.type == 'G' }
|
103
|
-
validates :tax, allow_blank: true, length: { maximum: 20 }, if: proc { self.type == 'G' }
|
104
120
|
validates :mainRemark, allow_blank: true, length: { maximum: 300 }, if: proc { self.type == 'G' }
|
105
121
|
validates :invoiceType, allow_blank: true, length: { is: 2 }, inclusion: { in: %w(07 08) }, if: proc { self.type == 'G' }
|
106
122
|
|
@@ -9,6 +9,14 @@ module Einvoice
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
class AllowanceIdentifierValidator < ActiveModel::EachValidator
|
13
|
+
def validate_each(record, attribute, value)
|
14
|
+
unless record.allowanceIdentifier =~ Regexp.new("\\A#{record.companyUn}_#{record.orgId}_")
|
15
|
+
record.errors.add attribute, options[:message] || :invalid
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
12
20
|
class TotalValidator < ActiveModel::EachValidator
|
13
21
|
def validate_each(record, attribute, value)
|
14
22
|
unless value != record.itemList.map(&:itemTotal).map(&:to_i).inject(&:+)
|
@@ -46,30 +54,20 @@ module Einvoice
|
|
46
54
|
|
47
55
|
class ItemListValidator < ActiveModel::EachValidator
|
48
56
|
def validate_each(record, attribtue, value)
|
49
|
-
if
|
57
|
+
if record.itemList.map(&:itemTotal).map(&:blank?).reduce(&:|)
|
50
58
|
record.errors[:itemList] << options[:message] || :invalid
|
51
|
-
|
52
|
-
# none
|
53
|
-
end
|
54
|
-
|
55
|
-
if %w(I R).include?(record.type) && record.itemList.map(&:itemTotal).map(&:blank?).reduce(&:|)
|
56
|
-
record.errors[:itemList] << options[:message] || :invalid
|
57
|
-
else
|
58
|
-
# none
|
59
|
-
end
|
60
|
-
|
61
|
-
if record.type == 'I' && record.itemList.map(&:taxType).map(&:blank?).reduce(&:|)
|
59
|
+
elsif record.itemList.map(&:taxType).map(&:blank?).reduce(&:|)
|
62
60
|
record.errors[:itemList] << options[:message] || :invalid
|
63
61
|
else
|
64
62
|
# none
|
65
63
|
end
|
66
64
|
|
67
|
-
if record.type
|
65
|
+
if %w(A H).include?(record.type)
|
68
66
|
if record.itemList.map(&:invoiceNumber).map(&:blank?).reduce(&:|)
|
69
67
|
record.errors[:itemList] << options[:message] || :invalid
|
70
68
|
elsif record.itemList.map(&:invoiceDate).map(&:blank?).reduce(&:|)
|
71
69
|
record.errors[:itemList] << options[:message] || :invalid
|
72
|
-
elsif record.itemList.map(&:
|
70
|
+
elsif record.itemList.map(&:itemExclude).map(&:blank?).reduce(&:|)
|
73
71
|
record.errors[:itemList] << options[:message] || :invalid
|
74
72
|
else
|
75
73
|
# none
|
data/lib/einvoice/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: einvoice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Yun
|
@@ -151,7 +151,7 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: factory_bot
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - ">="
|