Ejemplo n.º 1
0
    def testean(self):
        self.assertEqual('123456789012',
                         transform.addeancheckdigit('12345678901'), 'UPC')
        self.assertEqual('2', transform.calceancheckdigit('12345678901'),
                         'UPC')
        self.assertEqual(True, transform.checkean('123456789012'), 'UPC')
        self.assertEqual(False, transform.checkean('123456789011'), 'UPC')
        self.assertEqual(False, transform.checkean('123456789013'), 'UPC')

        self.assertEqual('123456789012',
                         transform.addeancheckdigit('12345678901'), 'UPC')
        self.assertEqual('2', transform.calceancheckdigit('12345678901'),
                         'UPC')
        self.assertEqual(True, transform.checkean('123456789012'), 'UPC')
        self.assertEqual(False, transform.checkean('123456789011'), 'UPC')
        self.assertEqual(False, transform.checkean('123456789013'), 'UPC')

        self.assertEqual('12345670', transform.addeancheckdigit('1234567'),
                         'EAN8')
        self.assertEqual('0', transform.calceancheckdigit('1234567'), 'EAN8')
        self.assertEqual(True, transform.checkean('12345670'), 'EAN8')
        self.assertEqual(False, transform.checkean('12345679'), 'EAN8')
        self.assertEqual(False, transform.checkean('12345671'), 'EAN8')

        self.assertEqual('1234567890128',
                         transform.addeancheckdigit('123456789012'), 'EAN13')
        self.assertEqual('8', transform.calceancheckdigit('123456789012'),
                         'EAN13')
        self.assertEqual(True, transform.checkean('1234567890128'), 'EAN13')
        self.assertEqual(False, transform.checkean('1234567890125'), 'EAN13')
        self.assertEqual(False, transform.checkean('1234567890120'), 'EAN13')

        self.assertEqual('12345678901231',
                         transform.addeancheckdigit('1234567890123'), 'EAN14')
        self.assertEqual('1', transform.calceancheckdigit('1234567890123'),
                         'EAN14')
        self.assertEqual(True, transform.checkean('12345678901231'), 'EAN14')
        self.assertEqual(False, transform.checkean('12345678901230'), 'EAN14')
        self.assertEqual(False, transform.checkean('12345678901236'), 'EAN14')

        self.assertEqual('123456789012345675',
                         transform.addeancheckdigit('12345678901234567'),
                         'UPC')
        self.assertEqual('5', transform.calceancheckdigit('12345678901234567'),
                         'UPC')
        self.assertEqual(True, transform.checkean('123456789012345675'), 'UPC')
        self.assertEqual(False, transform.checkean('123456789012345670'),
                         'UPC')
        self.assertEqual(False, transform.checkean('123456789012345677'),
                         'UPC')
Ejemplo n.º 2
0
    def testean(self):
        self.assertEqual("123456789012",
                         transform.addeancheckdigit("12345678901"), "UPC")
        self.assertEqual("2", transform.calceancheckdigit("12345678901"),
                         "UPC")
        self.assertEqual(True, transform.checkean("123456789012"), "UPC")
        self.assertEqual(False, transform.checkean("123456789011"), "UPC")
        self.assertEqual(False, transform.checkean("123456789013"), "UPC")

        self.assertEqual("123456789012",
                         transform.addeancheckdigit("12345678901"), "UPC")
        self.assertEqual("2", transform.calceancheckdigit("12345678901"),
                         "UPC")
        self.assertEqual(True, transform.checkean("123456789012"), "UPC")
        self.assertEqual(False, transform.checkean("123456789011"), "UPC")
        self.assertEqual(False, transform.checkean("123456789013"), "UPC")

        self.assertEqual("12345670", transform.addeancheckdigit("1234567"),
                         "EAN8")
        self.assertEqual("0", transform.calceancheckdigit("1234567"), "EAN8")
        self.assertEqual(True, transform.checkean("12345670"), "EAN8")
        self.assertEqual(False, transform.checkean("12345679"), "EAN8")
        self.assertEqual(False, transform.checkean("12345671"), "EAN8")

        self.assertEqual("1234567890128",
                         transform.addeancheckdigit("123456789012"), "EAN13")
        self.assertEqual("8", transform.calceancheckdigit("123456789012"),
                         "EAN13")
        self.assertEqual(True, transform.checkean("1234567890128"), "EAN13")
        self.assertEqual(False, transform.checkean("1234567890125"), "EAN13")
        self.assertEqual(False, transform.checkean("1234567890120"), "EAN13")

        self.assertEqual("12345678901231",
                         transform.addeancheckdigit("1234567890123"), "EAN14")
        self.assertEqual("1", transform.calceancheckdigit("1234567890123"),
                         "EAN14")
        self.assertEqual(True, transform.checkean("12345678901231"), "EAN14")
        self.assertEqual(False, transform.checkean("12345678901230"), "EAN14")
        self.assertEqual(False, transform.checkean("12345678901236"), "EAN14")

        self.assertEqual("123456789012345675",
                         transform.addeancheckdigit("12345678901234567"),
                         "UPC")
        self.assertEqual("5", transform.calceancheckdigit("12345678901234567"),
                         "UPC")
        self.assertEqual(True, transform.checkean("123456789012345675"), "UPC")
        self.assertEqual(False, transform.checkean("123456789012345670"),
                         "UPC")
        self.assertEqual(False, transform.checkean("123456789012345677"),
                         "UPC")
