def get_shop_running_reference_number(order): value = Counter.get_and_increment(CounterType.ORDER_REFERENCE) prefix = "%06d" % order.shop.pk padded_value = str(value).rjust( settings.SHOOP_REFERENCE_NUMBER_LENGTH - len(prefix), "0") reference_no = "%s%s" % (prefix, padded_value) return reference_no + calc_reference_number_checksum(reference_no)
def test_counters(): for counter_id in (CounterType.ORDER_REFERENCE,): try: initial = Counter.objects.get(id=CounterType.ORDER_REFERENCE).value except ObjectDoesNotExist: initial = 0 last = None for x in range(51): last = Counter.get_and_increment(counter_id) assert last == initial + 50 assert Counter.objects.get(id=CounterType.ORDER_REFERENCE).value == initial + 51
def test_counters(): for counter_id in (CounterType.ORDER_REFERENCE, ): try: initial = Counter.objects.get(id=CounterType.ORDER_REFERENCE).value except ObjectDoesNotExist: initial = 0 last = None for x in range(51): last = Counter.get_and_increment(counter_id) assert last == initial + 50 assert Counter.objects.get( id=CounterType.ORDER_REFERENCE).value == initial + 51
def get_shop_running_reference_number(order): value = Counter.get_and_increment(CounterType.ORDER_REFERENCE) prefix = "%06d" % order.shop.pk padded_value = force_text(value).rjust(settings.SHOOP_REFERENCE_NUMBER_LENGTH - len(prefix), "0") reference_no = "%s%s" % (prefix, padded_value) return reference_no + calc_reference_number_checksum(reference_no)