Skip to content

Commit

Permalink
fix comments;
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 committed Dec 17, 2023
1 parent cbd9b81 commit 09377bf
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.14 on 2023-12-13 18:51
# Generated by Django 3.1.14 on 2023-12-17 06:11

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -12,48 +12,10 @@ class Migration(migrations.Migration):
]

operations = [
migrations.CreateModel(
name='InvoiceLineItem',
fields=[
('id', models.UUIDField(editable=False, help_text='Unique identifier for the line item.', primary_key=True, serialize=False, unique=True)),
('expense_date', models.DateField(help_text='Date of the expense for this line item.')),
('description', models.CharField(help_text='Description of the product or service.', max_length=255)),
('quantity', models.PositiveIntegerField(help_text='Quantity of the product or service.')),
('unit_price', models.DecimalField(decimal_places=2, help_text='Unit price of the product or service.', max_digits=10)),
('non_taxable_unit_price', models.DecimalField(decimal_places=2, help_text='Non-taxable unit price.', max_digits=10)),
('tax_percentage', models.DecimalField(decimal_places=2, help_text='Tax percentage applied.', max_digits=5)),
('tax_amount', models.DecimalField(decimal_places=2, help_text='Total tax amount for this line item.', max_digits=10)),
('tax_regime', models.CharField(help_text='Tax regime for this line item.', max_length=20)),
('total_amount', models.DecimalField(decimal_places=2, help_text='Total amount including taxes.', max_digits=10)),
('trip_id', models.PositiveIntegerField(help_text='ID of the trip associated with this line item.')),
('trip_name', models.CharField(help_text='Name of the trip associated with this line item.', max_length=255)),
('service', models.CharField(help_text='Type of service (e.g., PREMIUM).', max_length=50)),
('booker_name', models.CharField(help_text='Name of the person who booked the service.', max_length=100)),
('booker_email', models.EmailField(help_text='Email address of the person who booked the service.', max_length=254)),
('cost_center', models.CharField(help_text='Cost center associated with this line item.', max_length=20)),
('credit_card_last_4_digits', models.CharField(help_text='Last 4 digits of the credit card used for payment.', max_length=4)),
],
options={
'db_table': 'invoice_line_items',
},
),
migrations.CreateModel(
name='TravelperkCredential',
fields=[
('id', models.AutoField(help_text='Unique Id to indentify a Credentials', primary_key=True, serialize=False)),
('refresh_token', models.CharField(help_text='Travelperk Refresh Token', max_length=255, null=True)),
('created_at', models.DateTimeField(auto_now_add=True, help_text='Created at datetime')),
('updated_at', models.DateTimeField(auto_now=True, help_text='Updated at datetime')),
('org', models.OneToOneField(help_text='Reference to Org table', on_delete=django.db.models.deletion.PROTECT, to='orgs.org')),
],
options={
'db_table': 'travelperk_credentials',
},
),
migrations.CreateModel(
name='Invoice',
fields=[
('id', models.UUIDField(editable=False, help_text='Unique identifier for the invoice.', primary_key=True, serialize=False, unique=True)),
('id', models.AutoField(help_text='Unique identifier for the invoice.', primary_key=True, serialize=False)),
('billing_information', models.JSONField(help_text='Billing information associated with the invoice.')),
('billing_period', models.CharField(help_text='Billing period type (e.g., instant).', max_length=20)),
('currency', models.CharField(help_text='Currency code (e.g., GBP).', max_length=3)),
Expand All @@ -63,7 +25,7 @@ class Migration(migrations.Migration):
('issuing_date', models.DateField(help_text='Date when the invoice was issued.')),
('mode', models.CharField(choices=[('reseller', 'Reseller'), ('direct', 'Direct')], help_text='Mode of the invoice, indicating whether it is a reseller or direct invoice.', max_length=20)),
('pdf', models.URLField(help_text='URL to the PDF version of the invoice.')),
('profile_id', models.UUIDField(help_text='ID of the profile associated with the invoice.')),
('profile_id', models.CharField(help_text='ID of the profile associated with the invoice.', max_length=255)),
('profile_name', models.CharField(help_text='Name of the profile associated with the invoice.', max_length=255)),
('reference', models.CharField(help_text='Reference information for the invoice (e.g., Trip #9876543).', max_length=50)),
('serial_number', models.CharField(help_text='Serial number of the invoice.', max_length=20)),
Expand All @@ -72,10 +34,48 @@ class Migration(migrations.Migration):
('total', models.DecimalField(decimal_places=2, help_text='Total amount of the invoice.', max_digits=10)),
('travelperk_bank_account', models.CharField(blank=True, help_text='TravelPerk bank account information if available.', max_length=50, null=True)),
('exported_to_fyle', models.BooleanField(default=False, help_text='If the invoice is exported to Fyle')),
('lines', models.ManyToManyField(help_text='Line items associated with the invoice.', to='travelperk.InvoiceLineItem')),
],
options={
'db_table': 'invoices',
},
),
migrations.CreateModel(
name='TravelperkCredential',
fields=[
('id', models.AutoField(help_text='Unique Id to indentify a Credentials', primary_key=True, serialize=False)),
('refresh_token', models.CharField(help_text='Travelperk Refresh Token', max_length=255, null=True)),
('created_at', models.DateTimeField(auto_now_add=True, help_text='Created at datetime')),
('updated_at', models.DateTimeField(auto_now=True, help_text='Updated at datetime')),
('org', models.OneToOneField(help_text='Reference to Org table', on_delete=django.db.models.deletion.PROTECT, to='orgs.org')),
],
options={
'db_table': 'travelperk_credentials',
},
),
migrations.CreateModel(
name='InvoiceLineItem',
fields=[
('id', models.AutoField(help_text='Unique identifier for the line item.', primary_key=True, serialize=False)),
('expense_date', models.DateField(help_text='Date of the expense for this line item.')),
('description', models.CharField(help_text='Description of the product or service.', max_length=255)),
('quantity', models.IntegerField(help_text='Quantity of the product or service.')),
('unit_price', models.DecimalField(decimal_places=2, help_text='Unit price of the product or service.', max_digits=10)),
('non_taxable_unit_price', models.DecimalField(decimal_places=2, help_text='Non-taxable unit price.', max_digits=10)),
('tax_percentage', models.DecimalField(decimal_places=2, help_text='Tax percentage applied.', max_digits=5)),
('tax_amount', models.DecimalField(decimal_places=2, help_text='Total tax amount for this line item.', max_digits=10)),
('tax_regime', models.CharField(help_text='Tax regime for this line item.', max_length=20)),
('total_amount', models.DecimalField(decimal_places=2, help_text='Total amount including taxes.', max_digits=10)),
('trip_id', models.CharField(help_text='ID of the trip associated with this line item.', max_length=255)),
('trip_name', models.CharField(help_text='Name of the trip associated with this line item.', max_length=255)),
('service', models.CharField(help_text='Type of service (e.g., PREMIUM).', max_length=50)),
('booker_name', models.CharField(help_text='Name of the person who booked the service.', max_length=100)),
('booker_email', models.EmailField(help_text='Email address of the person who booked the service.', max_length=254)),
('cost_center', models.CharField(help_text='Cost center associated with this line item.', max_length=20)),
('credit_card_last_4_digits', models.CharField(help_text='Last 4 digits of the credit card used for payment.', max_length=4)),
('invoice', models.ForeignKey(help_text='Invoice associated with this line item.', on_delete=django.db.models.deletion.CASCADE, related_name='line_items', to='travelperk.invoice')),
],
options={
'db_table': 'invoice_line_items',
},
),
]
83 changes: 42 additions & 41 deletions apps/travelperk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,78 +19,79 @@ class Meta:
db_table = 'travelperk_credentials'


