Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 902030f

Browse files
committed
Merge branch 'release/2.4.0'
2 parents 028d6fa + f4d6aae commit 902030f

File tree

3 files changed

+201
-2
lines changed

3 files changed

+201
-2
lines changed

src/X12/Generator.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Aonach\X12\Generator\TransactionSetHeader;
1111
use Aonach\X12\Generator\SegmentGeneratorInterface;
1212
use Aonach\X12\Generator\TransactionTrailer;
13+
use Aonach\X12\Generator\Name;
1314
use Aonach\X12\Generator\Product;
1415
use Faker\Provider\Base;
1516

@@ -24,18 +25,22 @@ class Generator
2425
* @var InterchangeHeader $isaSegment
2526
*/
2627
private $isaSegment;
28+
2729
/**
2830
* @var $gsSegment
2931
*/
3032
private $gsSegment;
33+
3134
/**
3235
* @var $stSegment
3336
*/
3437
private $stSegment;
38+
3539
/**
3640
* @var $bakSegment
3741
*/
3842
private $bakSegment;
43+
3944
/**
4045
* @var $po1Segment
4146
*/
@@ -45,15 +50,22 @@ class Generator
4550
* @var
4651
*/
4752
private $ackSegment;
53+
4854
/**
4955
* @var $seSegment
5056
*/
5157
private $seSegment;
5258

59+
/**
60+
* @var
61+
*/
62+
private $nSegment;
63+
5364
/**
5465
* @var $isaData
5566
*/
5667
private $isaData;
68+
5769
/**
5870
* @var $itemData
5971
*/
@@ -80,7 +92,6 @@ public function setExtraInformation($extraInformation): void
8092
$this->extraInformation = $extraInformation;
8193
}
8294

83-
8495
/**
8596
* Generator constructor.
8697
*/
@@ -108,6 +119,8 @@ public function generate()
108119
$this->gsSegment = new FunctionalGroupHeader();
109120
$this->stSegment = new TransactionSetHeader('855', $this->getExtraInformation()['855_data']->transaction_control_number);
110121
$this->bakSegment = new PurchaseOrderAcknowledgment($this->getExtraInformation()['acknowledgment_type'], $this->getExtraInformation()['855_data']->purchase_order_number, $this->getExtraInformation()['855_data']->date_of_issuance);
122+
// $this->nSegment = new Name($this->getExtraInformation()['855_data']->entity_identifier_code, $this->getExtraInformation()['855_data']->name, $this->getExtraInformation()['855_data']->identification_code_qualifier, $this->getExtraInformation()['855_data']->identification_code);
123+
$this->nSegment = new Name('SF', $this->getExtraInformation()['855_data']->name, '92', $this->getExtraInformation()['855_data']->identification_code);
111124

