cXML/Message/PunchOutOrder.pm

filter: Statementstmt 56.9% 33 / 58 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 68.7% 11 / 16 Podpod 100% 4 / 4 totaltotal 48.9% 48 / 98 CC 12 SCAR 34.6
CC
12
Cov
42%
to_node
90.0
_from_status
6.0
is_pending
6.0
CRAP 31.8
« cXML/Request/PunchOutSetup.pm ↑ Summary cXML/Amount.pm »
1 =encoding utf-8
2  
3 =head1 NAME
4  
5 Business::cXML::Message::PunchOutOrder - cXML punch-out order
6  
7 =head1 SYNOPSIS
8  
9 use Business::cXML;
10 my $cxml = new Business::cXML;
11 my $poom = $cxml->new_message('PunchOutOrder');
12  
13 =head1 DESCRIPTION
14  
15 Object representation of a cXML punch-out order.
16  
17 =head1 METHODS
18  
19 See L<Business::cXML::Object/COMMON METHODS>.
20  
21 =head1 PROPERTY METHODS
22  
23 See L<Business::cXML::Object/PROPERTY METHODS> for how the following operate.
24  
25 =over
26  
27 =cut
28  
29 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 package Business::cXML::Message::PunchOutOrder;
33 1 ▶use base qw(Business::cXML::Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 CXML_POOM_STATUS_PENDING => 1,
37 CXML_POOM_STATUS_FINAL => 2,
38 1 };
39  
40 1 ▶use constant NODENAME => 'PunchOutOrderMessage';
Subroutine BEGIN: called CC=1 SCAR=0.0
41 1 ▶use constant PROPERTIES => (
Subroutine BEGIN: called CC=1 SCAR=0.0
42 buyer_cookie => ' ',
43 highest_operation => 'create',
44 status => undef,
45 total => undef,
46 shipto => undef,
47 shipping => undef,
48 tax => undef,
49 items => [],
50 id => undef,
51 1 );
52 1 ▶use constant OBJ_PROPERTIES => (
Subroutine BEGIN: called CC=1 SCAR=0.0
53 total => [ 'Business::cXML::Amount', 'Total' ],
54 shipto => 'Business::cXML::ShipTo',
55 shipping => [ 'Business::cXML::Amount', 'Shipping' ],
56 tax => [ 'Business::cXML::Amount', 'Tax' ],
57 items => 'Business::cXML::ItemIn',
58 1 );
59  
60 1 ▶use Business::cXML::Amount;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 1 ▶use Business::cXML::ItemIn;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 1 ▶use Business::cXML::ShipTo;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 1 ▶use XML::LibXML::Ferry;
Subroutine BEGIN: called CC=1 SCAR=0.0
64  
65 0 ▶sub _from_status {
Subroutine _from_status: not called CC=2 SCAR=17.9
66 0 my ($self, $val) = @_;
67 0 ▶ return CXML_POOM_STATUS_FINAL if $val eq 'final';
Branch: 1 branch
BranchTrueFalseTotal
if $val eq "final" 0 0 0
68 0 return CXML_POOM_STATUS_PENDING;
69 }
70  
71 0 ▶sub from_node {
Subroutine from_node: not called CC=1 SCAR=6.9
Pod documented
72 0 my ($self, $el) = @_;
73  
74 0 $el->ferry($self, {
75 BuyerCookie => 'buyer_cookie',
76 PunchOutOrderMessageHeader => {
77 operationAllowed => 'highest_operation',
78 quoteStatus => [ 'status', \&_from_status ],
79 SourcingStatus => '__UNIMPLEMENTED',
80 Total => [ 'total', 'Business::cXML::Amount' ],
81 ShipTo => [ 'shipto', 'Business::cXML::ShipTo' ],
82 Shipping => [ 'shipping', 'Business::cXML::Amount' ],
83 Tax => [ 'tax', 'Business::cXML::Amount' ],
84 SupplierOrderInfo => {
85 orderID => 'id',
86 orderDate => '__UNIMPLEMENTED',
87 },
88 },
89 ItemIn => [ 'items', 'Business::cXML::ItemIn' ],
90 }
91 );
92 }
93  
94 0 ▶sub to_node {
Subroutine to_node: not called CC=9 SCAR=45.0
Pod documented
95 0 my ($self, $doc) = @_;
96 0 my $node = $doc->create($self->{_nodeName});
97  
98 0 $node->add('BuyerCookie', $self->{buyer_cookie});
99  
100 my $head = $node->add('PunchOutOrderMessageHeader', undef,
101 operationAllowed => $self->{highest_operation},
102 0 );
103 0 ▶ $head->{quoteStatus} = ($self->is_final ? 'final' : 'pending') if defined $self->{status};
Branch: 2 branches
BranchTrueFalseTotal
if defined $self->{"status"} 0 0 0
$self->is_final ? : 0 0 0
104  
105 # UNIMPLEMENTED: SourcingStatus
106 0 ▶ $self->total({}) unless defined $self->{total};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"total"} 0 0 0
107 0 $head->add($self->{total}->to_node($node));
108 0 ▶ $head->add($self->{shipto}->to_node($node)) if defined $self->{shipto};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"shipto"} 0 0 0
109 0 ▶ $head->add($self->{shipping}->to_node($node)) if defined $self->{shipping};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"shipping"} 0 0 0
110 0 ▶ $head->add($self->{tax}->to_node($node)) if defined $self->{tax};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"tax"} 0 0 0
111 0 ▶ $head->add('SupplierOrderInfo', undef, orderID => $self->{id}) if defined $self->{id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"id"} 0 0 0
112  
113 0 $node->add($_->to_node($node)) foreach (@{ $self->{items} });
114  
115 0 return $node;
116 }
117  
118 =item C<B<is_pending>( [I<$bool>] )>
119  
120 =item C<B<is_final>( [I<$bool>] )>
121  
122 Respectively gets or sets whether the order is in pending or final status.
123 There is no status at all by default.
124  
125 =cut
126  
127 0 ▶sub is_pending {
Subroutine is_pending: not called CC=2 SCAR=17.9
Pod documented
128 0 my ($self, $bool) = @_;
129 0 ▶ $self->{status} = CXML_POOM_STATUS_PENDING if $bool;
Branch: 1 branch
BranchTrueFalseTotal
if $bool 0 0 0
130 0 return $self->{status} == CXML_POOM_STATUS_PENDING;
131 }
132  
133 0 ▶sub is_final {
Subroutine is_final: not called CC=2 SCAR=17.9
Pod documented
134 0 my ($self, $bool) = @_;
135 0 ▶ $self->{status} = CXML_POOM_STATUS_FINAL if $bool;
Branch: 1 branch
BranchTrueFalseTotal
if $bool 0 0 0
136 0 return $self->{status} == CXML_POOM_STATUS_FINAL;
137 }
138  
139 =item C<B<buyer_cookie>>
140  
141 Mandatory, cookie from original punch-out setup request
142  
143 =item C<B<highest_operation>>
144  
145 Mandatory, highest operation that we allow on this order. One of: C<create>
146 (default), C<inspect>, C<edit>
147  
148 =item C<B<total>>
149  
150 Mandatory, L<Business::cXML::Amount> object of type C<Total>
151  
152 =item C<B<shipto>>
153  
154 Optional, L<Business::cXML::ShipTo> object
155  
156 =item C<B<shipping>>
157  
158 Optional, L<Business::cXML::Amount> object of C<Shipping> type (includes
159 tracking information)
160  
161 =item B<tax>
162  
163 Optional, L<Business::cXML::Amount> object of type C<Tax>
164  
165 =item C<B<items>[]>
166  
167 Optional, L<Business::cXML::ItemIn> objects
168  
169 =item C<B<id>>
170  
171 Optional, supplier sales order ID for this order, if one was created. The
172 buyer can later cancel the sales order by sending an C<OrderRequest> of type
173 C<delete> that refers to this ID.
174  
175 =back
176  
177 =head1 AUTHOR
178  
179 Stéphane Lavergne L<https://github.com/vphantom>
180  
181 =head1 ACKNOWLEDGEMENTS
182  
183 Graph X Design Inc. L<https://www.gxd.ca/> sponsored this project.
184  
185 =head1 COPYRIGHT & LICENSE
186  
187 Copyright (c) 2017-2018 Stéphane Lavergne L<https://github.com/vphantom>
188  
189 Permission is hereby granted, free of charge, to any person obtaining a copy
190 of this software and associated documentation files (the "Software"), to deal
191 in the Software without restriction, including without limitation the rights
192 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
193 copies of the Software, and to permit persons to whom the Software is
194 furnished to do so, subject to the following conditions:
195  
196 The above copyright notice and this permission notice shall be included in all
197 copies or substantial portions of the Software.
198  
199 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
200 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
201 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
202 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
203 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
204 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
205 SOFTWARE.
206  
207 =cut
208  
209 1 1;
210  
« cXML/Request/PunchOutSetup.pm ↑ Summary cXML/Amount.pm »