mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-16 21:12:13 +00:00
Add VAT Rates to modes, migrations and importer
This commit is contained in:
@@ -72,9 +72,27 @@ def import_organisations():
|
||||
print("Found: " + object.__unicode__())
|
||||
|
||||
|
||||
def import_vat_rates():
|
||||
cursor = setup_cursor()
|
||||
if cursor is None:
|
||||
return
|
||||
sql = """SELECT `id`, `start_date`, `start_time`, `comment`, `rate` FROM `vat_rates`"""
|
||||
cursor.execute(sql)
|
||||
for row in cursor.fetchall():
|
||||
object, created = models.VatRate.objects.get_or_create(pk=row[0], start_at=row[1] + " " + row[2],
|
||||
comment=row[3], rate=row[4])
|
||||
if created:
|
||||
print("Created: " + object.__unicode__())
|
||||
with transaction.atomic(), reversion.create_revision():
|
||||
object.save()
|
||||
else:
|
||||
print("Found: " + object.__unicode__())
|
||||
|
||||
|
||||
def main():
|
||||
# import_people()
|
||||
import_organisations()
|
||||
# import_organisations()
|
||||
import_vat_rates()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
26
RIGS/migrations/0007_vatrate.py
Normal file
26
RIGS/migrations/0007_vatrate.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import RIGS.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('RIGS', '0006_auto_20141105_1553'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='VatRate',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)),
|
||||
('start_at', models.DateTimeField()),
|
||||
('rate', models.DecimalField(max_digits=6, decimal_places=6)),
|
||||
('comment', models.CharField(max_length=255)),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model, RIGS.models.RevisionMixin),
|
||||
),
|
||||
]
|
||||
@@ -59,4 +59,14 @@ class Organisation(models.Model, RevisionMixin):
|
||||
string = self.name
|
||||
if len(self.notes) > 0:
|
||||
string += "*"
|
||||
return string
|
||||
return string
|
||||
|
||||
|
||||
@reversion.register
|
||||
class VatRate(models.Model, RevisionMixin):
|
||||
start_at = models.DateTimeField()
|
||||
rate = models.DecimalField(max_digits=6, decimal_places=6)
|
||||
comment = models.CharField(max_length=255)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.comment + " " + self.start_at + " @ " + self.rate
|
||||
Reference in New Issue
Block a user