Add pricing entry flow and platform admin foundations

This commit is contained in:
egecankomur
2026-06-20 18:24:40 +03:00
parent 1d36ccdf30
commit ac42681f7e
44 changed files with 6567 additions and 1419 deletions
+28 -12
View File
@@ -20,9 +20,9 @@ class FinanceService {
if (amount <= 0) return;
final existing = await _pb.collection('finance_entries').getFullList(
filter: 'job_id = "$jobId"',
batch: 200,
);
filter: 'job_id = "$jobId"',
batch: 200,
);
await _upsertEntry(
existing: existing,
@@ -47,11 +47,27 @@ class FinanceService {
);
}
Future<void> markJobPaid(String jobId) async {
Future<void> reportJobPayment(String jobId) async {
final existing = await _pb.collection('finance_entries').getFullList(
filter: 'job_id = "$jobId"',
batch: 200,
);
filter: 'job_id = "$jobId"',
batch: 200,
);
for (final record in existing) {
await _pb.collection('finance_entries').update(
record.id,
body: {
'status': 'reported',
'paid_at': null,
},
);
}
}
Future<void> confirmJobPayment(String jobId) async {
final existing = await _pb.collection('finance_entries').getFullList(
filter: 'job_id = "$jobId"',
batch: 200,
);
final paidAt = DateTime.now().toIso8601String();
for (final record in existing) {
await _pb.collection('finance_entries').update(
@@ -66,9 +82,10 @@ class FinanceService {
Future<void> deletePendingEntriesForJob(String jobId) async {
final existing = await _pb.collection('finance_entries').getFullList(
filter: 'job_id = "$jobId" && status = "pending"',
batch: 200,
);
filter:
'job_id = "$jobId" && (status = "pending" || status = "reported")',
batch: 200,
);
for (final record in existing) {
await _pb.collection('finance_entries').delete(record.id);
}
@@ -88,8 +105,7 @@ class FinanceService {
try {
match = existing.firstWhere(
(record) =>
record.data['tenant_id'] == tenantId &&
record.data['type'] == type,
record.data['tenant_id'] == tenantId && record.data['type'] == type,
);
} catch (_) {
match = null;