Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoho Books Invoice report #467

Merged
merged 96 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
eb84929
Upgrades for SQLAlchemy 2.0; additional linters; drop obsolete html5p…
jace May 11, 2023
9adf024
Fix all linter-identified issues
jace May 11, 2023
ba71efa
Support pytest without wrapping shell script
jace May 11, 2023
f7f0d1a
Add ALLOWED_ORIGINS to config sample
jace May 11, 2023
9ca7851
Remove custom endpoint names from views
jace May 11, 2023
ea6a09a
Use status code 422 instead of 402
jace May 11, 2023
79ba9c7
Fix import
jace May 11, 2023
5675fd6
Upgrade JavaScript (incomplete, still has webpack build errors)
jace May 11, 2023
f648dc9
Now left with only unused var errors, and one undefined reference
jace May 11, 2023
edb42ba
Webpack is now building, but Baseframe can't parse the new manifest.j…
jace May 11, 2023
ebc646a
Webpack assets now require the .js extension
jace May 12, 2023
d125066
Merge branch 'main' into linter-fixes
jace May 14, 2023
91b46f9
Merge branch 'main' into linter-fixes
jace May 14, 2023
553efd2
Add DeepSource config
jace May 14, 2023
d5f0f78
ASSET_BASE_PATH is no longer required with new Webpack
jace May 14, 2023
e496c50
Use psycopg3 for tests
jace May 23, 2023
94d4b28
Remove db.Model from base class in models
jace May 29, 2023
e1dbe73
Specify Ractive.transitions.fly on Ractive init
jace May 29, 2023
1e4efb3
Change ractive to version 0.8.0
vidya-ram May 29, 2023
5431f46
Merge branch 'linter-fixes' of https://github.com/hasgeek/boxoffice i…
vidya-ram May 29, 2023
9452063
Remove unnecessary type ignores
jace May 29, 2023
62d4267
Use backref from Coaster
jace May 29, 2023
326cddf
Add css build to webpack
vidya-ram May 29, 2023
608bfe9
Merge branch 'linter-fixes' of https://github.com/hasgeek/boxoffice i…
vidya-ram May 29, 2023
6365544
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 29, 2023
8e3f438
Relocate enums into a single file, move some added properties, use as…
jace May 29, 2023
5160133
Use mapped_column instead of Column
jace May 29, 2023
7aa441b
Replace all relationship backrefs with back_populates
jace May 29, 2023
530e6ae
Move ItemCollection.net_sales report within class and use SQLAlchemy …
jace May 29, 2023
c7472ba
Convert sales_by_date SQL to SQLAlchemy query
jace May 29, 2023
2cef2ab
Convert demand curve SQL to SQLAlchemy query
jace May 29, 2023
a531534
Convert date_item_counts from SQL to SQLAlchemy
jace May 29, 2023
5ccd918
Move relationships within Order class and solve for circular imports
jace May 29, 2023
89dd04e
Fix stylesheet -- block layoutheaders in index is overriding layout
jace May 29, 2023
75611dc
Backbone names it with an underscore prefix
jace May 30, 2023
9612d35
Replace week_sales SQL with SQLAlchemy construct and fix typing
jace May 30, 2023
2bd978f
Last remaining raw SQL statements converted to SQLAlchemy constructs
jace May 30, 2023
2c5aacf
Add trans tags to all text in Jinja2 templates
jace May 30, 2023
3f7176b
Fix the loop and variable names
vidya-ram May 30, 2023
514ad35
Merge branch 'linter-fixes' of https://github.com/hasgeek/boxoffice i…
vidya-ram May 30, 2023
d23ef83
Fix the variable name on admin page discount policy page
vidya-ram May 30, 2023
cdaf81a
Ensure JSON content is saved as a dict
jace May 30, 2023
f1837ff
Assignee ticket to item
vidya-ram May 31, 2023
f3beba6
Add type hints to console script
jace May 31, 2023
9f14142
Add type hints to forms
jace May 31, 2023
ca81c5f
Drop WTForms-JSON and switch to JsonField in ItemForm
jace Jun 2, 2023
7a08456
Rename 'item' to 'ticket' and 'item_collection' to 'menu' comprehensi…
jace Jun 2, 2023
d499fc9
Remove unmaintained types-all dependency
jace Jun 2, 2023
ce5b55d
Remove function calls in default arguments
jace Jun 6, 2023
dde5b02
Use Mapped annotations for all columns; rename Order.invoice_no to re…
jace Jun 6, 2023
8390807
Make timestamptz_now separate
jace Jun 6, 2023
07c169a
Replace LabeledEnum with Enum
jace Jun 6, 2023
45bf721
Add types-setuptools to pre-commit mypy config
jace Jun 6, 2023
89ee9ae
Replace query.first() with .one() or .one_or_none() to catch poorly f…
jace Jun 7, 2023
964ba45
Use unittest's patch instead of manually patching the refund_payment …
jace Jun 7, 2023
7384676
Add return type for render_with views
jace Jun 7, 2023
7a136d8
Use LF line ending
anishTP Jun 8, 2023
79c4f33
Drop CRLF line endings
jace Jun 8, 2023
4861d67
Fix type safety checks in tests
jace Jun 8, 2023
9b7f757
Add type hint for request.json in JSON-only views
jace Jun 8, 2023
70c06a9
Test actor is not None
jace Jun 8, 2023
d92d4c2
Type checks for everything except the calculate method
jace Jun 8, 2023
b83c0f0
Switch from pytest-remotedata to pytest-socket
jace Jun 8, 2023
297eed3
Use `.first()` since the query has an order_by clause
jace Jun 9, 2023
6a4b220
Use Coaster's WebpackManifest for Webpack assets
jace Jun 20, 2023
f0fa247
Merge branch 'main' into linter-fixes
jace Jul 20, 2023
267f70e
Update .pre-commit-config.yaml
jace Jul 20, 2023
4d1ad46
Add branch name to telegram message sent on pushing code to the repo
miteshashar Jul 24, 2023
c044a24
Merge branch 'main' into linter-fixes
jace Aug 7, 2023
bd321ae
Merge branch 'main' into linter-fixes
jace Aug 7, 2023
d598eed
Merge branch 'main' into linter-fixes
jace Aug 8, 2023
5618618
Ignore pyenv's .python-version file
miteshashar Aug 17, 2023
cab74f4
Merge branch 'main' into linter-fixes
miteshashar Aug 18, 2023
56a1d56
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 18, 2023
9fe7f4e
Add sample.env
miteshashar Aug 22, 2023
e9c69c8
Correct LASTUSER_COOKIE_DOMAIN in sample.env
miteshashar Aug 22, 2023
b392d88
Change the path for ticket search API endpoint from /admin/o/<org>/it…
miteshashar Aug 29, 2023
3c7a8c6
Discount policy endpoint expects applicable tickets in the ticket(s) …
miteshashar Aug 30, 2023
0cb2b59
Add Buyer Tax ID and Buyer Full Name columns to the Invoices CSV report
miteshashar Sep 5, 2023
ab39909
For json and jsonb in models, temporarily use coaster's JsonDict inst…
miteshashar Sep 6, 2023
0b96770
Work-in-progress commit for type annotations in line item discounter
jace Sep 6, 2023
fd32482
Merge branch 'main' into linter-fixes
jace Sep 6, 2023
d076a28
Add period-based filtering options for invoice reports
miteshashar Sep 12, 2023
c759a75
Introduce regular expression for PAN numbers to utils
miteshashar Sep 12, 2023
f6f6be3
Merge branch 'linter-fixes' into invoice-report
miteshashar Sep 12, 2023
1843bf2
Zoho Books Invoices Report First Cut
miteshashar Oct 3, 2023
9110236
Updated usage of correct API field and convert all amnounts received …
miteshashar Oct 3, 2023
3b6234b
Zoho Books Invoices report - version for final review and production …
miteshashar Oct 9, 2023
e825ea5
Merge branch 'main' into invoice-report
jace Mar 7, 2024
eb69974
Merge branch 'main' into invoice-report
jace Mar 7, 2024
859c613
Require siteadmin to view sensitive reports
jace Mar 7, 2024
2b0191e
Remove unnecessary cast
jace Mar 7, 2024
c920522
Custom JSON columns are no longer being used
jace Mar 7, 2024
357bc42
Merge branch 'main' into invoice-report
jace Mar 7, 2024
066eb9d
Order invoices by date
jace Mar 7, 2024
a01e1db
Drop siteadmin in org-level reports; fix Razorpay API access
jace Mar 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 58 additions & 8 deletions boxoffice/assets/js/templates/admin_org_report.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,65 @@ export const OrgReportTemplate = `
<p class="field-title filled">Report type</p>
<select name="report-type" value="{{ reportType }}">
<option value="invoices" selected="selected">Invoices</option>
{{#if siteadmin}}
<option value="settlements">Settlements</option>
{{/if}}
<option value="settlements">Settlements</option>
<option value="invoices_zoho_books">Zoho Books Invoices</option>
</select>
{{#if reportType == "settlements"}}
<p class='settlements-month-widget'>
<input id="month" type="month" value="{{monthYear}}">
</p>
{{/if}}
<p class="{{showForZBInvoicesClass()}}">
<small>
Following fields do not get automatically detected during import
and need to be manually mapped:
<ul>
<li>Sales Order Number</li>
<li>
Contact Details
<ul>
<li>First Name</li>
<li>Last Name</li>
<li>Email</li>
</ul>
</li>
<li>
Item Details
<ul>
<li>Item Tax %</li>
</ul>
</li>
</ul>
Following fields need to be manually added to the exported file:
<ul>
<li>Place of Supply</li>
<li>
Item Details
<ul>
<li>Account</li>
<li>HSN/SAC</li>
</ul>
</li>
</ul>
</small>
</p>
</div>
<div class="group-select {{hideForSettlementsClass()}}">
<p class="field-title filled">Filter by period</p>
<select name="period-type" value="{{ periodType }}">
<option value="all" selected="selected">All</option>
<option value="monthly">Monthly</option>
<option value="custom">Custom</option>
</select>
</div>
<div class="report-period">
<p class="field-title filled {{periodMonthlyClass()}}">Month</p>
<p class="{{periodMonthlyClass()}}">
<input id="month" type="month" value="{{periodMonth}}" max="{{currentMonth}}">
</p>
<p class="field-title filled {{periodCustomClass()}}">From</p>
<p class="{{periodCustomClass()}}">
<input id="period-from" type="date" name="from" value="{{periodFrom}}" max="{{periodTo}}">
</p>
<p class="field-title filled {{periodCustomClass()}}">To</p>
<p class="{{periodCustomClass()}}">
<input id="period-to" type="date" name="to" value="{{periodTo}}" max="{{periodTo}}">
</p>
</div>
<div class="btn-wrapper">
<a href="{{ reportsUrl() }}" download="{{ reportsFilename() }}" class="boxoffice-button boxoffice-button-action">Download</a>
Expand Down
77 changes: 65 additions & 12 deletions boxoffice/assets/js/views/admin_org_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,45 @@ export const OrgReportView = {
scope_id: accountName,
root: true,
}),
}).done(({ account_title: accountTitle, siteadmin }) => {
}).done(({ account_title: accountTitle }) => {
// Initial render
const currentDate = new Date();
const currentYear = currentDate.getFullYear();
const currentYear = String(currentDate.getFullYear());
// month starts from 0
const currentMonth = currentDate.getMonth() + 1;
const currentMonth = String(currentDate.getMonth() + 1).padStart(2, '0');
const prevMonth = String(
((currentDate.getMonth() + 11) % 12) + 1
).padStart(2, '0');
const toDate = String(currentDate.getDate()).padStart(2, '0');
const reportComponent = new Ractive({
el: '#main-content-area',
template: OrgReportTemplate,
transitions: { fly },
data: {
accountTitle,
reportType: 'invoices',
monthYear: `${currentYear}-${currentMonth}`,
siteadmin,
periodType: 'all',
periodMonth: `${currentYear}-${prevMonth}`,
currentMonth: `${currentYear}-${currentMonth}`,
periodFrom: `${currentYear}-${currentMonth}-01`,
periodTo: `${currentYear}-${currentMonth}-${toDate}`,
hideForSettlementsClass() {
return this.get('reportType') === 'settlements' ? 'hide' : '';
},
showForZBInvoicesClass() {
return this.get('reportType') === 'invoices_zoho_books'
? ''
: 'hide';
},
periodMonthlyClass() {
if (this.get('reportType') === 'settlements') return '';
return this.get('periodType') !== 'monthly' ? 'hide' : '';
},
periodCustomClass() {
return this.get('periodType') !== 'custom'
? 'hide'
: this.get('hideForSettlementsClass')();
},
reportsUrl() {
const reportType = this.get('reportType');
const url = urlFor('index', {
Expand All @@ -40,19 +64,48 @@ export const OrgReportView = {
ext: 'csv',
root: true,
});
const params = {};
if (reportType === 'settlements') {
const [year, month] = this.get('monthYear').split('-');
return `${url}?year=${year}&month=${month}`;
const periodMonth = this.get('periodMonth');
if (periodMonth)
[params.year, params.month] = periodMonth.split('-');
} else {
params.type = this.get('periodType');
switch (params.type) {
case 'monthly':
params.month = this.get('periodMonth');
break;
case 'custom':
params.from = this.get('periodFrom');
params.to = this.get('periodTo');
break;
default:
break;
}
}
return url;
return `${url}?${$.param(params)}`;
},
reportsFilename() {
let filename = `${accountName}_${this.get('reportType')}`;
if (this.get('reportType') === 'settlements') {
return `${accountName}_${this.get('reportType')}_${this.get(
'monthYear'
)}.csv`;
filename += `_${this.get('periodMonth')}`;
} else {
const periodType = this.get('periodType');
switch (periodType) {
case 'monthly':
filename += `_${this.get('periodMonth')}`;
break;
case 'custom':
filename += `_${this.get('periodFrom')}_${this.get(
'periodTo'
)}`;
break;
default:
break;
}
}
return `${accountName}_${this.get('reportType')}.csv`;
filename += '.csv';
return filename;
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion boxoffice/assets/sass/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ ul.content-slider-content {
}
}

p.settlements-month-widget {
p.period-type {
margin-top: 10px;
}
//styles for admin page
Expand Down
16 changes: 8 additions & 8 deletions boxoffice/extapi/razorpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ def get_settled_transactions(date_range, tz=None):
"Transaction external to Boxoffice. Credited directly to Razorpay?"
)

for settled_transaction in settled_transactions['tickets']:
for settled_transaction in settled_transactions['items']:
if settled_transaction['type'] == 'settlement':
rows.append(
{
'settlement_id': settled_transaction['entity_id'],
'settlement_amount': settled_transaction['amount'],
'settlement_amount': settled_transaction['amount'] / 100,
'settled_at': settled_transaction['settled_at'],
'transaction_type': settled_transaction['type'],
}
Expand All @@ -102,9 +102,9 @@ def get_settled_transactions(date_range, tz=None):
'transaction_type': settled_transaction['type'],
'order_id': order.id,
'payment_id': settled_transaction['entity_id'],
'razorpay_fees': settled_transaction['fee'],
'razorpay_fees': settled_transaction['fee'] / 100,
'transaction_date': localize_timezone(order.paid_at, tz),
'credit': settled_transaction['credit'],
'credit': settled_transaction['credit'] / 100,
'buyer_fullname': order.buyer_fullname,
'menu': order.menu.title,
}
Expand All @@ -128,7 +128,7 @@ def get_settled_transactions(date_range, tz=None):
{
'settlement_id': settled_transaction['settlement_id'],
'payment_id': settled_transaction['entity_id'],
'credit': settled_transaction['credit'],
'credit': settled_transaction['credit'] / 100,
'description': external_transaction_msg,
}
)
Expand All @@ -149,11 +149,11 @@ def get_settled_transactions(date_range, tz=None):
'payment_id': settled_transaction['payment_id'],
'transaction_type': settled_transaction['type'],
'order_id': order.id,
'razorpay_fees': settled_transaction['fee'],
'debit': settled_transaction['debit'],
'razorpay_fees': settled_transaction['fee'] / 100,
'debit': settled_transaction['debit'] / 100,
'buyer_fullname': order.buyer_fullname,
'description': refund.refund_description,
'amount': refund.amount,
'amount': refund.amount / 100,
'menu': order.menu.title,
}
)
Expand Down
2 changes: 1 addition & 1 deletion boxoffice/mailclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def send_ticket_reassignment_mail(
)
order = line_item.order

subject = _("{title}: Your ticket has been transfered to someone else").format(
subject = _("{title}: Your ticket has been transferred to someone else").format(
title=order.menu.title
)
msg = Message(
Expand Down
2 changes: 0 additions & 2 deletions boxoffice/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.dialects import postgresql
from sqlalchemy.orm import DeclarativeBase, Mapped
from sqlalchemy_json import mutable_json_type
import sqlalchemy as sa

from coaster.sqlalchemy import (
Expand Down Expand Up @@ -41,7 +40,6 @@ class Model(ModelBase, DeclarativeBase):
sa.orm.mapped_column(sa.TIMESTAMP(timezone=True), default=sa.func.utcnow()),
]


TimestampMixin.__with_timezone__ = True
db = SQLAlchemy(metadata=Model.metadata, query_class=Query) # type: ignore[arg-type]
Model.init_flask_sqlalchemy(db)
Expand Down
Loading
Loading