Ejemplo n.º 3
0
    def testean(self):
        self.assertEqual('123456789012',transform.addeancheckdigit('12345678901'),'UPC')
        self.assertEqual('2',transform.calceancheckdigit('12345678901'),'UPC')
        self.assertEqual(True,transform.checkean('123456789012'),'UPC')
        self.assertEqual(False,transform.checkean('123456789011'),'UPC')
        self.assertEqual(False,transform.checkean('123456789013'),'UPC')

        self.assertEqual('123456789012',transform.addeancheckdigit('12345678901'),'UPC')
        self.assertEqual('2',transform.calceancheckdigit('12345678901'),'UPC')
        self.assertEqual(True,transform.checkean('123456789012'),'UPC')
        self.assertEqual(False,transform.checkean('123456789011'),'UPC')
        self.assertEqual(False,transform.checkean('123456789013'),'UPC')

        self.assertEqual('12345670',transform.addeancheckdigit('1234567'),'EAN8')
        self.assertEqual('0',transform.calceancheckdigit('1234567'),'EAN8')
        self.assertEqual(True,transform.checkean('12345670'),'EAN8')
        self.assertEqual(False,transform.checkean('12345679'),'EAN8')
        self.assertEqual(False,transform.checkean('12345671'),'EAN8')

        self.assertEqual('1234567890128',transform.addeancheckdigit('123456789012'),'EAN13')
        self.assertEqual('8',transform.calceancheckdigit('123456789012'),'EAN13')
        self.assertEqual(True,transform.checkean('1234567890128'),'EAN13')
        self.assertEqual(False,transform.checkean('1234567890125'),'EAN13')
        self.assertEqual(False,transform.checkean('1234567890120'),'EAN13')

        self.assertEqual('12345678901231',transform.addeancheckdigit('1234567890123'),'EAN14')
        self.assertEqual('1',transform.calceancheckdigit('1234567890123'),'EAN14')
        self.assertEqual(True,transform.checkean('12345678901231'),'EAN14')
        self.assertEqual(False,transform.checkean('12345678901230'),'EAN14')
        self.assertEqual(False,transform.checkean('12345678901236'),'EAN14')

        self.assertEqual('123456789012345675',transform.addeancheckdigit('12345678901234567'),'UPC')
        self.assertEqual('5',transform.calceancheckdigit('12345678901234567'),'UPC')
        self.assertEqual(True,transform.checkean('123456789012345675'),'UPC')
        self.assertEqual(False,transform.checkean('123456789012345670'),'UPC')
        self.assertEqual(False,transform.checkean('123456789012345677'),'UPC')
