Beispiel #1
0
 def _create_thirds_ending_entry(self, year):
     from diacamma.accounting.models import get_amount_sum, Journal, EntryAccount, EntryLineAccount, ChartsAccount, Third
     from django.db.models.aggregates import Sum
     sum40 = get_amount_sum(EntryLineAccount.objects.filter(
         account__code__startswith='401', account__year=year).aggregate(Sum('amount')))
     sum41 = get_amount_sum(EntryLineAccount.objects.filter(
         account__code__startswith='411', account__year=year).aggregate(Sum('amount')))
     sum42 = get_amount_sum(EntryLineAccount.objects.filter(
         account__code__startswith='421', account__year=year).aggregate(Sum('amount')))
     sum45 = get_amount_sum(EntryLineAccount.objects.filter(
         account__code__startswith='450', account__year=year).aggregate(Sum('amount')))
     if (abs(sum40) > 0.001) or (abs(sum41) > 0.001) or (abs(sum42) > 0.001) or (abs(sum45) > 0.001):
         end_journ = Journal.objects.get(id=5)
         end_desig = "Cloture d'exercice - Résultat"
         new_entry = EntryAccount.objects.create(
             year=year, journal=end_journ, designation=end_desig, date_value=year.end)
         for data_line in EntryLineAccount.objects.filter(account__code__regex=THIRD_MASK, account__year=year).values('account', 'third').annotate(data_sum=Sum('amount')):
             if abs(data_line['data_sum']) > 0.0001:
                 new_line = EntryLineAccount()
                 new_line.entry = new_entry
                 new_line.amount = -1 * data_line['data_sum']
                 new_line.account = ChartsAccount.objects.get(
                     id=data_line['account'])
                 if data_line['third'] is not None:
                     new_line.third = Third.objects.get(
                         id=data_line['third'])
                 new_line.save()
         new_entry.add_entry_line(sum40, '401')
         new_entry.add_entry_line(sum41, '411')
         new_entry.add_entry_line(sum42, '421')
         new_entry.add_entry_line(sum45, '450')
         new_entry.closed()
Beispiel #2
0
 def _get_profit(self, year):
     from diacamma.accounting.models import EntryLineAccount, get_amount_sum
     from django.db.models.aggregates import Sum
     from django.db.models import Q
     query = Q(account__code__startswith='110') | Q(
         account__code__startswith='119')
     query &= Q(account__year=year)
     val_profit = get_amount_sum(EntryLineAccount.objects.filter(
         query).aggregate(Sum('amount')))
     return val_profit
Beispiel #3
0
 def show(self, xfer):
     self._add_cost_savebtn(xfer)
     last_row = xfer.get_max_row() + 10
     lbl = XferCompLabelForm('sep3')
     lbl.set_location(0, last_row + 1, 6)
     lbl.set_value_center("{[hr/]}")
     xfer.add_component(lbl)
     xfer.filltab_from_model(1, last_row + 2, True, ['entrylineaccount_set'])
     grid_lines = xfer.get_components('entrylineaccount')
     grid_lines.actions = []
     if self.item.has_third:
         sum_customer = get_amount_sum(self.item.entrylineaccount_set.filter(
             account__code__regex=current_system_account().get_third_mask()).aggregate(Sum('amount')))
         if ((sum_customer < 0) and not self.item.has_cash) or ((sum_customer > 0) and self.item.has_cash):
             lbl = XferCompLabelForm('asset_warning')
             lbl.set_location(0, last_row + 3, 6)
             lbl.set_value_as_header(_("entry of accounting for an asset"))
             xfer.add_component(lbl)
     if self.item.link is not None:
         linkentries = EntryAccount.objects.filter(link=self.item.link).exclude(id=self.item.id)
         if len(linkentries) == 0:
             self.item.unlink()
         else:
             lbl = XferCompLabelForm('sep4')
             lbl.set_location(0, last_row + 4, 6)
             lbl.set_value_center("{[hr/]}")
             xfer.add_component(lbl)
             lbl = XferCompLabelForm('entrylinklab')
             lbl.set_location(1, last_row + 5, 5)
             lbl.set_value_center(_("Linked entries"))
             xfer.add_component(lbl)
             link_grid_lines = XferCompGrid('entryaccount_link')
             link_grid_lines.set_model(linkentries, fieldnames=None, xfer_custom=xfer)
             link_grid_lines.set_location(1, last_row + 6, 5)
             link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url(
                 'accounting.EntryAccount', 'OpenFromLine', xfer), unique=SELECT_SINGLE, close=CLOSE_YES, params={'field_id': 'entryaccount_link', 'journal': ''})
             xfer.add_component(link_grid_lines)
     if self.added:
         xfer.add_action(xfer.get_action(TITLE_MODIFY, "images/ok.png"), params={"SAVE": "YES"})