php-edifact / edifact-generator

Formatter for EDI messages
GNU Lesser General Public License v3.0
36 stars 29 forks source link

CPS segment in DESADV message #33

Closed cv-chameleon closed 4 months ago

cv-chameleon commented 7 months ago

Hi, first of all, thanks for this superb package.

I need to create a DESADV message, I think it needs to follow the D96A or D96B standard.

Apparently the message also needs a CPS segment, Consignment Packing Sequence. I'm also missing how to create PAC and PCI segments, but those are optional.

I'm new to the whole EDI thing, so bare with me if I'm missing something.. :) Thanks in advance

Hereunder an example of a message I need to be able to create.

UNA:+.? ' UNB+UNOC:3+5430002362007:14+8711577188481:14+150618:0804+20140616471273+++++’ UNH+1+DESADV:D:96A:UN:EAN008' BGM+351::9+3021471273+9' DTM+11:20210218:102' DTM+132:20210219:102' DTM+137:20210218:102' RFF+ON:2048232' DTM+171:20210218:102' RFF+ON:471273' NAD+BY+5430002362038::9' NAD+DP+5430002362038::9' NAD+SU+8714252006209::9’ CPS+2+1' PAC+1+:52+PK' PCI+33E' GIN+BJ+387118580006435421' LIN+1++4039784418349:EN' PIA+5+12254AEC22:SA' QTY+12:1' RFF+ON:2048232' LIN+2++4039784295803:EN' PIA+5+12254AEC25:SA' QTY+12:1' RFF+ON:2048232' LIN+3++4002667005646:EN' PIA+5+12254AEC29:SA' QTY+12:1' RFF+ON:2048232' CNT+2:3' UNT+26+1' UNZ+1+20150618471273'

sabas commented 7 months ago

Hi, DESADV was contributed by @viezel

As I read the class it's using a different approach to the one I used, as the composeByKeys seems assuming that all the fields need to be filled? The reasoning on the class is that you instantiate it and use the different methods to populate the segments, and then call compose() to get the final array to pass to the EDI\Encoder from my other package. So to add new segments you can create the relevant methods, in the classes involved (DESADV also uses Traits)

In the samples (https://github.com/php-edifact/edifact-generator/blob/master/SAMPLES.md) file you get some hints on how to use the package to have an edi from this

cv-chameleon commented 7 months ago

I'll give it a try, thanks!

Laurent-Lopez-mealo commented 7 months ago

@cv-chameleon did you manage to get the ":14:" added to the sender and receiver? I am trying the following line where receiver is '1234:14':

$interchange = new Generator\Interchange($sender,$receiver, null, null, $order->id);

The result is UNB+UNOC:3+4567+1234?:14+240425:0619+150'

I read that the "?" is a release character that should be added in front of ":" but should it be added for a receiver / sender? Is there a way to omit it there (the company receiving the edifact for now is asking me to remove the "?"

Laurent-Lopez-mealo commented 7 months ago

Just got told that the 14 is supposed to be the identification code qualifier for the interchange recipient and interchange sender, @sabas do you know how can I set it?

cv-chameleon commented 7 months ago

@Laurent-Lopez-mealo yes, I was able to fully customize the output to my requirements.

I created a class myself, for example App\Classes\EDI\Desadv, which extends the \EDI\Generator\Desadv.

I also created a custom Trait CustomNameAndAddress which is extending the existing vendor NameAndAddress class. My own DesAdv class is then using my CustomNameAndAddress Trait.

That way I'm able to customize all output.

`<?php

namespace App\Classes\EDI\Traits;

use EDI\Generator\Traits\NameAndAddress;

/**

sabas commented 7 months ago

@Laurent-Lopez-mealo you could try to pass it as array [$code, 14]

sabas commented 7 months ago

@cv-chameleon thanks! If you added something which conforms to the standard you can contribute it 🙂