Example #1
0
def get_client_by_inf_card(card_num):  # код клиента из инф карты
    # Catalog_ИнформационныеКарты
    catalog = f"Catalog_ИнформационныеКарты(Ref_Key=guid'{card_num}')"
    select = ''
    filt = ''
    req = request_jason_data(catalog, select, filt)
    return req['ВладелецКарты']
Example #2
0
def get_product_by_id(id):
    catalog = f"Catalog_Номенклатура(Ref_Key=guid'{id}')"
    select = ''
    filt = ''
    res = request_jason_data(catalog, select, filt)
    # print(res['Code'], res['Description'], res['DeletionMark'])
    print(res)
Example #3
0
def get_return_receipts(start_date, end_date):
    catalog = 'Document_ЧекККМ'
    select = ''
    filt = f"Date ge datetime'{start_date}' and Date le datetime'{end_date}' and " \
           f"ЧекККМПродажа_Key ne guid'00000000-0000-0000-0000-000000000000'"
    receipts_on_return = request_jason_data(catalog, select, filt)
    for a in receipts_on_return['value']:
        print(a['Number'])
Example #4
0
def opk_by_period(start_date: datetime, end_date: datetime):
    s_date = f"{start_date.year}-{('%02d' % start_date.month)}-{('%02d' % start_date.day)}T00:00:00"
    e_date = f"{end_date.year}-{('%02d' % end_date.month)}-{('%02d' % end_date.day)}T23:59:59"

    catalog = 'Document_ОплатаОтПокупателяПлатежнойКартой'
    select = 'Date, ДокументОснование, РасшифровкаПлатежа'
    filt = f"Date ge datetime'{s_date}' and Date le datetime'{e_date}' and ИТС_ОрганизацияДляПечати_Key eq guid'1aae1c91-3e2d-11df-9651-005056c00008'"
    req2 = request_jason_data(catalog, select, filt)
    return req2['value']
Example #5
0
def test1():

    catalog = f"Document_ОтчетОРозничныхПродажах"
    # select = 'Ref_Key, Number, Date, Б_Идентификатор'
    filt = "Number eq 'ААЛК0000310'"
    # filt = "Number eq 'ААЭС0009820'" Б_Идентификатор
    # filt = f"Date ge datetime'{s_date}' and Date le datetime'{e_date}' and Б_Идентификатор ne ''"
    req = request_jason_data(catalog, '', filt)
    print(req)
Example #6
0
def get_child(parent_ref_id):
    catalog = 'Catalog_Номенклатура'
    select = ''
    filt = f"Parent_Key eq guid'{parent_ref_id}'"
    req = request_jason_data(catalog, select, filt)
    print(req)
    for a in req['value']:
        if a['IsFolder']:
            list_to_work.append(a['Ref_Key'])
            print(a['Description'])
Example #7
0
def recipe_by_period(start_date: datetime, end_date: datetime):
    s_date = f"{start_date.year}-{('%02d' % start_date.month)}-{('%02d' % start_date.day)}T00:00:00"
    e_date = f"{end_date.year}-{('%02d' % end_date.month)}-{('%02d' % end_date.day)}T23:59:59"

    catalog = f"Document_ЧекККМ"
    select = 'Ref_Key, Number, Date, ЗаказОснование_Key'
    # filt = f"ЗаказОснование_Key eq guid'{req['value'][0]['Ref_Key']}'"
    filt = f"Date ge datetime'{s_date}' and Date le datetime'{e_date}' and ЗаказОснование_Key ne guid'00000000-0000-0000-0000-000000000000'"
    req = request_jason_data(catalog, select, filt)
    return req['value']
Example #8
0
def get_recipe_by_period(start_date, end_date,
                         dep_code):  # возвращаем дисконтные карты из чеков
    catalog = 'Document_ЧекККМ'
    select = ''
    filt = f"Date ge datetime'{start_date}' and Date le datetime'{end_date}' and Подразделение_Key eq guid'{dep_code}'"
    req = request_jason_data(catalog, select, filt)
    result = []
    for a in req['value']:
        if a['ДисконтнаяКарта_Key'] != '00000000-0000-0000-0000-000000000000':
            result.append(a['ДисконтнаяКарта_Key'])
    return result
Example #9
0
def orders_by_period(start_date: datetime, end_date: datetime):
    s_date = f"{start_date.year}-{('%02d' % start_date.month)}-{('%02d' % start_date.day)}T00:00:00"
    e_date = f"{end_date.year}-{('%02d' % end_date.month)}-{('%02d' % end_date.day)}T23:59:59"

    catalog = f"Document_ЗаказПокупателя"
    select = 'Ref_Key, Number, Date, Б_Идентификатор'
    filt = "Number eq 'ААЭС0009820'"
    # filt = "Number eq 'ААЭС0009820'" Б_Идентификатор
    filt = f"Date ge datetime'{s_date}' and Date le datetime'{e_date}' and Б_Идентификатор ne ''"
    req = request_jason_data(catalog, select, filt)
    return req['value']
Example #10
0
def get_last_cost(product_ref, departure_ref):

    start_date = '2020-05-01T00:00:00'
    end_date = '2020-05-11T23:59:59'
    catalog = 'AccumulationRegister_ПродажиСебестоимость_RecordType'
    select = 'Recorder_Type, Подразделение_Key, Period, Номенклатура_Key, Стоимость, Количество'
    r_filter = f"Period ge datetime'{start_date}' and Period le datetime'{end_date}' " \
               f"and Номенклатура_Key eq guid'{product_ref}' " \
               f"and Recorder_Type eq 'StandardODATA.Document_ОтчетОРозничныхПродажах' " \
               f"and Подразделение_Key eq guid'{departure_ref}'"
    # f'$orderby = {order}&' - Параметр $orderby, top не поддерживается, WTF???
    n_res = request_jason_data(catalog, select, r_filter)
    return n_res
