Beispiel #1
0
def add_footer(message: SegmentCollection, message_data: dict):
    number_of_segments = len(message.segments)
    message.add_segment(
        Segment("UNT", str(number_of_segments),
                message_data['message_reference_number']))
    message.add_segment(
        Segment("UNZ", "1", message_data['interchangeControlReference']))
    pass
Beispiel #2
0
def add_equipment(message: SegmentCollection, equipment_data: dict):
    #Blocks, refrigerated tank
    message.add_segment(
        Segment("EQD", "BL", equipment_data['identification_number'],
                ["7", "ZZZ", "5"], None, "3", "5"))
    message.add_segment(
        Segment("MEA", "AAE", "G",
                ["KGM", equipment_data['total_gross_weight']]))  # weight
    message.add_segment(Segment("MEA", "AAE", "AAW", ["MTQ", "100"]))  # volume
Beispiel #3
0
def add_cargo_report_sender_info(message: SegmentCollection,
                                 message_data: dict):
    message.add_segment(
        Segment("DTM",
                ["137", message_data['submit_to_customs_timestamp'], "203"]))
    message.add_segment(
        Segment("RFF",
                ["SS", message_data['sellers_message_reference_number']]))
    message.add_segment(
        Segment("NAD", "MS",
                [message_data['sender_identification'], "172", "20"]))
Beispiel #4
0
def add_headers(message: SegmentCollection, message_data: dict):
    message.add_segment(
        Segment("UNB", ["UNOB", "2"], message_data['sender_identification'],
                message_data['recipient_identification'],
                [message_data['send_date'], message_data['send_time']],
                message_data['interchangeControlReference']))
    message.add_segment(
        Segment("UNH", message_data['message_reference_number'],
                ["CUSCAR", "D", "95B", "UN", "LOT10"]))
    message.add_segment(
        Segment("BGM", "85", message_data['document_reference_number'], "9"))
Beispiel #5
0
def add_details_of_transport_and_arrival(message: SegmentCollection,
                                         message_data: dict):
    message.add_segment(
        Segment("TDT", "20", message_data['conveyance_reference_number'], "1",
                None, [
                    message_data['sender_identification'], "172", "20",
                    message_data['carrier_name']
                ], None, None, [
                    message_data['means_of_transport_identification'], "103",
                    None, message_data['means_of_transport']
                ]))
    message.add_segment(
        Segment("LOC", "60", [message_data['arrival_port'], None, "139"]))
    message.add_segment(
        Segment("DTM",
                ["132", message_data['arrival_datetime_estimated'], "203"]))
    message.add_segment(
        Segment("DTM",
                ["232", message_data['arrival_datetime_scheduled'], "203"]))
Beispiel #6
0
def add_general_indicator(message: SegmentCollection, message_data: dict):
    message.add_segment(Segment("GIS", "23"))
Beispiel #7
0
def add_consigment_details(message: SegmentCollection, consignment: dict):
    #CNI+1+DOCV373MOB909999'
    message.add_segment(
        Segment("CNI", consignment['cni_sequence_number'],
                consignment['cni_document_number'] +
                "-0"))  # master bill number
    #RFF+BM:DOCV373MOB909999'
    message.add_segment(
        Segment("RFF", ["BM", consignment['cni_document_number']]))
    #CNT+7:55814:KGM'
    #CNT+8:60'
    message.add_segment(
        Segment("CNT", ["7", consignment['total_gross_weight'], "KGM"]))
    message.add_segment(Segment(
        "CNT", ["8", consignment['number_of_pieces']]))  # total pieces
    #LOC+9+CRMOB::139'
    #LOC+11+GBPME::139'
    #LOC+76+CRMOB::139'
    message.add_segment(
        Segment("LOC", "9", [consignment['departure_port'], None, "139"
                             ]))  #Place/port of loading
    message.add_segment(
        Segment("LOC", "11", [consignment['arrival_port'], None, "139"
                              ]))  # Place/port of discharge
    message.add_segment(
        Segment("LOC", "76", [consignment['departure_port'], None, "139"
                              ]))  # Original port of loading
    #GIS+23'
    message.add_segment(Segment("GIS", "23"))
    #NAD+SU+SUP1234+A PERSON, TEST ADDRESS, TOWN, POSTCODE'
    #NAD+CN+MOB00995+ANOTHER PERSON, A COMPANY, SOMEWHERE'
    #NAD+CZ+MOB00996+ANOTHER DIFFERENT PERSON, ANOTHER COMPANY, SOMEWHERE ELSE'
    message.add_segment(
        Segment("NAD", "SU", consignment['supplier']['id'],
                consignment['supplier']['name-address']))
    message.add_segment(
        Segment("NAD", "CN", consignment['consignee']['id'],
                consignment['consignee']['name-address']))  # receiver
    message.add_segment(
        Segment("NAD", "CZ", consignment['consignor']['id'],
                consignment['consignor']['name-address']))  # sender
    #GID+1+2880:UNT'
    message.add_segment(Segment("GID", "1", ["28880", "UNT"]))  # num packages
    #FTX+AAA+++FREETEXT DESC, DETAILS'
    message.add_segment(
        Segment("FTX", "AAA", None, None, specified_values["goods"]))
    #MEA+AAE+G+KGM:55814'
    message.add_segment(
        Segment("MEA", "AAE", "G", ["KGM", consignment['total_gross_weight']]))
    #SGP+EQ123456+60'
    message.add_segment(
        Segment("SGP", consignment['equipment_identification_number'],
                consignment['number_of_pieces']))
    #PCI+24+SHIP1234'
    message.add_segment(Segment("PCI", "24", consignment['shipping_marks']))
Beispiel #8
0
def test_empty_segment():
    m = SegmentCollection()
    with pytest.raises(ValueError):
        m.add_segment(Segment("", []))
Beispiel #9
0
def test_UNA_integrity2():
    m = SegmentCollection()
    initstring = ":+.? '"
    m.add_segment(Segment("UNA", initstring))
    assert m.serialize() == "UNA" + initstring
def test_empty_segment():
    m = SegmentCollection()
    m.add_segment(Segment("", []))
    assert m