Skip to content

Commit

Permalink
Merge pull request #10 from Napp/feature/orders_extended
Browse files Browse the repository at this point in the history
Orders extended
  • Loading branch information
sabas authored Mar 25, 2019
2 parents 4e2aba3 + f0cc56c commit daa90ba
Show file tree
Hide file tree
Showing 13 changed files with 878 additions and 88 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ _ide_helper.php
coverage
coverage.xml
phpunit.local.xml
.phpunit.result.cache
composer.lock
/tests/_output
67 changes: 65 additions & 2 deletions SAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ UNT+31+M5C5201079DE48'
UNZ+1+I5C5201079DADD'
```

```

CODECO
------
Container move report. Multiple containers per message. Each message can be for gate in or for gate out.
Expand Down Expand Up @@ -335,7 +335,7 @@ COHAOR
------
Container special handling order message

```
```php
$oInterchange = (new \EDI\Generator\Interchange('ME', 'YOU'));

$sMessageReferenceNumber = 'ROW' . str_pad(1, 11, 0, STR_PAD_LEFT);
Expand Down Expand Up @@ -490,3 +490,66 @@ CNT+16:1'
UNT+12+ROW00000000001'
UNZ+1+I5C51F7D31CFF8'
```


ORDERS
------
Purchase order.

```php
$interchange = new \EDI\Generator\Interchange('UNB-Identifier-Sender','UNB-Identifier-Receiver');
$interchange->setCharset('UNOC', '3');

$orders = new \EDI\Generator\Orders();
$orders
->setOrderNumber('AB76104')
->setContactPerson('John Doe')
->setMailAddress('[email protected]')
->setPhoneNumber('+49123456789')
->setDeliveryDate(new \DateTime())
->setDeliveryAddress(
'Name 1',
'Name 2',
'Name 3',
'Street',
'99999',
'city',
'DE'
)
->setDeliveryTerms('CAF');

// adding order items
$item = new \EDI\Generator\Orders\Item();
$item->setPosition('1', '8290123', 'EN')->setQuantity(3);
$orders->addItem($item);

$item = new \EDI\Generator\Orders\Item();
$item->setPosition('2', 'AB992233', 'EN')->setQuantity(1);
$orders->addItem($item);

$orders->compose();

$encoder = new \EDI\Encoder($interchange->addMessage($orders)->getComposed(), true);
$encoder->setUNA(":+,? '");
echo $encoder->get();
```

```
UNB+UNOC:3+UNB-Identifier-Sender+UNB-Identifier-Receiver+190325:1242+I5C98CCC536C91'
UNH+M5C98CCC536CA2+ORDERS:D:96B:UN:ITEK35'
BGM+120+AB76104+9'
DTM+2:201903251242:203'
CTA++:John Doe'
[email protected]:EM'
COM+?+49123456789:TE'
NAD+ST+::ZZZ++Name 1:Name 2:Name 3+Street+city++99999+DE'
TOD+6++CAF'
LIN+1++8290123:EN'
QTY+12:3:PCE'
LIN+2++AB992233:EN'
QTY+12:1:PCE'
UNS+S'
CNT+2+2'
UNT+15+M5C98CCC536CA2'
UNZ+1+I5C98CCC536C91'
```
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
]
},
"require": {
"sabas/edifact": "^0.4.1",
"friendsofphp/php-cs-fixer": "^2.14"
},
"require-dev": {
"phpunit/phpunit": "6.1.*"
"sabas/edifact": "^0.4.1",
"phpunit/phpunit": "~8.0",
"friendsofphp/php-cs-fixer": "^2.14"
}
}
29 changes: 29 additions & 0 deletions src/Generator/EdifactCurrency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace EDI\Generator;

/**
* Class EdifactCurrency
* @url http://www.unece.org/trade/untdid/d96b/uncl/uncl6343.htm
* @package EDI\Generator
*/
class EdifactCurrency
{
const CURRENCY_CUSTOMS_VALUATIONS = '1';
const CURRENCY_INSURANCE = '2';
const CURRENCY_HOME = '3';
const CURRENCY_INVOICING = '4';
const CURRENCY_ACCOUNT = '5';
const CURRENCY_REFERENCE = '6';
const CURRENCY_TARGET = '7';
const CURRENCY_PRICE_LIST = '8';
const CURRENCY_ORDER = '9';
const CURRENCY_PRICING = '10';
const CURRENCY_PAYMENT = '11';
const CURRENCY_QUOTATION = '12';
const CURRENCY_RECIPIENT_LOCAL = '13';
const CURRENCY_SUPPLIER = '14';
const CURRENCY_SENDER_LOCAL = '15';
const CURRENCY_TARIFF = '16';
const CURRENCY_CHARGE_CALCULATION = '17';
}
70 changes: 2 additions & 68 deletions src/Generator/Invoic.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use EDI\Generator\Invoic\Item;
use EDI\Generator\Traits\ContactPerson;
use EDI\Generator\Traits\NameAndAddress;
use EDI\Generator\traits\VatAndCurrency;

/**
* Class Invoic
Expand All @@ -13,9 +14,7 @@
*/
class Invoic extends Message
{
use
ContactPerson,
NameAndAddress;
use ContactPerson, NameAndAddress, VatAndCurrency;

const TYPE_INVOICE = '380';
const TYPE_CREDIT_NOTE = '381';
Expand All @@ -34,13 +33,7 @@ class Invoic extends Message
/** @var array */
protected $reductionOfFeesText;
/** @var array */
protected $excludingVatText;
/** @var array */
protected $invoiceDescription;
/** @var array */
protected $vatNumber;
/** @var array */
protected $currency;

/** @var array */
protected $composeKeys = [
Expand Down Expand Up @@ -229,23 +222,7 @@ public function setReductionOfFeesText($reductionOfFeesText)
return $this;
}

/**
* @return array
*/
public function getExcludingVatText()
{
return $this->excludingVatText;
}

/**
* @param string $excludingVatText
* @return Invoic
*/
public function setExcludingVatText($excludingVatText)
{
$this->excludingVatText = self::addFTXSegment($excludingVatText, 'OSI', 'ROU');
return $this;
}

/**
* @return array
Expand All @@ -265,49 +242,6 @@ public function setInvoiceDescription($invoiceDescription)
return $this;
}

/**
* @return array
*/
public function getVatNumber()
{
return $this->vatNumber;
}

/**
* @param string $vatNumber
* @return Invoic
*/
public function setVatNumber($vatNumber)
{
$this->vatNumber = self::addRFFSegment('VA', str_replace(' ', '', $vatNumber));
return $this;
}

/**
* @return array
*/
public function getCurrency()
{
return $this->currency;
}

/**
* @param string $currency
* @return Invoic
*/
public function setCurrency($currency = 'EUR')
{
$this->currency = [
'CUX',
[
'2',
$currency
]
];
return $this;
}


/**
* @return Invoic
*/
Expand Down
Loading

0 comments on commit daa90ba

Please sign in to comment.