Example #1
0
    # Initialise local variables for fetch loop

    total_ct = 0       # Total no. of items
    start_row = 1      # The first row in spreadsheet that contains data (starting at 0)

    # Iterate through all rows of data in input spreadsheet

    for this_row in range(start_row, wsh.nrows):

        ic = InterfaceableCommodityFromXls(wsh, this_row, curs_target_mea, er.logger)
        er.logger.info("Processing commodity %s for item %s" % (ic.commodity, ic.itemnum))

        if (ic.is_valid(curs_target_lookup, er.logger)):
            
            # Is this a UNSPSC Class Code or Commodity Code, i.e Parent or Child?
            er.logger.debug("Commodity %s has an implied parent %s" % (ic.commodity, get_unspsc_class(ic.commodity)))
            
            if (ic.commodity == get_unspsc_class(ic.commodity)):
                
                # It is a parent so process it
                er.logger.debug("Commodity %s is a UNSPSC Class Code" % (ic.commodity))
                total_ct += process_commodity(Commodity(ic.commodity, ic.parent, ic.description), curs_target_mea, er.logger)
                
            else:
                
                # It is a child with an implied parent
                er.logger.debug("Commodity %s is a UNSPSC Commodity Code" % (ic.commodity))

                if get_unspsc_class(ic.commodity) in processed_ic:
                    
                    # The implied parent has already been processed so assign the parent to the
Example #2
0
    # Initialise local variables for fetch loop

    total_ct = 0       # Total no. of items
    start_row = 1      # The first row in spreadsheet that contains data (starting at 0)

    # Iterate through all rows of data in input spreadsheet

    for this_row in range(start_row, wsh.nrows):

        ic = InterfaceableItemCommodityFromXls(wsh, this_row, curs_target_mea, er.logger)
        er.logger.info("Processing commodity %s for item %s" % (ic.commodity, ic.itemnum))

        if (ic.is_valid(curs_target_lookup, er.logger)):
            
            # Is this a UNSPSC Class Cob de or Commodity Code, i.e Parent or Child?
            er.logger.debug("Commodity %s has an implied parent %s" % (ic.commodity, get_unspsc_class(ic.commodity)))
            
            if (ic.commodity == get_unspsc_class(ic.commodity)):
                
                # The commodity supplied is a parent so process the item as a Commodity Group

                er.logger.debug("Commodity %s is a UNSPSC Class Code" % (ic.commodity))
                ic.commoditygroup = ic.commodity
                ic.commodity = None
                
            else:
                
                # The commodity supplied is a child so process the item as a Commodity Code
                # deriving its Commodity Group
                er.logger.debug("Commodity %s is a UNSPSC Commodity Code" % (ic.commodity))
                ic.commoditygroup = get_unspsc_class(ic.commodity)