-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
108 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
xrechnung (0.5.0) | ||
xrechnung (0.6.0) | ||
builder (~> 3.2) | ||
|
||
GEM | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require "xrechnung/attachment" | ||
|
||
module Xrechnung | ||
class AdditionalDocumentReference | ||
include MemberContainer | ||
|
||
# @!attribute id | ||
# @return [String] | ||
member :id, type: String | ||
|
||
# @!attribute document_type | ||
# @return [String] | ||
member :document_type, type: String, optional: true | ||
|
||
# @!attribute document_description | ||
# @return [String] | ||
member :document_description, type: String, optional: true | ||
|
||
# @!attribute attachment | ||
# @return [Xrechnung::Attachment] | ||
member :attachment, type: Xrechnung::Attachment, optional: true | ||
|
||
# noinspection RubyResolve | ||
def to_xml(xml) | ||
xml.cac :AdditionalDocumentReference do | ||
xml.cbc :ID, id | ||
xml.cbc :DocumentType, document_type | ||
xml.cbc :DocumentDescription, document_description | ||
|
||
attachment&.to_xml(xml) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "base64" | ||
|
||
module Xrechnung | ||
class Attachment | ||
include MemberContainer | ||
|
||
# @!attribute mime_code | ||
# @return [String] | ||
member :mime_code, type: String | ||
|
||
# @!attribute filename | ||
# @return [String] | ||
member :filename, type: String | ||
|
||
member :payload | ||
|
||
# noinspection RubyResolve | ||
def to_xml(xml) | ||
xml.cac :Attachment do | ||
xml.cbc :EmbeddedDocumentBinaryObject, | ||
Base64.strict_encode64(payload), | ||
mimeCode: mime_code, | ||
filename: filename | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Xrechnung | ||
VERSION = "0.5.0".freeze | ||
VERSION = "0.6.0".freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def build_additional_document_reference | ||
Xrechnung::AdditionalDocumentReference.new( | ||
id: "CR44123", | ||
document_type: "Consumption report", | ||
document_description: "Lorem Ipsum", | ||
attachment: Xrechnung::Attachment.new( | ||
payload: "Hello World", | ||
mime_code: "text/plain", | ||
filename: "attachment.txt", | ||
), | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<cac:AdditionalDocumentReference> | ||
<cbc:ID>CR44123</cbc:ID> | ||
<cbc:DocumentType>Consumption report</cbc:DocumentType> | ||
<cbc:DocumentDescription>Lorem Ipsum</cbc:DocumentDescription> | ||
<cac:Attachment> | ||
<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain" filename="attachment.txt">SGVsbG8gV29ybGQ=</cbc:EmbeddedDocumentBinaryObject> | ||
</cac:Attachment> | ||
</cac:AdditionalDocumentReference> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "spec_helper" | ||
load("spec/fixtures/ruby/additional_document_reference.rb") | ||
|
||
RSpec.describe Xrechnung::AdditionalDocumentReference do | ||
it "generates xml" do | ||
expect_xml_eq_fixture(build_additional_document_reference, "additional_document_reference") | ||
end | ||
end |