05/08 Phase 4

This commit is contained in:
2026-05-08 10:15:40 -04:00
parent 959f54ed84
commit bf9b54f6b5
26 changed files with 1509 additions and 42 deletions
+32
View File
@@ -0,0 +1,32 @@
{% extends "tenant/layouts/base.html" %}
{% block title %}Adjust Stock — {{ item.name }}{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-5">
<div class="card shadow-sm">
<div class="card-header fw-semibold">Adjust Stock — {{ item.name }}</div>
<div class="card-body">
<p class="text-muted">Current quantity: <strong>{{ item.qty_on_hand }}</strong></p>
{% if error %}<div class="alert alert-danger py-2">{{ error }}</div>{% endif %}
<form method="POST" novalidate>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<div class="mb-3">
<label class="form-label">Adjustment <small class="text-muted">(positive = add, negative = remove)</small></label>
<input type="number" class="form-control form-control-lg text-center" name="delta"
placeholder="e.g. +10 or -3" autofocus required>
</div>
<div class="mb-3">
<label class="form-label">Reason</label>
<input type="text" class="form-control" name="reason"
placeholder="e.g. Stock count, Supplier delivery, Damage">
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">Apply Adjustment</button>
<a href="{{ url_for('inventory.index') }}" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
+61
View File
@@ -0,0 +1,61 @@
{% extends "tenant/layouts/base.html" %}
{% block title %}{{ 'Edit' if mode == 'edit' else 'New' }} Inventory Item{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card shadow-sm">
<div class="card-header fw-semibold">{{ 'Edit' if mode == 'edit' else 'Add' }} Inventory Item</div>
<div class="card-body">
{% if error %}<div class="alert alert-danger py-2">{{ error }}</div>{% endif %}
<form method="POST" novalidate>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<div class="mb-3">
<label class="form-label">Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="name"
value="{{ item.name if item else '' }}" required autofocus>
</div>
<div class="row g-2 mb-3">
<div class="col">
<label class="form-label">SKU</label>
<input type="text" class="form-control font-monospace" name="sku"
value="{{ item.sku if item else '' }}">
</div>
<div class="col">
<label class="form-label">Category</label>
<input type="text" class="form-control" name="category"
value="{{ item.category if item else '' }}">
</div>
</div>
{% if mode == 'create' %}
<div class="mb-3">
<label class="form-label">Initial Quantity</label>
<input type="number" class="form-control" name="qty_on_hand" min="0" value="0">
</div>
{% endif %}
<div class="mb-3">
<label class="form-label">Reorder Level <small class="text-muted">(alert when stock reaches this)</small></label>
<input type="number" class="form-control" name="reorder_level" min="0"
value="{{ item.reorder_level if item else 5 }}">
</div>
<div class="row g-2 mb-3">
<div class="col">
<label class="form-label">Cost Price ($)</label>
<input type="number" step="0.01" class="form-control" name="cost_price" min="0"
value="{{ "%.2f"|format(item.cost_price) if item and item.cost_price else '' }}">
</div>
<div class="col">
<label class="form-label">Sale Price ($)</label>
<input type="number" step="0.01" class="form-control" name="sale_price" min="0"
value="{{ "%.2f"|format(item.sale_price) if item and item.sale_price else '' }}">
</div>
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">Save</button>
<a href="{{ url_for('inventory.index') }}" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
+52
View File
@@ -0,0 +1,52 @@
{% extends "tenant/layouts/base.html" %}
{% block title %}Inventory{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<h4 class="fw-bold mb-0"><i class="bi bi-box-seam me-2"></i>Inventory</h4>
<a href="{{ url_for('inventory.create') }}" class="btn btn-primary btn-sm">+ Add Item</a>
</div>
{% if low_stock %}
<div class="alert alert-warning d-flex align-items-center mb-3">
<i class="bi bi-exclamation-triangle-fill me-2"></i>
<div>
<strong>{{ low_stock|length }} item(s) at or below reorder level:</strong>
{{ low_stock|map(attribute='name')|join(', ') }}
</div>
</div>
{% endif %}
<div class="card shadow-sm">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr><th>Name</th><th>SKU</th><th>Category</th><th>On Hand</th><th>Reorder At</th><th>Cost</th><th>Sale</th><th></th></tr>
</thead>
<tbody>
{% for item in items %}
<tr class="{{ 'table-warning' if item.qty_on_hand <= item.reorder_level else '' }}">
<td class="fw-semibold">{{ item.name }}</td>
<td class="small text-muted font-monospace">{{ item.sku or '—' }}</td>
<td class="small">{{ item.category or '—' }}</td>
<td>
<span class="fw-bold {{ 'text-danger' if item.qty_on_hand <= item.reorder_level else '' }}">
{{ item.qty_on_hand }}
</span>
</td>
<td class="small">{{ item.reorder_level }}</td>
<td class="small">{{ '$' ~ "%.2f"|format(item.cost_price) if item.cost_price else '—' }}</td>
<td class="small">{{ '$' ~ "%.2f"|format(item.sale_price) if item.sale_price else '—' }}</td>
<td class="d-flex gap-1">
<a href="{{ url_for('inventory.adjust', item_id=item.id) }}" class="btn btn-outline-primary btn-sm">Adjust</a>
<a href="{{ url_for('inventory.edit', item_id=item.id) }}" class="btn btn-outline-secondary btn-sm">Edit</a>
<a href="{{ url_for('inventory.log', item_id=item.id) }}" class="btn btn-outline-secondary btn-sm">Log</a>
</td>
</tr>
{% else %}
<tr><td colspan="8" class="text-center text-muted py-4">No inventory items yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
+31
View File
@@ -0,0 +1,31 @@
{% extends "tenant/layouts/base.html" %}
{% block title %}Stock Log — {{ item.name }}{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<h4 class="fw-bold mb-0">Stock Log — {{ item.name }}</h4>
<span class="badge bg-primary fs-6">Current: {{ item.qty_on_hand }} units</span>
</div>
<div class="card shadow-sm">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light"><tr><th>Date</th><th>Change</th><th>Reason</th></tr></thead>
<tbody>
{% for e in entries %}
<tr>
<td class="small text-muted">{{ e.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
<td class="fw-bold {{ 'text-success' if e.delta > 0 else 'text-danger' }}">
{{ '+' if e.delta > 0 else '' }}{{ e.delta }}
</td>
<td class="small">{{ e.reason or '—' }}</td>
</tr>
{% else %}
<tr><td colspan="3" class="text-center text-muted py-4">No log entries.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<a href="{{ url_for('inventory.index') }}" class="btn btn-outline-secondary btn-sm mt-3">
<i class="bi bi-arrow-left me-1"></i>Back to Inventory
</a>
{% endblock %}
+7 -1
View File
@@ -116,7 +116,7 @@
</li>
<li class="nav-item">
<a class="nav-link {% if request.endpoint and 'inventory' in request.endpoint %}active fw-bold{% endif %}"
href="{{ '#' }}">
href="{{ url_for('inventory.index') }}">
<i class="bi bi-box-seam me-2"></i>Inventory
</a>
</li>
@@ -132,6 +132,12 @@
<i class="bi bi-calculator me-2"></i>Reconciliation
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if request.endpoint and 'pay_periods' in request.endpoint %}active fw-bold{% endif %}"
href="{{ url_for('pay_periods.index') }}">
<i class="bi bi-wallet2 me-2"></i>Pay Periods
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if request.endpoint and 'reports' in request.endpoint %}active fw-bold{% endif %}"
href="{{ '#' }}">
@@ -0,0 +1,76 @@
{% extends "tenant/layouts/base.html" %}
{% block title %}Calculate Pay Period{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-5">
<div class="card shadow-sm mb-4">
<div class="card-header fw-semibold">Calculate Pay Period</div>
<div class="card-body">
<form method="POST" novalidate>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<div class="row g-2 mb-3">
<div class="col">
<label class="form-label">Period Start <span class="text-danger">*</span></label>
<input type="date" class="form-control" name="period_start"
value="{{ period_start.isoformat() if period_start else '' }}" required>
</div>
<div class="col">
<label class="form-label">Period End <span class="text-danger">*</span></label>
<input type="date" class="form-control" name="period_end"
value="{{ period_end.isoformat() if period_end else '' }}" required>
</div>
</div>
<div class="mb-3">
<label class="form-label">Staff Members <small class="text-muted">(leave blank for all)</small></label>
<select class="form-select" name="staff_ids" multiple size="6">
{% for s in staff_list %}
<option value="{{ s.id }}">{{ s.name }} — {{ s.pay_type.title() }}</option>
{% endfor %}
</select>
<div class="form-text">Hold Ctrl/Cmd to select multiple.</div>
</div>
<button type="submit" class="btn btn-primary w-100">Calculate</button>
</form>
</div>
</div>
</div>
{% if results %}
<div class="col-md-7">
<div class="card shadow-sm">
<div class="card-header fw-semibold">
Results — {{ period_start.strftime('%b %d') if period_start else '' }}{{ period_end.strftime('%b %d, %Y') if period_end else '' }}
</div>
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr><th>Staff</th><th>Type</th><th>Hours</th><th>Base</th><th>Commission</th><th>Total</th></tr>
</thead>
<tbody>
{% for row in results %}
<tr>
<td class="fw-semibold">{{ row.staff.name }}</td>
<td class="small">{{ row.calc.pay_type.title() }}</td>
<td class="small">{{ "%.1f"|format(row.calc.total_hours) }}h</td>
<td>${{ "%.2f"|format(row.calc.base_amount) }}</td>
<td>${{ "%.2f"|format(row.calc.commission_amount) }}</td>
<td class="fw-bold">${{ "%.2f"|format(row.calc.total_amount) }}</td>
</tr>
{% endfor %}
</tbody>
<tfoot class="table-light fw-bold">
<tr>
<td colspan="5">Grand Total</td>
<td>${{ "%.2f"|format(results|sum(attribute='calc.total_amount')) }}</td>
</tr>
</tfoot>
</table>
</div>
<div class="card-footer text-muted small">
Records saved as drafts. Go to <a href="{{ url_for('pay_periods.index') }}">Pay Periods</a> to approve and mark as paid.
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %}
+53
View File
@@ -0,0 +1,53 @@
{% extends "tenant/layouts/base.html" %}
{% block title %}Pay Periods{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<h4 class="fw-bold mb-0"><i class="bi bi-wallet2 me-2"></i>Pay Periods</h4>
<a href="{{ url_for('pay_periods.calculate') }}" class="btn btn-primary btn-sm">Calculate Period</a>
</div>
{% if periods %}
<div class="card shadow-sm">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr><th>Staff</th><th>Period</th><th>Type</th><th>Base</th><th>Commission</th><th>Topup</th><th>Total</th><th>Status</th><th></th></tr>
</thead>
<tbody>
{% for pp in periods %}
<tr>
<td class="fw-semibold">{{ pp.staff.name if pp.staff else pp.staff_id }}</td>
<td class="small text-nowrap">{{ pp.period_start.strftime('%b %d') }}{{ pp.period_end.strftime('%b %d, %Y') }}</td>
<td class="small">{{ pp.pay_type.title() }}</td>
<td>${{ "%.2f"|format(pp.base_amount) }}</td>
<td>${{ "%.2f"|format(pp.commission_amount) }}</td>
<td>{{ '$' ~ "%.2f"|format(pp.guarantee_topup) if pp.guarantee_topup > 0 else '—' }}</td>
<td class="fw-bold">${{ "%.2f"|format(pp.total_amount) }}</td>
<td>
<span class="badge bg-{{ {'draft':'secondary','approved':'primary','paid':'success'}.get(pp.status,'secondary') }}">
{{ pp.status }}
</span>
</td>
<td class="d-flex gap-1">
{% if pp.status == 'draft' %}
<form method="POST" action="{{ url_for('pay_periods.approve', pp_id=pp.id) }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button class="btn btn-outline-primary btn-sm">Approve</button>
</form>
{% elif pp.status == 'approved' %}
<form method="POST" action="{{ url_for('pay_periods.mark_paid', pp_id=pp.id) }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button class="btn btn-outline-success btn-sm">Mark Paid</button>
</form>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% else %}
<div class="alert alert-light">No pay periods calculated yet. Use <strong>Calculate Period</strong> to get started.</div>
{% endif %}
{% endblock %}
+76 -10
View File
@@ -1,5 +1,18 @@
{% extends "tenant/layouts/base.html" %}
{% block title %}{{ 'Edit' if mode == 'edit' else 'New' }} Staff Member{% endblock %}
{% block scripts %}
<script>
function togglePayFields(val) {
document.getElementById("field_hourly_rate").classList.toggle("d-none", val !== "hourly");
document.getElementById("field_salary_amount").classList.toggle("d-none", val !== "salary");
document.getElementById("field_guarantee_amount").classList.toggle("d-none", val !== "guarantee");
}
document.addEventListener("DOMContentLoaded", function() {
var pt = document.getElementById("pay_type");
if (pt) togglePayFields(pt.value);
});
</script>
{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-6">
@@ -11,17 +24,19 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<div class="mb-3">
<label class="form-label">Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="name" value="{{ staff.name if staff else '' }}" required
autofocus>
<input type="text" class="form-control" name="name"
value="{{ staff.name if staff else '' }}" required autofocus>
</div>
<div class="mb-3">
<label class="form-label">Phone <span class="text-danger">*</span></label>
<input type="tel" class="form-control" name="phone" value="{{ staff.phone if staff else '' }}" required>
<input type="tel" class="form-control" name="phone"
value="{{ staff.phone if staff else '' }}" required>
</div>
{% if mode == 'create' %}
<div class="mb-3">
<label class="form-label">Passcode (46 digits) <span class="text-danger">*</span></label>
<input type="password" class="form-control" name="passcode" inputmode="numeric" maxlength="6" required>
<input type="password" class="form-control" name="passcode"
inputmode="numeric" maxlength="6" required>
<div class="form-text">Staff will use this PIN to log in. Show it to them once, then discard it.</div>
</div>
{% endif %}
@@ -30,7 +45,7 @@
<label class="form-label">Job Type</label>
<select class="form-select" name="staff_type">
{% for t in ['full_time','part_time','seasonal','receptionist','salon_manager'] %}
<option value="{{ t }}" {{ 'selected' if staff and staff.staff_type==t }}>
<option value="{{ t }}" {{ 'selected' if staff and staff.staff_type == t }}>
{{ t.replace('_',' ').title() }}
</option>
{% endfor %}
@@ -40,25 +55,76 @@
<label class="form-label">Pay Type</label>
<select class="form-select" name="pay_type">
{% for t in ['hourly','salary','guarantee'] %}
<option value="{{ t }}" {{ 'selected' if staff and staff.pay_type==t }}>{{ t.title() }}</option>
<option value="{{ t }}" {{ 'selected' if staff and staff.pay_type == t }}>{{ t.title() }}</option>
{% endfor %}
</select>
</div>
</div>
<hr class="my-3">
<h6 class="fw-semibold text-muted mb-3">Pay Structure</h6>
<div class="row g-2 mb-3">
<div class="col">
<label class="form-label">Pay Type</label>
<select class="form-select" name="pay_type" id="pay_type" onchange="togglePayFields(this.value)">
{% for t in ['hourly','salary','guarantee'] %}
<option value="{{ t }}" {{ 'selected' if staff and staff.pay_type == t }}>{{ t.title() }}</option>
{% endfor %}
</select>
</div>
<div class="col">
<label class="form-label">Pay Period</label>
<select class="form-select" name="pay_period">
{% for t in ['weekly','biweekly','monthly'] %}
<option value="{{ t }}" {{ 'selected' if staff and staff.pay_period == t }}>{{ t.title() }}</option>
{% endfor %}
</select>
</div>
</div>
<div id="field_hourly_rate" class="mb-3">
<label class="form-label">Hourly Rate ($)</label>
<input type="number" step="0.01" class="form-control" name="hourly_rate" min="0"
value="{{ "%.2f"|format(staff.hourly_rate) if staff and staff.hourly_rate else '' }}">
</div>
<div id="field_salary_amount" class="mb-3 d-none">
<label class="form-label">Salary Amount ($ per pay period)</label>
<input type="number" step="0.01" class="form-control" name="salary_amount" min="0"
value="{{ "%.2f"|format(staff.salary_amount) if staff and staff.salary_amount else '' }}">
</div>
<div id="field_guarantee_amount" class="mb-3 d-none">
<label class="form-label">Guarantee Amount ($ per pay period)</label>
<input type="number" step="0.01" class="form-control" name="guarantee_amount" min="0"
value="{{ "%.2f"|format(staff.guarantee_amount) if staff and staff.guarantee_amount else '' }}">
</div>
<div class="row g-2 mb-3">
<div class="col">
<label class="form-label">Commission Rate (%)</label>
<input type="number" step="0.01" class="form-control" name="commission_rate" min="0" max="100"
value="{{ "%.2f"|format(staff.commission_rate) if staff and staff.commission_rate else '' }}">
</div>
<div class="col d-flex align-items-end mb-1">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="commission_enabled" value="1"
id="commission_enabled"
{{ 'checked' if not staff or staff.commission_enabled }}>
<label class="form-check-label" for="commission_enabled">Commission Enabled</label>
</div>
</div>
</div>
<div class="mb-3">
<label class="form-label">Location Assignments</label>
{% for loc in locations %}
<div class="form-check">
<input class="form-check-input" type="checkbox" name="location_ids" value="{{ loc.id }}"
id="loc_{{ loc.id }}" {{ 'checked' if assigned_ids and loc.id in assigned_ids }}>
<input class="form-check-input" type="checkbox" name="location_ids"
value="{{ loc.id }}" id="loc_{{ loc.id }}"
{{ 'checked' if assigned_ids and loc.id in assigned_ids }}>
<label class="form-check-label" for="loc_{{ loc.id }}">{{ loc.name }}</label>
</div>
{% endfor %}
</div>
{% if mode == 'edit' %}
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" name="is_active" value="1" id="is_active" {{ 'checked' if
staff and staff.is_active }}>
<input class="form-check-input" type="checkbox" name="is_active" value="1"
id="is_active" {{ 'checked' if staff and staff.is_active }}>
<label class="form-check-label" for="is_active">Active</label>
</div>
{% endif %}