Exemplo n.º 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()
Exemplo n.º 2
0
 def _create_profit_entry(self, year, profit_account):
     from diacamma.accounting.models import Journal, EntryAccount, EntryLineAccount, ChartsAccount
     from django.db.models import Q
     paym_journ = Journal.objects.get(id=1)
     paym_desig = 'Affectation des bénéfices/pertes'
     new_entry = EntryAccount.objects.create(
         year=year, journal=paym_journ, designation=paym_desig, date_value=year.begin)
     query = Q(account__code__startswith='110') | Q(
         account__code__startswith='119')
     query &= Q(account__year=year)
     sum_profit = 0
     for new_line in EntryLineAccount.objects.filter(query):
         sum_profit += new_line.amount
         new_line.id = None
         new_line.entry = new_entry
         new_line.amount = -1 * new_line.amount
         new_line.save()
     new_line = EntryLineAccount()
     new_line.entry = new_entry
     new_line.amount = sum_profit
     new_line.account = ChartsAccount.objects.get(
         id=profit_account)
     new_line.save()
     new_entry.closed()
     return True
Exemplo n.º 3
0
Lucterios is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Lucterios.  If not, see <http://www.gnu.org/licenses/>.
'''

from __future__ import unicode_literals

from django.utils.translation import ugettext_lazy as _

from diacamma.accounting.models import EntryLineAccount

name = _("listing")
kind = 0
modelname = EntryLineAccount.get_long_name()
value = """210
297
5//%s//#entry.num
12//%s//#entry.date_entry
12//%s//#entry.date_value
20//%s//#entry_account
25//%s//#entry.designation
15//%s//#debit
15//%s//#credit
5//%s//#entry.link
""" % (_('numeros'), _('date entry'), _('date value'), _('account'), _('name'), _('debit'), _('credit'), _('link'))