def main(inn, out):
    #~ print 'in WPLUU2pricat'
    for edidc in inn.getloop({'BOTSID': 'EDI_DC40'}):
        #~ lou = out.putloop({'BOTSID':'UNH'},{'BOTSID':'PGI'},{'BOTSID':'LIN'})
        out.put({
            'BOTSID': 'UNH',
            '0062': out.ta_info['reference'],
            'S009.0065': 'PRICAT',
            'S009.0052': 'D',
            'S009.0054': '96A',
            'S009.0051': 'UN',
            'S009.0057': 'EAN005'
        })
        out.put({'BOTSID': 'UNH'}, {
            'BOTSID': 'BGM',
            'C002.1001': '9',
            '1004': edidc.get({
                'BOTSID': 'EDI_DC40',
                'DOCNUM': None
            })
        })
        out.put({'BOTSID': 'UNH'}, {
            'BOTSID': 'DTM',
            'C507.2005': '137',
            'C507.2379': '102',
            'C507.2380': transform.strftime('%Y%m%d')
        })
        out.put({'BOTSID': 'UNH'}, {
            'BOTSID': 'NAD',
            '3035': 'BY',
            'C082.3055': '9',
            'C082.3039': inn.ta_info['frompartner']
        })
        out.put({'BOTSID': 'UNH'}, {
            'BOTSID': 'NAD',
            '3035': 'SU',
            'C082.3055': '9',
            'C082.3039': inn.ta_info['topartner']
        })
        out.put({'BOTSID': 'UNH'}, {
            'BOTSID':
            'CUX',
            'C504#1.6347':
            '2',
            'C504#1.6343':
            '8',
            'C504#1.6345':
            edidc.get({'BOTSID': 'EDI_DC40'}, {'BOTSID': 'E2WPA01'},
                      {'BOTSID': 'E2WPA04'}, {
                          'BOTSID': 'E2WPA05002',
                          'CURRENCY': None
                      })
        })
        out.put({'BOTSID': 'UNH'}, {'BOTSID': 'PGI', '5379': '2'})
        linecounter = 0
        for artikel in edidc.getloop({'BOTSID': 'EDI_DC40'},
                                     {'BOTSID': 'E2WPA01'}):
            lou = out.putloop({'BOTSID': 'UNH'}, {'BOTSID': 'PGI'},
                              {'BOTSID': 'LIN'})
            linecounter += 1
            lou.put({'BOTSID': 'LIN', '1082': linecounter})
            artikelcode = artikel.get({
                'BOTSID': 'E2WPA01',
                'HAUPTEAN': None
            })[:10]
            artikelcode = transform.addeancheckdigit('16' + artikelcode)
            lou.put({
                'BOTSID': 'LIN',
                'C212.7143': 'EN',
                'C212.7140': artikelcode
            })
            lou.put({'BOTSID': 'LIN'}, {
                'BOTSID':
                'PIA',
                '4347':
                '5',
                'C212#1.7143':
                'SA',
                'C212#1.7140':
                artikel.get({
                    'BOTSID': 'E2WPA01',
                    'ARTIKELNR': None
                })
            })
            lou.put({'BOTSID': 'LIN'}, {
                'BOTSID':
                'PIA',
                '4347':
                '1',
                'C212#1.7143':
                'GU',
                'C212#1.7140':
                artikel.get({'BOTSID': 'E2WPA01'}, {
                    'BOTSID': 'E2WPA02002',
                    'WARENGR': None
                })
            })
            lou.put({'BOTSID': 'LIN'}, {
                'BOTSID':
                'IMD',
                '7077':
                'A',
                'C273.7008#1':
                artikel.get({'BOTSID': 'E2WPA01'}, {
                    'BOTSID': 'E2WPA03',
                    'QUALARTTXT': 'LTXT',
                    'TEXT': None
                })[:35]
            })
            lou.put({'BOTSID': 'LIN'}, {
                'BOTSID':
                'DTM',
                'C507.2005':
                '157',
                'C507.2379':
                '102',
                'C507.2380':
                artikel.get({
                    'BOTSID': 'E2WPA01',
                    'AKTIVDATUM': None
                })
            })
            lou.put({'BOTSID': 'LIN'}, {
                'BOTSID':
                'PRI',
                'C509.5125':
                'NTP',
                'C509.5387':
                'SRP',
                'C509.5118':
                artikel.get({'BOTSID': 'E2WPA01'}, {
                    'BOTSID': 'E2WPA04',
                    'KONDART': 'VKP0'
                }, {
                    'BOTSID': 'E2WPA05002',
                    'KONDWERT': None
                })
            })

        out.put(
            {'BOTSID': 'UNH'}, {
                'BOTSID': 'UNT',
                '0074': out.getcount() + 1,
                '0062': out.ta_info['reference']
            }
        )  #last line (counts the segments produced in out-message, add 1 for UNT itself)