112125
foreach ($this->productsData as $product) {
113126
$this->po1Segment[] = new BaselineItemData($product);
@@ -128,6 +141,8 @@ private function __generate(){
128141
$this->getGsSegment()->build();
129142
$this->getStSegment()->build();
130143
$this->getBakSegment()->build();
144+
$this->getNSegment()->build();
145+
131146
foreach ($this->getPo1Segment() as $po1){
132147
$po1->build();
133148
}
@@ -144,6 +159,8 @@ private function __generate(){
144159
$fileContent[] = $this->getGsSegment()->__toString();
145160
$fileContent[] = $this->getStSegment()->__toString();
146161
$fileContent[] = $this->getBakSegment()->__toString();
162+
$fileContent[] = $this->getNSegment()->__toString();
163+
147164
for ($i = 0; $i < count($this->getPo1Segment()); $i++){
148165
$fileContent[] = $this->getPo1Segment()[$i]->__toString();
149166
$fileContent[] = $this->getAckSegment()[$i]->__toString();
@@ -155,6 +172,22 @@ private function __generate(){
155172

156173
}
157174

175+
/**
176+
* @return mixed
177+
*/
178+
public function getNSegment()
179+
{
180+
return $this->nSegment;
181+
}
182+
183+
/**
184+
* @param mixed $nSegment
185+
*/
186+
public function setNSegment($nSegment): void
187+
{
188+
$this->nSegment = $nSegment;
189+
}
190+
158191
/**
159192
* @return int
160193
*/

src/X12/Generator/FunctionalGroupHeader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function build()
125125
}
126126

127127
/**
128-
* @return mixed|void
128+
* @return mixed|string
129129
*/
130130
public function __toString()
131131
{

src/X12/Generator/Name.php

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?php
2+
3+
namespace Aonach\X12\Generator;
4+
5+
use Aonach\X12\Generator\SegmentGeneratorInterface;
6+
7+
8+
/**
9+
* Class Name
10+
* @package Aonach\X12\Generator
11+
*/
12+
class Name implements SegmentGeneratorInterface
13+
{
14+
15+
/**
16+
*
17+
*/
18+
const SEGMENT_CODE = 'N1';
19+
20+
/**
21+
*
22+
*/
23+
const SEGMENT_SECTIONS_NUMBER = 4;
24+
25+
26+
/**
27+
* @var
28+
*/
29+
private $entityIdentifierCode;
30+
31+
/**
32+
* @var
33+
*/
34+
private $name;
35+
36+
/**
37+
* @var
38+
*/
39+
private $identificationCodeQualifier;
40+
41+
/**
42+
* @var
43+
*/
44+
private $identificationCode;
45+
46+
/**
47+
* @var
48+
*/
49+
private $data;
50+
51+
52+
/**
53+
* Name constructor.
54+
*/
55+
public function __construct($entityIdentifierCode, $name, $identificationCodeQualifier, $identificationCode)
56+
{
57+
$this->setEntityIdentifierCode($entityIdentifierCode);
58+
$this->setName($name);
59+
$this->setIdentificationCodeQualifier($identificationCodeQualifier);
60+
$this->setIdentificationCode($identificationCode);
61+
}
62+
63+
/**
64+
* @return mixed|string
65+
*/
66+
public function __toString()
67+
{
68+
return (!is_null($this->getData())) ? implode('*', $this->getData()) : self::SEGMENT_CODE;
69+
70+
}
71+
72+
/**
73+
* @return mixed|void
74+
*/
75+
public function build()
76+
{
77+
$this->setData([
78+
self::SEGMENT_CODE,
79+
(!is_null($this->getEntityIdentifierCode())) ? $this->getEntityIdentifierCode() : '',
80+
(!is_null($this->getName())) ? $this->getName() : '',
81+
(!is_null($this->getIdentificationCodeQualifier())) ? $this->getIdentificationCodeQualifier() : '',
82+
(!is_null($this->getIdentificationCode())) ? $this->getIdentificationCode(): '',
83+
]);
84+
}
85+
86+
/**
87+
* @return mixed
88+
*/
89+
public function getEntityIdentifierCode()
90+
{
91+
return $this->entityIdentifierCode;
92+
}
93+
94+
/**
95+
* @param mixed $entityIdentifierCode
96+
*/
97+
public function setEntityIdentifierCode($entityIdentifierCode): void
98+
{
99+
$this->entityIdentifierCode = $entityIdentifierCode;
100+
}
101+
102+
/**
103+
* @return mixed
104+
*/
105+
public function getName()
106+
{
107+
return $this->name;
108+
}
109+
110+
/**
111+
* @param mixed $name
112+
*/
113+
public function setName($name): void
114+
{
115+
$this->name = $name;
116+
}
117+
118+
/**
119+
* @return mixed
120+
*/
121+
public function getIdentificationCodeQualifier()
122+
{
123+
return $this->identificationCodeQualifier;
124+
}
125+
126+
/**
127+
* @param mixed $identificationCodeQualifier
128+
*/
129+
public function setIdentificationCodeQualifier($identificationCodeQualifier): void
130+
{
131+
$this->identificationCodeQualifier = $identificationCodeQualifier;
132+
}
133+
134+
/**
135+
* @return mixed
136+
*/
137+
public function getIdentificationCode()
138+
{
139+
return $this->identificationCode;
140+
}
141+
142+
/**
143+
* @param mixed $identificationCode
144+
*/
145+
public function setIdentificationCode($identificationCode): void
146+
{
147+
$this->identificationCode = $identificationCode;
148+
}
149+
150+
/**
151+
* @return mixed
152+
*/
153+
public function getData()
154+
{
155+
return $this->data;
156+
}
157+
158+
/**
159+
* @param mixed $data
160+
*/
161+
public function setData($data): void
162+
{
163+
$this->data = $data;
164+
}
165+
166+
}

0 commit comments

Comments
 (0)