from django.db import models

class InvoiceLineItem(models.Model):
"""
Travelperk Invoice Line Item Model
"""

id = models.UUIDField(primary_key=True, editable=False, unique=True, help_text='Unique identifier for the line item.')
expense_date = models.DateField(help_text='Date of the expense for this line item.')
description = models.CharField(max_length=255, help_text='Description of the product or service.')
quantity = models.PositiveIntegerField(help_text='Quantity of the product or service.')
unit_price = models.DecimalField(max_digits=10, decimal_places=2, help_text='Unit price of the product or service.')
non_taxable_unit_price = models.DecimalField(max_digits=10, decimal_places=2, help_text='Non-taxable unit price.')
tax_percentage = models.DecimalField(max_digits=5, decimal_places=2, help_text='Tax percentage applied.')
tax_amount = models.DecimalField(max_digits=10, decimal_places=2, help_text='Total tax amount for this line item.')
tax_regime = models.CharField(max_length=20, help_text='Tax regime for this line item.')
total_amount = models.DecimalField(max_digits=10, decimal_places=2, help_text='Total amount including taxes.')

# Metadata
trip_id = models.PositiveIntegerField(help_text='ID of the trip associated with this line item.')
trip_name = models.CharField(max_length=255, help_text='Name of the trip associated with this line item.')
service = models.CharField(max_length=50, help_text='Type of service (e.g., PREMIUM).')

# Booker
booker_name = models.CharField(max_length=100, help_text='Name of the person who booked the service.')
booker_email = models.EmailField(help_text='Email address of the person who booked the service.')

