Skip to content

Commit

Permalink
Merge pull request #39 from Komtet/feature/correction_check_v2_change…
Browse files Browse the repository at this point in the history
…s#KK-1959

правки по чеку коррекции v2
  • Loading branch information
a1723 authored Nov 3, 2022
2 parents 69bcbcd + 8ca0d34 commit 7e81189
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
Unreleased
----------

7.1.0 (03.11.2022)
------------------
- У чека коррекции v2 убран параметр base_name
- Параметр base_number теперь является необязательным для чека коррекции v2

7.0.5 (19.10.2022)
------------------
- Добавлена потерянная запятая в __init__ в v2
Expand Down
11 changes: 5 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ komtet-kassa-python-sdk
email = '[email protected]' # E-Mail пользователя для отправки электронного чека
phone = '+79992400041' # Телефон пользователя
name = 'Иванов Иван' # Имя пользователя
inn = '516954782202' # Инн пользователя
inn = '5834041042' # Инн пользователя
check.set_client(email=email, phone=phone, name=name, inn=inn)
Expand Down Expand Up @@ -238,7 +238,7 @@ komtet-kassa-python-sdk
# intent = Intent.SELL_RETURN_CORRECTION # Коррекция возврата прихода
# intent = Intent.BUY_RETURN_CORRECTION # Коррекция возврата расхода
check = CorrectionCheck(oid, intent, sno)
check = CorrectionCheck(oid, intent)
# Установка данных компании
check.set_company(payment_address=payment_address, tax_system=tax_system)
Expand All @@ -256,14 +256,13 @@ komtet-kassa-python-sdk
# Установка данных коррекции
check.set_correction_info(correction_type,
'2017-09-28', # Дата документа коррекции в формате 'yyyy-mm-dd'
'K11', # Номер документа коррекции
'Отключение электричества' # Описание коррекции
'31.03.2022', # Дата документа коррекции в формате 'dd.mm.yyyy'
'K11', # Номер документа коррекции
)
# Создаём позицию коррекции
position = Position(name='Товар', price=10, quantity=5, total=50,
measure=measure_type, payment_method=payment_method,
measure=measure, payment_method=payment_method,
payment_object=payment_object, vat=vat_rate)
# Добавляем позицию коррекции
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='komtet_kassa_sdk',
version='7.0.5',
version='7.1.0',
license='MIT',
description='Python SDK for KOMTET Kassa',
long_description=long_description,
Expand Down
8 changes: 5 additions & 3 deletions src/komtet_kassa_sdk/v2/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def set_additional_user_props(self, name, value):
'value': value
}

def set_correction_info(self, type, base_date, base_number, base_name=''):
def set_correction_info(self, type, base_date, base_number=None):
"""
:param int type: Тип коррекции
:param str base_date: Дата документа коррекции
Expand All @@ -612,9 +612,11 @@ def set_correction_info(self, type, base_date, base_number, base_name=''):
self.__data['correction_info'] = {
'type': type,
'base_date': base_date,
'base_number': base_number,
'base_name': base_name
}

if base_number:
self.__data['correction_info']['base_number'] = base_number

return self

def set_company(self, payment_address, tax_system):
Expand Down
28 changes: 24 additions & 4 deletions tests/v2/correction_check/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def test_check(self):
check.set_client(email='[email protected]', phone='+79992410085',
name='Иванов Иван', inn='516974792202')
check.add_payment(50)
check.set_correction_info(CorrectionType.INSTRUCTION, '2017-09-28', 'K11',
'Отключение электричества')
check.set_correction_info(CorrectionType.INSTRUCTION, '2017-09-28', 'K11')
position = Position(name='Товар', price=10, quantity=5, total=50,
measure=MesureTypes.PIECE, payment_method=PaymentMethod.FULL_PAYMENT,
payment_object=PaymentObject.PRODUCT, vat=VatRate.RATE_NO)
Expand All @@ -30,8 +29,7 @@ def test_check(self):
'correction_info': {
'type': 'instruction',
'base_date': '2017-09-28',
'base_number': 'K11',
'base_name': 'Отключение электричества'
'base_number': 'K11'
},
'company': {
'payment_address': 'ул. им Дедушки на деревне д.5',
Expand Down Expand Up @@ -69,6 +67,28 @@ def test_check(self):
for key, value in check:
self.assertEqual(expected[key], value)

def test_correction_info(self):
'''
Тест информации о коррекции
'''
check = CorrectionCheck(3, Intent.SELL_CORRECTION)
check.set_correction_info(CorrectionType.SELF, '2017-09-28', 'K11')

self.assertEqual(check['correction_info']['type'], 'self')
self.assertEqual(check['correction_info']['base_date'], '2017-09-28')
self.assertEqual(check['correction_info']['base_number'], 'K11')

def test_correction_info_without_base_number(self):
'''
Тест информации о коррекции без номера документа основания для коррекции
'''
check = CorrectionCheck(3, Intent.SELL_CORRECTION)
check.set_correction_info(CorrectionType.INSTRUCTION, '2022-09-28')

self.assertEqual(check['correction_info']['type'], 'instruction')
self.assertEqual(check['correction_info']['base_date'], '2022-09-28')


def test_additional_user_props(self):
'''
Тест дополнительных параметров чека
Expand Down

0 comments on commit 7e81189

Please sign in to comment.