Merge dev to main #1

Open
kibin wants to merge 33 commits from dev into main
Showing only changes of commit 8fdfa6b7ba - Show all commits

View File

@@ -113,7 +113,7 @@ async function main() {
const userDefs = [ const userDefs = [
{ email: 'admin@demo-isp.com', first: 'Admin', last: 'User', role: 'tenant_admin' }, { email: 'admin@demo-isp.com', first: 'Admin', last: 'User', role: 'tenant_admin' },
{ email: 'manager@demo-isp.com', first: 'Maria', last: 'Reyes', role: 'manager' }, { email: 'manager@demo-isp.com', first: 'Maria', last: 'Reyes', role: 'manager' },
{ email: 'collector@demo-isp.com', first: 'Juan', last: 'Santos', role: 'technician' }, { email: 'collector@demo-isp.com', first: 'Juan', last: 'Santos', role: 'collector' },
{ email: 'tech@demo-isp.com', first: 'Pedro', last: 'Cruz', role: 'technician' }, { email: 'tech@demo-isp.com', first: 'Pedro', last: 'Cruz', role: 'technician' },
{ email: 'tech2@demo-isp.com', first: 'Jose', last: 'Garcia', role: 'technician' }, { email: 'tech2@demo-isp.com', first: 'Jose', last: 'Garcia', role: 'technician' },
{ email: 'viewer@demo-isp.com', first: 'Ana', last: 'Lopez', role: 'viewer' }, { email: 'viewer@demo-isp.com', first: 'Ana', last: 'Lopez', role: 'viewer' },
@@ -468,13 +468,14 @@ async function main() {
const methods = ['gcash', 'maya', 'cash', 'bank_transfer']; const methods = ['gcash', 'maya', 'cash', 'bank_transfer'];
const method = methods[Math.floor(Math.random() * methods.length)]; const method = methods[Math.floor(Math.random() * methods.length)];
const paidDate = new Date(dueDate.getTime() - 86400000 * Math.floor(Math.random() * 5)); const paidDate = new Date(dueDate.getTime() - 86400000 * Math.floor(Math.random() * 5));
const collector = i % 2 === 0 ? usersByEmail['collector@demo-isp.com'] : usersByEmail['tech@demo-isp.com'];
await prisma.payment.create({ await prisma.payment.create({
data: { data: {
tenantId: tenant.id, tenantId: tenant.id,
clientId: client.id, clientId: client.id,
invoiceId: invoice.id, invoiceId: invoice.id,
collectedById: users.technician.id, collectedById: collector.id,
amount, amount,
method, method,
referenceNo: method !== 'cash' ? `REF-${String(Math.floor(Math.random() * 99999)).padStart(5, '0')}` : null, referenceNo: method !== 'cash' ? `REF-${String(Math.floor(Math.random() * 99999)).padStart(5, '0')}` : null,
@@ -482,17 +483,17 @@ async function main() {
}, },
}); });
} else if (status === 'partial') { } else if (status === 'partial') {
// Partial payment - half the amount
const methods = ['gcash', 'cash']; const methods = ['gcash', 'cash'];
const method = methods[Math.floor(Math.random() * methods.length)]; const method = methods[Math.floor(Math.random() * methods.length)];
const paidDate = new Date(dueDate.getTime() - 86400000 * 2); const paidDate = new Date(dueDate.getTime() - 86400000 * 2);
const collector = i % 2 === 0 ? usersByEmail['collector@demo-isp.com'] : usersByEmail['tech@demo-isp.com'];
await prisma.payment.create({ await prisma.payment.create({
data: { data: {
tenantId: tenant.id, tenantId: tenant.id,
clientId: client.id, clientId: client.id,
invoiceId: invoice.id, invoiceId: invoice.id,
collectedById: users.technician.id, collectedById: collector.id,
amount: Math.round(amount / 2), amount: Math.round(amount / 2),
method, method,
referenceNo: method !== 'cash' ? `REF-${String(Math.floor(Math.random() * 99999)).padStart(5, '0')}` : null, referenceNo: method !== 'cash' ? `REF-${String(Math.floor(Math.random() * 99999)).padStart(5, '0')}` : null,