예제 #1
0
def payform(building, user):
    if pending_payments(building, user):
        raise Exception(_(u'Nu mai pot fi efectuate plăți până când nu se proceseaza cele în derulare'))
    order, amount = __create_order(building, user)
    logger.info('Online payment order %d for building %s on behalf of %s worth %d' % (order.id, building, user, amount))
    l = License.for_building(building)
    
    if not l.payu_available() or building.payments_service() == None:
        raise Exception(_(u'Nu a fost configurată plata pentru această clădire'))
    
    order = [
        ('MERCHANT', l.payu_merchant_id),
        ('ORDER_REF' , 'Habitam ' + str(order.id)),
        ('ORDER_DATE', timezone.now().strftime(DATE_FORMAT)),
        ('ORDER_PNAME[]', 'Intretinere pentru %s' % str(building.name)),
        ('ORDER_PCODE[]', 'Cladire ' + str(building.pk)),
        ('ORDER_PRICE[]', str(amount)),
        ('ORDER_QTY[]', str(1)),
        ('ORDER_VAT[]', str(0)),
        ('ORDER_SHIPPING', str(0)),
        ('ORDER_PRICE_TYPE[]', 'GROSS')
    ] 
    order.extend([
        ('ORDER_HASH', __sign(str(l.payu_merchant_key), order)),
        ('BACK_REF', Site.objects.get_current().domain + '/ui'),
    ])
    
    if PAYU_DEBUG:
        order.append(('TESTORDER', 'TRUE'))
   
    return order   
예제 #2
0
def operation_list(request, building_id, account_id, month=None):
    building = ApartmentGroup.objects.get(pk=building_id)
    building_accessible(request, building)
    if month == None:
        today = date.today()
        month = date(day=building.close_day, month=today.month,
                     year=today.year)
    else:
        month = datetime.strptime(month + '-%02d' % building.close_day,
                                  "%Y-%m-%d").date()
    
    l = License.for_building(building)
    l.validate_month(building, month)
    month_end = month + relativedelta(months=1) 
    
    account = Account.objects.get(pk=account_id)
    
    ops = account.operation_list(month, month_end)
    initial_penalties, final_penalties = None, None
    src_exclude = None
    
    apartment = entity_for_account(Apartment, account)
    # TODO(Stefan) there's logic put in the view, this is uncool
    if apartment != None:
        initial_penalties = apartment.penalties(month)
        final_penalties = apartment.penalties(month_end)
        src_exclude = Q(dest=apartment.building().penalties_account)
        
    service = entity_for_account(CollectingFund, account)
    if service != None:
        src_exclude = Q(doc__type='collection')
        
    initial = account.balance(month, src_exclude)
    final = account.balance(month_end, src_exclude)
    
    data = {'account': account, 'docs': ops, 'building': building,
            'initial_balance': initial, 'initial_penalties': initial_penalties,
            'final_balance': final, 'final_penalties': final_penalties,
            'month': month, 'month_end': month_end, 'service': service,
            'building': building_for_account(account)}
    return render(request, 'operation_list.html', data)
예제 #3
0
def license_allowed(admin_license, building):
    return admin_license == License.for_building(building)
예제 #4
0
def license_for_building(building):
    return License.for_building(building)
예제 #5
0
def available_list_months(building):
    l = License.for_building(building)
    return building.available_list_months(l.months_back)