Skip to content

Commit

Permalink
Merge branch 'main' into checkout-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
vidya-ram committed Mar 27, 2024
2 parents e670e7f + ed5c915 commit 66b7518
Show file tree
Hide file tree
Showing 64 changed files with 791 additions and 377 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ monkeytype.sqlite3
.env
.env.testing
.envrc
.DS_Store
.venv
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
hooks:
- id: ruff
args: ['--fix', '--exit-non-zero-on-fix']
Expand All @@ -20,7 +20,7 @@ repos:
'--remove-duplicate-keys',
]
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.1
rev: v3.15.2
hooks:
- id: pyupgrade
args: ['--keep-runtime-typing', '--py311-plus']
Expand Down Expand Up @@ -52,7 +52,7 @@ repos:
additional_dependencies:
- toml
- repo: https://github.com/psf/black
rev: 24.2.0
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -83,7 +83,7 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.9.0
hooks:
- id: mypy
# warn-unused-ignores is unsafe with pre-commit, see
Expand Down Expand Up @@ -117,7 +117,7 @@ repos:
additional_dependencies:
- tomli
- repo: https://github.com/PyCQA/bandit
rev: 1.7.7
rev: 1.7.8
hooks:
- id: bandit
language_version: python3
Expand Down
7 changes: 3 additions & 4 deletions boxoffice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from flask_rq2 import RQ
from pytz import timezone

from baseframe import Version, assets, baseframe
from baseframe import Version, baseframe
from baseframe.utils import JSONProvider
from coaster.assets import WebpackManifest
from flask_lastuser import Lastuser
Expand All @@ -28,7 +28,6 @@
# --- Assets ---------------------------------------------------------------------------

version = Version(__version__)
assets['boxoffice.js'][version] = 'js/scripts.js'

# --- Import rest of the app -----------------------------------------------------------

Expand All @@ -38,8 +37,8 @@
DiscountCoupon,
DiscountPolicy,
Invoice,
Item,
ItemCollection,
Ticket,
Menu,
Organization,
Price,
User,
Expand Down
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
71 changes: 0 additions & 71 deletions boxoffice/assets/js/views/admin_org_report.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
124 changes: 124 additions & 0 deletions boxoffice/assets/js/views/org_report_admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/* eslint-disable no-unused-vars */
import { fetch, urlFor, setPageTitle } from '../models/util';
import { OrgReportTemplate } from '../templates/admin_org_report.html';
import { SideBarView } from './sidebar';

const NProgress = require('nprogress');
const Ractive = require('ractive');
const fly = require('ractive-transitions-fly');

export const OrgReportView = {
render({ accountName } = {}) {
fetch({
url: urlFor('index', {
resource: 'reports',
scope_ns: 'o',
scope_id: accountName,
root: true,
}),
}).done(({ account_title: accountTitle }) => {
// Initial render
const currentDate = new Date();
const currentYear = String(currentDate.getFullYear());
// month starts from 0
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',
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', {
resource: reportType,
scope_ns: 'o',
scope_id: accountName,
ext: 'csv',
root: true,
});
const params = {};
if (reportType === 'settlements') {
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}?${$.param(params)}`;
},
reportsFilename() {
let filename = `${accountName}_${this.get('reportType')}`;
if (this.get('reportType') === 'settlements') {
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;
}
}
filename += '.csv';
return filename;
},
},
});

SideBarView.render('org_reports', { accountName, accountTitle });
setPageTitle('Organization reports', accountTitle);
NProgress.done();

window.addEventListener('popstate', (event) => {
NProgress.configure({ showSpinner: false }).start();
});
});
},
};

export { OrgReportView as default };
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 17 additions & 17 deletions boxoffice/assets/js/views/router.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { IndexView } from './index';
import { OrgView } from './org';
import { OrgReportView } from './admin_org_report';
import { DiscountPolicyView } from './admin_discount_policy';
import { DeleteDiscountPolicyView } from './delete_discount_policy';
import { MenuView } from './item_collection';
import { MenuNewView } from './new_item_collection';
import { MenuEditView } from './edit_item_collection';
import { OrdersView } from './admin_orders';
import { OrderView } from './admin_order';
import { ReportView } from './admin_report';
import { TicketView } from './admin_item';
import { NewTicketView } from './new_item';
import { EditTicketView } from './edit_item';
import { NewPriceView } from './new_price';
import { EditPriceView } from './edit_price';
import { NewCategoryView } from './new_category';
import { EditCategoryView } from './edit_category';
import { PartialRefundOrderView } from './partial_refund_order';
import { OrgReportView } from './org_report_admin';
import { DiscountPolicyView } from './discount_policy_admin';
import { DeleteDiscountPolicyView } from './discount_policy_delete';
import { MenuView } from './menu';
import { MenuNewView } from './menu_new';
import { MenuEditView } from './menu_edit';
import { OrdersView } from './orders_admin';
import { OrderView } from './order_admin';
import { ReportView } from './report_admin';
import { TicketView } from './ticket_admin';
import { NewTicketView } from './ticket_new';
import { EditTicketView } from './ticket_edit';
import { NewPriceView } from './price_new';
import { EditPriceView } from './price_edit';
import { NewCategoryView } from './category_new';
import { EditCategoryView } from './category_edit';
import { PartialRefundOrderView } from './order_partial_refund';

const Backbone = require('backbone');

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 66b7518

Please sign in to comment.