def merge_s_d(dict_line_item, string): result_s_d = function_regex.re_find_all_s_d(string) print('Found possible SKU and Description:', len(result_s_d)) for raw_sku, raw_description in result_s_d: if function_cleaner.is_description_valid(raw_description): cleaned_sku = raw_sku.strip() aLineItem = class_general.LineItem() aLineItem.merge_s_d(raw_sku, raw_description) dict_line_item[cleaned_sku] = aLineItem return dict_line_item
def merge_s_d_lt_tc(dict_line_item, string): result_s_d_lt_tc = function_regex.re_find_all_s_d_lt_tc(string) print('Found possible Line Total and Tax Code:', len(result_s_d_lt_tc)) for raw_sku, raw_description, line_total, tax_code in result_s_d_lt_tc: if function_cleaner.is_description_valid(raw_description): cleaned_sku = raw_sku.strip() if cleaned_sku in dict_line_item: dict_line_item[cleaned_sku].merge_s_d_lt_tc( raw_sku, raw_description, line_total, tax_code) else: aLineItem = class_general.LineItem() aLineItem.merge_s_d_lt_tc(raw_sku, raw_description, line_total, tax_code) dict_line_item[cleaned_sku] = aLineItem return dict_line_item
def merge_s_d_cd(dict_line_item, string): result_s_d_cd = function_regex.re_find_all_s_d_cd(string) print('Found possible Container Deposit:', len(result_s_d_cd)) for raw_sku, raw_description, container_deposit in result_s_d_cd: if function_cleaner.is_description_valid(raw_description): cleaned_sku = raw_sku.strip() if cleaned_sku in dict_line_item: dict_line_item[cleaned_sku].merge_s_d_cd( raw_sku, raw_description, container_deposit) else: aLineItem = class_general.LineItem() aLineItem.merge_s_d_cd(raw_sku, raw_description, container_deposit) dict_line_item[cleaned_sku] = aLineItem return dict_line_item
def merge_s_d_q_up(dict_line_item, string): result_s_d_q_up = function_regex.re_find_all_s_d_q_up(string) print('Found possible Quantity and Unit Price:', len(result_s_d_q_up)) for raw_sku, raw_description, raw_quantity_and_unit_price in result_s_d_q_up: if function_cleaner.is_description_valid(raw_description): cleaned_sku = raw_sku.strip() quantity, unit_price = function_cleaner.clean_quantity_and_unit_price( raw_quantity_and_unit_price) if cleaned_sku in dict_line_item: dict_line_item[cleaned_sku].merge_s_d_q_up( raw_sku, raw_description, quantity, unit_price) else: aLineItem = class_general.LineItem() aLineItem.merge_s_d_q_up(raw_sku, raw_description, quantity, unit_price) dict_line_item[cleaned_sku] = aLineItem return dict_line_item