# Cost Center
cost_center = models.CharField(max_length=20, help_text='Cost center associated with this line item.')

# Other Fields
credit_card_last_4_digits = models.CharField(max_length=4, help_text='Last 4 digits of the credit card used for payment.')

class Meta:
db_table = 'invoice_line_items'


class Invoice(models.Model):
"""
Travelperk Invoice Model
"""

id = models.UUIDField(primary_key=True, editable=False, unique=True, help_text='Unique identifier for the invoice.')
id = models.AutoField(primary_key=True, help_text='Unique identifier for the invoice.')
billing_information = models.JSONField(help_text='Billing information associated with the invoice.')
billing_period = models.CharField(max_length=20, help_text='Billing period type (e.g., instant).')
currency = models.CharField(max_length=3, help_text='Currency code (e.g., GBP).')
due_date = models.DateField(help_text='Due date for the invoice.')
from_date = models.DateField(help_text='Start date for the billing period.')
to_date = models.DateField(help_text='End date for the billing period.')
issuing_date = models.DateField(help_text='Date when the invoice was issued.')
lines = models.ManyToManyField(InvoiceLineItem, help_text='Line items associated with the invoice.')

mode = models.CharField(
max_length=20,
choices=[('reseller', 'Reseller'), ('direct', 'Direct')],
help_text='Mode of the invoice, indicating whether it is a reseller or direct invoice.'
)
pdf = models.URLField(help_text='URL to the PDF version of the invoice.')
profile_id = models.UUIDField(help_text='ID of the profile associated with the invoice.')
profile_id = models.CharField(max_length=255, help_text='ID of the profile associated with the invoice.')
profile_name = models.CharField(max_length=255, help_text='Name of the profile associated with the invoice.')
reference = models.CharField(max_length=50, help_text='Reference information for the invoice (e.g., Trip #9876543).')
serial_number = models.CharField(max_length=20, help_text='Serial number of the invoice.')
status = models.CharField(max_length=20, help_text='Status of the invoice (e.g., paid).')
taxes_summary = models.JSONField(help_text='Summary of taxes applied to the invoice.')
total = models.DecimalField(max_digits=10, decimal_places=2, help_text='Total amount of the invoice.')
travelperk_bank_account = models.CharField(max_length=50, null=True, blank=True, help_text='TravelPerk bank account information if available.')

exported_to_fyle = models.BooleanField(default=False, help_text='If the invoice is exported to Fyle')

class Meta:
db_table = 'invoices'


class InvoiceLineItem(models.Model):
"""
Travelperk Invoice Line Item Model
"""

id = models.AutoField(primary_key=True, help_text='Unique identifier for the line item.')
expense_date = models.DateField(help_text='Date of the expense for this line item.')
description = models.CharField(max_length=255, help_text='Description of the product or service.')
quantity = models.IntegerField(help_text='Quantity of the product or service.')
unit_price = models.DecimalField(max_digits=10, decimal_places=2, help_text='Unit price of the product or service.')
non_taxable_unit_price = models.DecimalField(max_digits=10, decimal_places=2, help_text='Non-taxable unit price.')
tax_percentage = models.DecimalField(max_digits=5, decimal_places=2, help_text='Tax percentage applied.')
tax_amount = models.DecimalField(max_digits=10, decimal_places=2, help_text='Total tax amount for this line item.')
tax_regime = models.CharField(max_length=20, help_text='Tax regime for this line item.')
total_amount = models.DecimalField(max_digits=10, decimal_places=2, help_text='Total amount including taxes.')

# Metadata
trip_id = models.CharField(max_length=255, help_text='ID of the trip associated with this line item.')
trip_name = models.CharField(max_length=255, help_text='Name of the trip associated with this line item.')
service = models.CharField(max_length=50, help_text='Type of service (e.g., PREMIUM).')

# Booker
booker_name = models.CharField(max_length=100, help_text='Name of the person who booked the service.')
booker_email = models.EmailField(help_text='Email address of the person who booked the service.')

# Cost Center
cost_center = models.CharField(max_length=20, help_text='Cost center associated with this line item.')

# Other Fields
credit_card_last_4_digits = models.CharField(max_length=4, help_text='Last 4 digits of the credit card used for payment.')

# Foreign Key to Invoice
invoice = models.ForeignKey(Invoice, on_delete=models.CASCADE, related_name='line_items', help_text='Invoice associated with this line item.')

class Meta:
db_table = 'invoice_line_items'


class TravelPerk(models.Model):
"""
Travelperk Model
Expand Down

0 comments on commit 09377bf

Please sign in to comment.