Example #11
0
def find_from_to():  # Поиск чека на возврат?
    START_DATE = '2020-05-01T00:00:00'
    END_DATE = '2020-05-01T23:59:59'
    catalog = 'Document_ЧекККМ'
    select = ''
    filt = f"Date ge datetime'{START_DATE}' and Date le datetime'{END_DATE}' " \
       f"and ЧекККМПродажа_Key ne guid'00000000-0000-0000-0000-000000000000'"
    req = request_jason_data(catalog, select, filt)

    second_list = []
    for a in req['value']:
        catalog = f"Document_ЧекККМ(Ref_Key=guid'{a['ЧекККМПродажа_Key']}')"
        select = ''
        filt = ''
        req2 = request_jason_data(catalog, select, filt)
        str1 = a['Date']
        date1 = datetime.strptime(str1[:10], '%Y-%m-%d')
        str2 = req2['Date']
        date2 = datetime.strptime(str2[:10], '%Y-%m-%d')
        if date1 != date2:
            print(a['Number'])
        second_list.append(req2)
Example #12
0
def get_client_by_code(code):
    """
    Полезные поля: 'Description'/'НаименованиеПолное' , 'Code'
    'ДатаСоздания', 'СогласенНаРассылкуSMS', 'ДатаРождения', 'Пол', 'СогласенНаРассылкуEMAIL'
    :param code:
    :return:
    """
    catalog = f"Catalog_Контрагенты(Ref_Key=guid'{code}')"
    select = 'Code, НаименованиеПолное, ДатаСоздания'
    filt = ''
    req = request_jason_data(catalog, select, filt)

    # get_contact_reg_info(req['Ref_Key'])
    return req
Example #13
0
def cost_price_by_day(start_date, end_date):
    catalog = 'AccumulationRegister_ПродажиСебестоимость_RecordType'
    select = 'Recorder_Type, Подразделение_Key, Period, Номенклатура_Key, Стоимость, Количество'
    filt = f"Period ge datetime'{start_date}' and Period le datetime'{end_date}'"
    res = request_jason_data(catalog, select, filt)
    sorted_cost_price = {}

    for a in res['value']:
        if a['Recorder_Type'] == 'StandardODATA.Document_ОтчетОРозничныхПродажах' \
                and a['Подразделение_Key'] == '1e2039a3-da0a-11dc-b992-001bfcc2ffde':
            str = a['Period']
            date = datetime.strptime(str[:10], '%Y-%m-%d')
            if date in sorted_cost_price:
                sorted_cost_price[date].update(
                    {a['Номенклатура_Key']: a['Стоимость'] / a['Количество']})
            else:
                sorted_cost_price[date] = {
                    a['Номенклатура_Key']: a['Стоимость'] / a['Количество']
                }
    print(sorted_cost_price)
Example #14
0
def get_contact_reg_info(client_code):
    #  Использовать "ПолеПоискаПоТелефону"
    #  http://192.168.1.108/mayco/odata/standard.odata/InformationRegister_КонтактнаяИнформация
    #  (Объект='e7e66f48-cf94-11e7-a937-005056950094',
    #  Объект_Type='StandardODATA.Catalog_Контрагенты',
    #  Тип = 'Телефон',
    #  Вид=guid'968558ff-8fe0-40d0-84e3-ca694acbc839',
    #  Вид_Type='StandardODATA.Catalog_ВидыКонтактнойИнформации')
    catalog = f"InformationRegister_КонтактнаяИнформация(Объект='{client_code}', " \
              f"Объект_Type='StandardODATA.Catalog_Контрагенты', " \
              f"Тип = 'Телефон', " \
              f"Вид=guid'968558ff-8fe0-40d0-84e3-ca694acbc839', " \
              f"Вид_Type='StandardODATA.Catalog_ВидыКонтактнойИнформации')"
    select = ''
    filt = ''
    req = request_jason_data(catalog, select, filt)
    if 'Представление' in req:
        return [req['Представление'], req['ПолеПоискаПоТелефону']]
    else:
        total_list.append(client_code)
Example #15
0
def get_department_id_by_code(code):
    catalog = f"Catalog_Подразделения"
    select = ''
    filt = f"Code eq '{code}'"
    req = request_jason_data(catalog, select, filt)
    return req['value'][0]['Ref_Key']
Example #16
0
    printProgressBar(0,
                     row_count,
                     prefix='Progress:',
                     suffix='Complete',
                     length=50)

    input_file = csv.DictReader(open(file_name, encoding='utf-8-sig'),
                                delimiter=';')

    start_time = datetime.now()
    for row in input_file:
        if row['art'] is not None:
            catalog = 'Catalog_Номенклатура'
            select = f""
            filt = f"Code eq '{row['art']}'"
            res = request_jason_data(catalog, select, filt)

            if len(res['value']) > 0:
                for a in res['value']:
                    if a['ВнешнийID'] != row['id']:
                        # print(f"Wrong! {a['ВнешнийID']}")
                        catalog = f"Catalog_Номенклатура(Ref_Key=guid'{a['Ref_Key']}')"
                        select = ''
                        filt = ''
                        body = {'ВнешнийID': row['id']}
                        res = request_patch(catalog, select, filt, body)

            else:
                bad_val.update({row['art']: res})
        count += 1
        printProgressBar(count,