mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-21 15:32:14 +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__())
|
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():
|
def main():
|
||||||
# import_people()
|
# import_people()
|
||||||
import_organisations()
|
# import_organisations()
|
||||||
|
import_vat_rates()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
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),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -60,3 +60,13 @@ class Organisation(models.Model, RevisionMixin):
|
|||||||
if len(self.notes) > 0:
|
if len(self.notes) > 0:
|
||||||
string += "*"
|
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
|
||||||
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
Reference in New Issue
Block a user