mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
Some refactoring between accounting and counter
This commit is contained in:
@ -3,9 +3,6 @@ from django.contrib import admin
|
||||
from accounting.models import *
|
||||
|
||||
|
||||
admin.site.register(Customer)
|
||||
admin.site.register(ProductType)
|
||||
admin.site.register(Product)
|
||||
admin.site.register(BankAccount)
|
||||
admin.site.register(ClubAccount)
|
||||
admin.site.register(GeneralJournal)
|
||||
|
@ -2,106 +2,65 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import accounting.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0001_initial'),
|
||||
('club', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AccountingType',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
|
||||
('code', models.CharField(max_length=16, verbose_name='code')),
|
||||
('label', models.CharField(max_length=60, verbose_name='label')),
|
||||
('movement_type', models.CharField(max_length=12, verbose_name='movement type', choices=[('credit', 'Credit'), ('debit', 'Debit'), ('neutral', 'Neutral')])),
|
||||
('movement_type', models.CharField(choices=[('credit', 'Credit'), ('debit', 'Debit'), ('neutral', 'Neutral')], max_length=12, verbose_name='movement type')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='BankAccount',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
|
||||
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||
('rib', models.CharField(max_length=255, verbose_name='rib', blank=True)),
|
||||
('number', models.CharField(max_length=255, verbose_name='account number', blank=True)),
|
||||
('rib', models.CharField(blank=True, max_length=255, verbose_name='rib')),
|
||||
('number', models.CharField(blank=True, max_length=255, verbose_name='account number')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ClubAccount',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
|
||||
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||
('bank_account', models.ForeignKey(related_name='club_accounts', to='accounting.BankAccount')),
|
||||
('club', models.OneToOneField(related_name='club_accounts', to='club.Club')),
|
||||
('bank_account', models.ForeignKey(to='accounting.BankAccount', related_name='club_accounts')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Customer',
|
||||
fields=[
|
||||
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, primary_key=True, serialize=False)),
|
||||
('account_id', models.CharField(max_length=10, verbose_name='account id', unique=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'customers',
|
||||
'verbose_name': 'customer',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='GeneralJournal',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
|
||||
('start_date', models.DateField(verbose_name='start date')),
|
||||
('end_date', models.DateField(null=True, default=None, verbose_name='end date', blank=True)),
|
||||
('end_date', models.DateField(default=None, blank=True, verbose_name='end date', null=True)),
|
||||
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||
('closed', models.BooleanField(default=False, verbose_name='is closed')),
|
||||
('club_account', models.ForeignKey(related_name='journals', to='accounting.ClubAccount')),
|
||||
('closed', models.BooleanField(verbose_name='is closed', default=False)),
|
||||
('club_account', models.ForeignKey(to='accounting.ClubAccount', related_name='journals')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Operation',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
|
||||
('amount', accounting.models.CurrencyField(max_digits=12, decimal_places=2, verbose_name='amount')),
|
||||
('date', models.DateField(verbose_name='date')),
|
||||
('remark', models.TextField(max_length=255, verbose_name='remark')),
|
||||
('mode', models.CharField(max_length=255, verbose_name='payment method', choices=[('cheque', 'Chèque'), ('cash', 'Espèce'), ('transfert', 'Virement'), ('card', 'Carte banquaire')])),
|
||||
('mode', models.CharField(choices=[('cheque', 'Chèque'), ('cash', 'Espèce'), ('transfert', 'Virement'), ('card', 'Carte banquaire')], max_length=255, verbose_name='payment method')),
|
||||
('cheque_number', models.IntegerField(verbose_name='cheque number')),
|
||||
('invoice', models.FileField(null=True, upload_to='invoices', blank=True)),
|
||||
('done', models.BooleanField(default=False, verbose_name='is done')),
|
||||
('journal', models.ForeignKey(related_name='invoices', to='accounting.GeneralJournal')),
|
||||
('type', models.ForeignKey(related_name='operations', to='accounting.AccountingType')),
|
||||
('invoice', models.FileField(blank=True, upload_to='invoices', null=True)),
|
||||
('done', models.BooleanField(verbose_name='is done', default=False)),
|
||||
('journal', models.ForeignKey(to='accounting.GeneralJournal', related_name='operations')),
|
||||
('type', models.ForeignKey(to='accounting.AccountingType', related_name='operations')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Product',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||
('description', models.TextField(verbose_name='description', blank=True)),
|
||||
('code', models.CharField(max_length=10, verbose_name='code')),
|
||||
('purchase_price', accounting.models.CurrencyField(max_digits=12, decimal_places=2, verbose_name='purchase price')),
|
||||
('selling_price', accounting.models.CurrencyField(max_digits=12, decimal_places=2, verbose_name='selling price')),
|
||||
('special_selling_price', accounting.models.CurrencyField(max_digits=12, decimal_places=2, verbose_name='special selling price')),
|
||||
('icon', models.ImageField(null=True, upload_to='products', blank=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ProductType',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||
('description', models.TextField(null=True, verbose_name='description', blank=True)),
|
||||
('icon', models.ImageField(null=True, upload_to='products', blank=True)),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='product',
|
||||
name='product_type',
|
||||
field=models.ForeignKey(null=True, to='accounting.ProductType', related_name='products', blank=True),
|
||||
),
|
||||
]
|
||||
|
@ -1,19 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounting', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='operation',
|
||||
name='journal',
|
||||
field=models.ForeignKey(to='accounting.GeneralJournal', related_name='operations'),
|
||||
),
|
||||
]
|
@ -8,25 +8,18 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('club', '0001_initial'),
|
||||
('accounting', '0002_auto_20160502_0952'),
|
||||
('accounting', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='bankaccount',
|
||||
name='club',
|
||||
field=models.OneToOneField(to='club.Club', related_name='bank_accounts', default=1),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='product',
|
||||
name='club',
|
||||
field=models.OneToOneField(to='club.Club', related_name='products', default=1),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='clubaccount',
|
||||
name='club',
|
||||
field=models.OneToOneField(related_name='club_account', to='club.Club'),
|
||||
field=models.OneToOneField(to='club.Club', related_name='club_account'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='bankaccount',
|
||||
name='club',
|
||||
field=models.ForeignKey(to='club.Club', related_name='bank_accounts'),
|
||||
),
|
||||
]
|
@ -1,19 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounting', '0003_auto_20160509_0712'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='club',
|
||||
field=models.ForeignKey(related_name='products', to='club.Club'),
|
||||
),
|
||||
]
|
@ -1,19 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounting', '0004_auto_20160509_0715'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='bankaccount',
|
||||
name='club',
|
||||
field=models.ForeignKey(related_name='bank_accounts', to='club.Club'),
|
||||
),
|
||||
]
|
@ -24,65 +24,6 @@ class CurrencyField(models.DecimalField):
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
class Customer(models.Model):
|
||||
"""
|
||||
This class extends a user to make a customer. It adds some basic customers informations, such as the accound ID, and
|
||||
is used by other accounting classes as reference to the customer, rather than using User
|
||||
"""
|
||||
user = models.OneToOneField(User, primary_key=True)
|
||||
account_id = models.CharField(_('account id'), max_length=10, unique=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('customer')
|
||||
verbose_name_plural = _('customers')
|
||||
|
||||
def __str__(self):
|
||||
return self.user.username
|
||||
|
||||
class ProductType(models.Model):
|
||||
"""
|
||||
This describes a product type
|
||||
Useful only for categorizing, changes are made at the product level for now
|
||||
"""
|
||||
name = models.CharField(_('name'), max_length=30)
|
||||
description = models.TextField(_('description'), null=True, blank=True)
|
||||
icon = models.ImageField(upload_to='products', null=True, blank=True)
|
||||
|
||||
def is_owned_by(self, user):
|
||||
"""
|
||||
Method to see if that object can be edited by the given user
|
||||
"""
|
||||
if user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name']):
|
||||
return True
|
||||
return False
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Product(models.Model):
|
||||
"""
|
||||
This describes a product, with all its related informations
|
||||
"""
|
||||
name = models.CharField(_('name'), max_length=30)
|
||||
description = models.TextField(_('description'), blank=True)
|
||||
product_type = models.ForeignKey(ProductType, related_name='products', null=True, blank=True)
|
||||
code = models.CharField(_('code'), max_length=10)
|
||||
purchase_price = CurrencyField(_('purchase price'))
|
||||
selling_price = CurrencyField(_('selling price'))
|
||||
special_selling_price = CurrencyField(_('special selling price'))
|
||||
icon = models.ImageField(upload_to='products', null=True, blank=True)
|
||||
club = models.ForeignKey(Club, related_name="products")
|
||||
|
||||
def is_owned_by(self, user): # TODO do this for all models
|
||||
"""
|
||||
Method to see if that object can be edited by the given user
|
||||
"""
|
||||
if user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name']):
|
||||
return True
|
||||
return False
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class BankAccount(models.Model):
|
||||
name = models.CharField(_('name'), max_length=30)
|
||||
@ -196,6 +137,7 @@ class Operation(models.Model):
|
||||
An operation is a line in the journal, a debit or a credit
|
||||
"""
|
||||
journal = models.ForeignKey(GeneralJournal, related_name="operations", null=False)
|
||||
amount = CurrencyField(_('amount'))
|
||||
date = models.DateField(_('date'))
|
||||
remark = models.TextField(_('remark'), max_length=255)
|
||||
mode = models.CharField(_('payment method'), max_length=255, choices=settings.SITH_ACCOUNTING_PAYMENT_METHOD)
|
||||
|
Reference in New Issue
Block a user