Skip to content

Commit

Permalink
Last changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbdavide committed Oct 29, 2017
1 parent 409fab4 commit 9c56437
Show file tree
Hide file tree
Showing 14 changed files with 235 additions and 105 deletions.
2 changes: 2 additions & 0 deletions freeze.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Django==1.11.6
pytz==2017.2
1 change: 1 addition & 0 deletions sales/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = 'sales.apps.SalesConfig'
8 changes: 7 additions & 1 deletion sales/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

from .models import *

from django.contrib.auth.models import Group
from django.contrib.auth.models import User

admin.site.unregister(Group)
admin.site.unregister(User)
admin.site.site_header = 'Administración de Kenosis'


Expand Down Expand Up @@ -32,8 +37,9 @@ def sold_out(self, instance):
@admin.register(Register)
class RegisterAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return True
return False

search_fields = ('id',)
list_filter = ('date', 'register_type')
list_display = ('id', 'date', 'register_type', 'value', 'description',)
readonly_fields = ('client', 'description', 'register_type', 'product_name')
20 changes: 20 additions & 0 deletions sales/migrations/0011_auto_20171018_0727.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-10-18 12:27
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sales', '0010_auto_20171011_1230'),
]

operations = [
migrations.AlterField(
model_name='register',
name='date',
field=models.DateTimeField(auto_now_add=True, verbose_name='fecha'),
),
]
20 changes: 20 additions & 0 deletions sales/migrations/0012_auto_20171020_0659.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-10-20 11:59
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sales', '0011_auto_20171018_0727'),
]

operations = [
migrations.AlterField(
model_name='employee',
name='phone_number',
field=models.CharField(max_length=10, null=True, verbose_name='celular'),
),
]
20 changes: 20 additions & 0 deletions sales/migrations/0013_auto_20171020_0700.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-10-20 12:00
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sales', '0012_auto_20171020_0659'),
]

operations = [
migrations.AlterField(
model_name='employee',
name='phone_number',
field=models.CharField(blank=True, max_length=10, null=True, verbose_name='celular'),
),
]
6 changes: 4 additions & 2 deletions sales/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ class Employee(models.Model):

phone_number = models.CharField(
max_length=10,
verbose_name='celular'
verbose_name='celular',
null=True,
blank=True,
)

def __str__(self):
Expand Down Expand Up @@ -120,7 +122,7 @@ class Register(models.Model):
)

date = models.DateTimeField(
auto_now=True,
auto_now_add=True,
verbose_name='fecha',
)

Expand Down
26 changes: 26 additions & 0 deletions sales/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,30 @@

.label {
font-size: 13px;
}

