Skip to content

Commit

Permalink
Add function to generate billing
Browse files Browse the repository at this point in the history
  • Loading branch information
maximeconnolly committed Aug 10, 2016
1 parent 79dfa27 commit c438e89
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 1 deletion.
40 changes: 40 additions & 0 deletions django/santropolFeast/billing/migrations/0001_initial.py
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')),
],
),
]
41 changes: 41 additions & 0 deletions django/santropolFeast/billing/models.py
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()
2 changes: 2 additions & 0 deletions django/santropolFeast/billing/templating/base_billing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% extends "base.html" %}
{% load i18n %}
5 changes: 5 additions & 0 deletions django/santropolFeast/billing/templating/create.html
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 %}
5 changes: 5 additions & 0 deletions django/santropolFeast/billing/templating/list.html
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 %}
8 changes: 8 additions & 0 deletions django/santropolFeast/billing/templating/view.html
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 %}
10 changes: 10 additions & 0 deletions django/santropolFeast/billing/urls.py
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'),
]
68 changes: 67 additions & 1 deletion django/santropolFeast/billing/views.py
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

0 comments on commit c438e89

Please sign in to comment.