-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79dfa27
commit c438e89
Showing
8 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.8 on 2016-08-10 17:02 | ||
from __future__ import unicode_literals | ||
|
||
import annoying.fields | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('order', '0006_auto_20160803_2217'), | ||
('member', '0011_client_delivery_note'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Billing', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('total_amount', models.DecimalField(decimal_places=2, max_digits=6, verbose_name='total_amount')), | ||
('billing_month', models.IntegerField()), | ||
('billing_year', models.IntegerField()), | ||
('generation_date', models.DateTimeField(auto_now=True)), | ||
('detail', annoying.fields.JSONField()), | ||
('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='member.Client')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='OrderBilling', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('billing_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='client_billing', to='billing.Billing')), | ||
('order_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='client_order', to='order.Order')), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,44 @@ | ||
from django.db import models | ||
from member.models import Client | ||
from order.models import Order | ||
from annoying.fields import JSONField | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
# Create your models here. | ||
month = { | ||
|
||
} | ||
|
||
|
||
class OrderBilling(models.Model): | ||
order_id = models.ForeignKey( | ||
"order.Order", | ||
related_name='client_order' | ||
) | ||
billing_id = models.ForeignKey( | ||
"billing.Billing", | ||
related_name='client_billing' | ||
) | ||
|
||
|
||
class Billing(models.Model): | ||
client = models.ForeignKey( | ||
"member.Client", | ||
) | ||
|
||
total_amount = models.DecimalField( | ||
verbose_name=_('total_amount'), | ||
max_digits=6, | ||
decimal_places=2 | ||
) | ||
|
||
billing_month = models.IntegerField() | ||
|
||
billing_year = models.IntegerField() | ||
|
||
generation_date = models.DateTimeField( | ||
verbose_name=None, auto_now=True | ||
) | ||
|
||
detail = JSONField() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{% extends "base.html" %} | ||
{% load i18n %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends "base_billing" %} | ||
{% load i18n %} | ||
{% load static %} | ||
|
||
{% block title %}{% trans'Billing' %}{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends "base_billing" %} | ||
{% load i18n %} | ||
{% load static %} | ||
|
||
{% block title %}{% trans'Billing' %}{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% extends "base_billing" %} | ||
{% load i18n %} | ||
{% load static %} | ||
|
||
{% block title %}{% trans'Billing' %}{% endblock %} | ||
{% block content %} | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.conf.urls import url | ||
from billing.views import BillingList, BillingCreate, delete_billing | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
urlpatterns = [ | ||
url(r'^list/', BillingList.as_view(), name="list"), | ||
url(r'^create', BillingCreate.as_view(), name="create"), | ||
url(r'^view/(?<pk>\d+)/$', BillingView.as_view(), name="view"), | ||
url(r'^delete/(?<pk>\d+)/$', BillingDelete.as_view(), name='delete'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,69 @@ | ||
from django.shortcuts import render | ||
from django.views import generic | ||
from billing.models import Billing | ||
from django.shortcuts import login_required | ||
|
||
# Create your views here. | ||
|
||
class BillingList(generic.ListView): | ||
# Display the billing list | ||
model = Billing | ||
template_name = "list.html" | ||
context_object_name = "billing" | ||
|
||
@method_decorator(login_required) | ||
def dispatch(self, *args, **kwargs): | ||
return super(BillingList, self).dispatch(*args, **kwargs) | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(BillingList, self).get_context_data(**kwargs) | ||
|
||
# Context variable | ||
context['myVariableOfContext'] = 0 | ||
|
||
return context | ||
|
||
|
||
class BillingCreate(generic.CreateView): | ||
# View to create the billing | ||
|
||
model = Billing | ||
template_name = "create.html" | ||
context_object_name = "billing" | ||
|
||
@method_decorator(login_required) | ||
def dispatch(self, *args, **kwargs): | ||
return super(BillingCreate, self).dispatch(*args, **kwargs) | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(BillingCreate, self).get_context_data(**kwargs) | ||
|
||
# Context variable | ||
context['myVariableOfContext'] = 0 | ||
|
||
return context | ||
|
||
def create_bill(client, year, month): | ||
pass | ||
|
||
|
||
class BillingView(generic.DetailView): | ||
# Display detail of billing | ||
model = Billing | ||
template_name = "view.html" | ||
context_object_name = "billing" | ||
|
||
@method_decorator(login_required) | ||
def dispatch(self, *args, **kwargs): | ||
return super(BillingView, self).dispatch(*args, **kwargs) | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(BillingView, self).get_context_data(**kwargs) | ||
|
||
# Context variable | ||
context['myVariableOfContext'] = 0 | ||
|
||
return context | ||
|
||
|
||
class BillingDelete(generic.DeleteView): | ||
pass |