@media print {
body {
/*margin: 0;*/
/*padding: 0;*/
font-size: 14px;
}
h3 {
font-size: 1rem;
font-weight: bold;
}
td {
padding-top: 0 !important;
margin-top: 0;
padding-bottom: 0 !important;
margin-bottom: 0;
}
#back {
display: none;
}
.containter {
margin: 0;
padding: 0;

}
}
16 changes: 13 additions & 3 deletions sales/static/js/listado.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@ $(document).ready(function() {
var elements = {
'row' : $('#row_base'),
'table' : $('#table'),
'credit' : $('#credit'),
'cash' : $('#cash'),
'table_expense' : $('#table_expense')
}

var buttons = {
'print' : $('#print')
}

buttons['print'].click(function(e) {
window.print()
})

$.get('/registros', function(data) {
console.log(data)
var registros = data.data

elements['cash'].text(data.today_cash)
elements['credit'].text(data.card_cash)

var ingresos = {}
var gastos = {}

Expand Down Expand Up @@ -64,9 +74,9 @@ function addRow(base, table, idx, register) {

new_row.attr('hidden', false)

children[0].textContent = idx
children[1].textContent = register.key
children[2].textContent = register.val
// children[0].textContent = idx
children[0].textContent = register.key
children[1].textContent = register.val

table.append(new_row)

Expand Down
7 changes: 6 additions & 1 deletion sales/static/js/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ $(document).ready(function() {
elements['comission'].val()
buttons['enviar'].attr('disabled', false)

}else {
}else if(comission > 100) {
alert('El porcentaje del vendedor tiene que ser menor a 100.')
elements['comission'].val('')
elements['comission'].focus()
buttons['enviar'].attr('disabled', false)
} else {
$.post('/venta/producto/', {
el_name: name,
is_card: is_card,
Expand Down
19 changes: 13 additions & 6 deletions sales/static/js/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $(document).ready(function() {

forms['register'].on('submit', function(e) {

buttons['enviar'].attr('disabled', true)
// buttons['enviar'].attr('disabled', true)

var price = to_int(elements['price']),
is_card = elements['pay_with_card'].prop('checked'),
Expand Down Expand Up @@ -50,21 +50,28 @@ $(document).ready(function() {
elements['comission'].focus()
buttons['enviar'].attr('disabled', false)

} else if(comission > 100) {
alert('El porcentaje del vendedor tiene que ser menor a 100.')
elements['comission'].val('')
elements['comission'].focus()
buttons['enviar'].attr('disabled', false)
}else {

$.post('venta/servicio', {
el_name: description,
is_card: is_card,
value: price,
owner_document: owner_document,
client_document: client_document,
percent: comission,
services: JSON.stringify([{
el_name: description,
value: price,
percent: comission,
}])
}, function(data) {

if(data.ok) {
alert('El ingreso se registro correctamente.')
initialize(elements)

elements['descripcion'].val('')
elements['price'].val('')
} else {
alert(data.msg)
}
Expand Down
38 changes: 19 additions & 19 deletions sales/templates/sales/create_service_sale.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ <h1>Venta de servicio</h1>
<input type="text" class="form-control" id="descripcion" placeholder="Descripción" required>
</div>

<div class="form-group">
<div class="row">
<div class="col">
<label for="product-price">Precio: </label>
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="text" id="price" class="form-control input-right" aria-label="Precio" placeholder="0" >
<span class="input-group-addon">.00</span>
</div>
</div>
<div class="col">
<label for="product-price">Porcentaje Vendedor: </label>
<div class="input-group">
<input type="text" id="comission" class="form-control input-right" aria-label="Porcentaje" placeholder="0" >
<span class="input-group-addon">%</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
Expand All @@ -55,25 +74,6 @@ <h1>Venta de servicio</h1>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col">
<label for="product-price">Precio: </label>
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="text" id="price" class="form-control input-right" aria-label="Precio" placeholder="0" >
<span class="input-group-addon">.00</span>
</div>
</div>
<div class="col">
<label for="product-price">Porcentaje Vendedor: </label>
<div class="input-group">
<input type="text" id="comission" class="form-control input-right" aria-label="Porcentaje" placeholder="0" >
<span class="input-group-addon">%</span>
</div>
</div>
</div>
</div>

<div class="form-group">
<div class="form-check">
Expand Down
11 changes: 8 additions & 3 deletions sales/templates/sales/lista.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Balance</title>
<link rel="stylesheet" type="text/css" href="/static/css/styles.css">
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap-reboot.min.css">
<link rel="stylesheet" type="text/css" href="/static/css/icons.css">
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap-grid.min.css">
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap-reboot.min.css">
<link rel="stylesheet" type="text/css" href="/static/css/styles.css">
</head>
<body>
<div class="container">
Expand All @@ -17,7 +17,7 @@
</div>
<div class="col">
<div class="text-right">
<a class="btn btn-primary pull-right" href="{% url 'sales:home'%}">Regresar</a>
<a id="back" class="btn btn-primary pull-right" href="{% url 'sales:home'%}">Regresar</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -52,6 +52,11 @@ <h3>Entradas Netas:</h3>
</tr>
</tbody>
</table>
<div class="text-right">
<button id="print" class="btn btn-primary pull-right">Imprimir</button>
</div>
<br>
<hr>
</div>
<script src="/static/js/jquery-3.2.1.min.js"></script>
<script src="/static/js/popper.min.js"></script>
Expand Down
Loading

0 comments on commit 9c56437

Please sign in to comment.