feat: implement customer profile management and business application features
- Added customer profile controller with endpoints for retrieving, updating, and deactivating user profiles. - Introduced address model and routes for managing user addresses. - Created business application model and service for handling business applications, including approval and rejection processes. - Developed business contact and credit account models to support business customer functionalities. - Implemented settlement term model for managing payment terms. - Added email templates for business application notifications (approved, rejected, received, and status changes). - Enhanced validation schemas for customer and business inputs to ensure data integrity. - Created unit tests for business application service and validation schemas to ensure functionality and correctness. - Added migration scripts to set up new database tables and columns for customer and business features.
This commit is contained in:
@@ -21,7 +21,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
},
|
||||
businessRegistrationNumber: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
allowNull: false, unique: true,
|
||||
},
|
||||
businessType: {
|
||||
type: DataTypes.STRING,
|
||||
@@ -47,6 +47,14 @@ module.exports = (sequelize, DataTypes) => {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
},
|
||||
legalName: DataTypes.STRING,
|
||||
taxNumber: DataTypes.STRING,
|
||||
website: DataTypes.STRING,
|
||||
partnerId: { type: DataTypes.STRING, allowNull: false, unique: true },
|
||||
status: { type: DataTypes.ENUM("ACTIVE", "SUSPENDED", "CLOSED"), allowNull: false, defaultValue: "ACTIVE" },
|
||||
approvedAt: { type: DataTypes.DATE, allowNull: false },
|
||||
approvedBy: { type: DataTypes.STRING, allowNull: false },
|
||||
settlement_term_id: { type: DataTypes.STRING, allowNull: true },
|
||||
},
|
||||
{
|
||||
tableName: "business_customers",
|
||||
@@ -59,6 +67,10 @@ module.exports = (sequelize, DataTypes) => {
|
||||
foreignKey: "user_id",
|
||||
as: "user",
|
||||
});
|
||||
BusinessCustomer.hasMany(db.BusinessContact, { foreignKey: "business_profile_id", as: "contacts" });
|
||||
BusinessCustomer.hasMany(db.Address, { foreignKey: "business_profile_id", as: "addresses" });
|
||||
BusinessCustomer.hasOne(db.BusinessCreditAccount, { foreignKey: "business_profile_id", as: "creditAccount" });
|
||||
BusinessCustomer.belongsTo(db.SettlementTerm, { foreignKey: "settlement_term_id", as: "settlementTerm" });
|
||||
};
|
||||
|
||||
return BusinessCustomer;
|
||||
|
||||
Reference in New Issue
Block a user