Пример #1
0
 def run_begin(self, xfer):
     if self.item.status == 0:
         EntryAccount.clear_ghost()
         nb_entry_noclose = EntryLineAccount.objects.filter(entry__journal__id=1, entry__close=False, account__year=self.item).count()
         if nb_entry_noclose > 0:
             raise LucteriosException(IMPORTANT, _("Some enties for last year report are not closed!"))
         if current_system_account().check_begin(self.item, xfer):
             self.item.status = 1
             self.item.save()
Пример #2
0
def thirdaddon_accounting(item, xfer):
    if WrapAction.is_permission(xfer.request, 'accounting.change_entryaccount'):
        try:
            entry_lines_filter = Q(entrylineaccount__third=item)
            lines_filter = xfer.getparam('lines_filter', 0)
            if lines_filter == 0:
                entry_lines_filter &= Q(year=FiscalYear.get_current())
            elif lines_filter == 1:
                entry_lines_filter &= Q(year=FiscalYear.get_current()) & Q(close=False)
            xfer.new_tab(_('entry of account'))
            lbl = XferCompLabelForm('lbl_lines_filter')
            lbl.set_value_as_name(_('Accounts filter'))
            lbl.set_location(0, 1)
            xfer.add_component(lbl)
            edt = XferCompSelect("lines_filter")
            edt.set_select([(0, _('All entries of current fiscal year')), (1, _(
                'Only no-closed entries of current fiscal year')), (2, _('All entries for all fiscal year'))])
            edt.set_value(lines_filter)
            edt.set_location(1, 1)
            edt.set_action(xfer.request, xfer.get_action(),
                           modal=FORMTYPE_REFRESH, close=CLOSE_NO)
            xfer.add_component(edt)
            entries = EntryAccount.objects.filter(entry_lines_filter)
            link_grid_lines = XferCompGrid('entryaccount')
            link_grid_lines.set_model(entries, EntryAccount.get_default_fields(), xfer)
            link_grid_lines.set_location(0, 2, 2)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'OpenFromLine', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_SINGLE, close=CLOSE_NO)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Close', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Link', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO)
            xfer.add_component(link_grid_lines)
        except LucteriosException:
            pass
Пример #3
0
 def ventilate_result(self, fiscal_year, ventilate):
     Owner.throw_not_allowed()
     self.check_account_config()
     result = fiscal_year.total_revenue - fiscal_year.total_expense
     if abs(result) > 0.001:
         total_part = PropertyLot.get_total_part()
         if total_part > 0:
             close_entry = EntryAccount(
                 year=fiscal_year,
                 designation=_("Ventilation for %s") % fiscal_year.toText,
                 journal_id=5)
             close_entry.check_date()
             close_entry.save()
             if ventilate == 0:
                 amount = 0
                 biggerowner_val = 0
                 biggerowner_line = None
                 for owner in Owner.objects.all():
                     total = owner.propertylot_set.aggregate(
                         sum=Sum('value'))
                     if ('sum' in total.keys()) and (total['sum']
                                                     is not None):
                         value = currency_round(result * total['sum'] /
                                                total_part)
                         if abs(value) > 0.0001:
                             owner_account = owner.third.get_account(
                                 fiscal_year, owner.get_third_mask(1))
                             last_line = EntryLineAccount.objects.create(
                                 account=owner_account,
                                 amount=-1 * value,
                                 entry=close_entry,
                                 third=owner.third)
                             if biggerowner_val < total['sum']:
                                 biggerowner_val = total['sum']
                                 biggerowner_line = last_line
                             amount += value
                 diff = currency_round(result - amount)
                 if abs(diff) > 0.0001:
                     biggerowner_line.amount -= diff
                     biggerowner_line.save()
             else:
                 EntryLineAccount.objects.create(account_id=ventilate,
                                                 amount=result,
                                                 entry=close_entry)
             reserve_account = ChartsAccount.get_account(
                 Params.getvalue("condominium-current-revenue-account"),
                 fiscal_year)
             EntryLineAccount.objects.create(account=reserve_account,
                                             amount=-1 * result,
                                             entry=close_entry)
             close_entry.closed()
Пример #4
0
 def ventilate_costaccounting(self, own_set, cost_accounting, type_owner,
                              initial_code):
     if type_owner == 2:
         result = currency_round(
             CallDetail.objects.filter(set=own_set).aggregate(
                 sum=Sum('price'))['sum'])
     else:
         result = cost_accounting.get_total_revenue()
     result -= cost_accounting.get_total_expense()
     if abs(result) > 0.0001:
         fiscal_year = FiscalYear.get_current()
         close_entry = EntryAccount(year=fiscal_year,
                                    designation=_("Ventilation for %s") %
                                    own_set,
                                    journal_id=5)
         close_entry.check_date()
         close_entry.save()
         amount = 0
         last_line = None
         for part in own_set.partition_set.all().order_by('value'):
             value = currency_round(result * part.get_ratio() / 100.0)
             if abs(value) > 0.0001:
                 owner_account = part.owner.third.get_account(
                     fiscal_year, part.owner.get_third_mask(type_owner))
                 last_line = EntryLineAccount.objects.create(
                     account=owner_account,
                     amount=-1 * value,
                     entry=close_entry,
                     third=part.owner.third)
                 amount += value
         if last_line is None:
             raise LucteriosException(
                 IMPORTANT,
                 _('The class load %s has no owner') % own_set)
         diff = currency_round(result - amount)
         if abs(diff) > 0.0001:
             last_line.amount -= diff
             last_line.save()
         reserve_account = ChartsAccount.get_account(
             initial_code, fiscal_year)
         EntryLineAccount.objects.create(account=reserve_account,
                                         amount=-1 * result,
                                         entry=close_entry,
                                         costaccounting=cost_accounting)
         close_entry.closed()