Seeds one TRACECOIN_BUNDLE package per role (100 Tracecoins / ₹250, placeholder pricing per your instruction) so the purchase flow (CreditsPage.tsx -> GET /api/packages, filtered client-side by role_key) has something to show instead of "No packages available for your role," and so create_order/verify_payment/invoice generation can actually be exercised end-to-end. Idempotent (WHERE NOT EXISTS guard) so it's safe against the custom db-migrate runner re-executing every file on every deploy. Adjust real pricing later via the existing admin CRUD (POST/PATCH /api/packages) — no new endpoint needed, it already works. Also fixes a unit bug introduced in the invoice wiring last commit: payments.amount_inr is already paise (copied straight from pricing_packages.price_inr, which is paise despite the name — PayU order creation divides it by 100 via paise_to_rupee_string), but the invoice line item multiplied it by 100 again, making every generated invoice show a 100x inflated amount.
28 lines
1.1 KiB
SQL
28 lines
1.1 KiB
SQL
-- Seed one purchasable Tracecoin package per role so the purchase flow
|
|
-- (CreditsPage.tsx -> GET /api/packages, filtered client-side by
|
|
-- role_key) has something to show instead of "No packages available for
|
|
-- your role." Placeholder pricing per user instruction: ₹250 flat
|
|
-- (25000 paise — pricing_packages.price_inr is paise despite the name,
|
|
-- see apps/payments/src/payu.rs::paise_to_rupee_string) for 100
|
|
-- Tracecoins, across every role. Adjust via the existing admin API
|
|
-- (POST/PATCH /api/packages) once real pricing is decided.
|
|
INSERT INTO pricing_packages (name, role_key, package_type, tracecoins_amount, price_inr, description, is_active)
|
|
SELECT 'Starter Pack', role_key, 'TRACECOIN_BUNDLE', 100, 25000, '100 Tracecoins', true
|
|
FROM (VALUES
|
|
('COMPANY'),
|
|
('CUSTOMER'),
|
|
('JOB_SEEKER'),
|
|
('PHOTOGRAPHER'),
|
|
('MAKEUP_ARTIST'),
|
|
('TUTOR'),
|
|
('DEVELOPER'),
|
|
('VIDEO_EDITOR'),
|
|
('GRAPHIC_DESIGNER'),
|
|
('SOCIAL_MEDIA_MANAGER'),
|
|
('FITNESS_TRAINER'),
|
|
('CATERING_SERVICES'),
|
|
('UGC_CONTENT_CREATOR')
|
|
) AS roles(role_key)
|
|
WHERE NOT EXISTS (
|
|
SELECT 1 FROM pricing_packages p WHERE p.role_key = roles.role_key
|
|
);
|