Major Features Added: - Complete Plugin Architecture System with financial plugin - Multi-currency support with exchange rates - Course type system (online, classroom, hybrid) - Attendance tracking and QR code scanning - Classroom sessions management - Course sections and content management - Professional video player with authentication - Secure media serving system - Shopping cart and checkout system - Financial dashboard and earnings tracking - Trainee progress tracking - User notes and assignments system Backend Infrastructure: - Plugin loader and registry system - Multi-currency database models - Secure media middleware - Course access middleware - Financial plugin with payment processing - Database migrations for new features - API endpoints for all new functionality Frontend Components: - Course management interface - Content creation and editing - Section management with drag-and-drop - Professional video player - QR scanner for attendance - Shopping cart and checkout flow - Financial dashboard - Plugin management interface - Trainee details and progress views This represents a major evolution of CourseWorx from a basic LMS to a comprehensive educational platform with plugin architecture.
76 lines
2.8 KiB
JavaScript
76 lines
2.8 KiB
JavaScript
/**
|
|
* Financial Plugin Models Index
|
|
*
|
|
* This file initializes all financial plugin models with Sequelize
|
|
* and sets up their associations.
|
|
*/
|
|
|
|
const { sequelize } = require('../../../config/database');
|
|
const { User, Course } = require('../../../models');
|
|
|
|
// Initialize financial plugin models
|
|
const Cart = require('./Cart')(sequelize);
|
|
const Order = require('./Order')(sequelize);
|
|
const OrderItem = require('./OrderItem')(sequelize);
|
|
const Coupon = require('./Coupon')(sequelize);
|
|
const Transaction = require('./Transaction')(sequelize);
|
|
const Payout = require('./Payout')(sequelize);
|
|
|
|
// Currency and exchange rate models
|
|
const Currency = require('./Currency');
|
|
const ExchangeRate = require('./ExchangeRate');
|
|
const ExchangeRateHistory = require('./ExchangeRateHistory');
|
|
const CourseCurrency = require('./CourseCurrency');
|
|
|
|
// Set up associations
|
|
// Cart associations
|
|
Cart.belongsTo(User, { as: 'user', foreignKey: 'userId' });
|
|
|
|
// Order associations
|
|
Order.belongsTo(User, { as: 'user', foreignKey: 'userId' });
|
|
Order.belongsTo(Coupon, { as: 'coupon', foreignKey: 'couponId' });
|
|
Order.hasMany(OrderItem, { as: 'items', foreignKey: 'orderId' });
|
|
Order.hasMany(Transaction, { as: 'transactions', foreignKey: 'orderId' });
|
|
Order.hasMany(Payout, { as: 'payouts', foreignKey: 'orderId' });
|
|
|
|
// OrderItem associations
|
|
OrderItem.belongsTo(Order, { as: 'order', foreignKey: 'orderId' });
|
|
OrderItem.belongsTo(Course, { as: 'course', foreignKey: 'courseId' });
|
|
|
|
// Coupon associations
|
|
Coupon.belongsTo(User, { as: 'creator', foreignKey: 'createdBy' });
|
|
|
|
// Transaction associations
|
|
Transaction.belongsTo(Order, { as: 'order', foreignKey: 'orderId' });
|
|
|
|
// Payout associations
|
|
Payout.belongsTo(User, { as: 'trainer', foreignKey: 'trainerId' });
|
|
Payout.belongsTo(Order, { as: 'order', foreignKey: 'orderId' });
|
|
|
|
// Currency associations
|
|
ExchangeRate.belongsTo(Currency, { as: 'fromCurrency', foreignKey: 'fromCurrencyId' });
|
|
ExchangeRate.belongsTo(Currency, { as: 'toCurrency', foreignKey: 'toCurrencyId' });
|
|
ExchangeRate.belongsTo(User, { as: 'creator', foreignKey: 'createdBy' });
|
|
|
|
// Exchange rate history associations
|
|
ExchangeRateHistory.belongsTo(ExchangeRate, { as: 'exchangeRate', foreignKey: 'exchangeRateId' });
|
|
ExchangeRateHistory.belongsTo(Currency, { as: 'fromCurrency', foreignKey: 'fromCurrencyId' });
|
|
ExchangeRateHistory.belongsTo(Currency, { as: 'toCurrency', foreignKey: 'toCurrencyId' });
|
|
ExchangeRateHistory.belongsTo(User, { as: 'changer', foreignKey: 'changedBy' });
|
|
|
|
// Course currency associations
|
|
CourseCurrency.belongsTo(Course, { as: 'course', foreignKey: 'courseId' });
|
|
CourseCurrency.belongsTo(Currency, { as: 'baseCurrency', foreignKey: 'baseCurrencyId' });
|
|
|
|
module.exports = {
|
|
Cart,
|
|
Order,
|
|
OrderItem,
|
|
Coupon,
|
|
Transaction,
|
|
Payout,
|
|
Currency,
|
|
ExchangeRate,
|
|
ExchangeRateHistory,
|
|
CourseCurrency
|
|
};
|