feat: add vendor optional fields and configuration hooks

- Implemented VendorOptionalFields component to handle optional vendor details (mobile, email, address) with validation.
- Created useCustomerConfig hook to load optional customer field settings from Sales configuration.
- Developed useProcurementConfig hook to manage Procurement configuration flags.
- Introduced accessConfigApi for managing access configuration settings.
- Added openingBalancesApi for handling opening balances operations.
- Created procurementConfigApi for managing procurement configuration settings.
- Implemented nav-routes for permission-based routing.
- Developed PDF generation for purchase orders with dynamic vendor and item details.
- Added purchase-order tax helpers for tax calculations and formatting.
- Defined types for opening balances and related operations.
This commit is contained in:
Dhananjaya99
2026-10-18 12:46:31 +05:30
parent c27db06880
commit e7b1f270a5
202 changed files with 99906 additions and 1894 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,88 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ERPCore.Migrations
{
/// <inheritdoc />
public partial class AddProcurementConfigAndVendorContact : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Address",
table: "vendors",
type: "varchar(500)",
maxLength: 500,
nullable: true,
collation: "utf8mb4_unicode_ci");
migrationBuilder.AddColumn<string>(
name: "Email",
table: "vendors",
type: "varchar(200)",
maxLength: 200,
nullable: true,
collation: "utf8mb4_unicode_ci");
migrationBuilder.AddColumn<string>(
name: "Mobile",
table: "vendors",
type: "varchar(20)",
maxLength: 20,
nullable: true,
collation: "utf8mb4_unicode_ci");
migrationBuilder.CreateTable(
name: "procurement_config",
columns: table => new
{
ConfigId = table.Column<int>(type: "int", nullable: false),
VendorContactMode = table.Column<string>(type: "varchar(10)", maxLength: 10, nullable: false, defaultValue: "None", collation: "utf8mb4_unicode_ci"),
VendorAddressEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
PoTaxEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
UpdatedBy = table.Column<int>(type: "int", nullable: true),
RowVersion = table.Column<uint>(type: "int unsigned", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_procurement_config", x => x.ConfigId);
table.CheckConstraint("ck_procurement_config_singleton", "`ConfigId` = 1");
table.ForeignKey(
name: "FK_procurement_config_users_UpdatedBy",
column: x => x.UpdatedBy,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
})
.Annotation("Relational:Collation", "utf8mb4_unicode_ci");
migrationBuilder.CreateIndex(
name: "IX_procurement_config_UpdatedBy",
table: "procurement_config",
column: "UpdatedBy");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "procurement_config");
migrationBuilder.DropColumn(
name: "Address",
table: "vendors");
migrationBuilder.DropColumn(
name: "Email",
table: "vendors");
migrationBuilder.DropColumn(
name: "Mobile",
table: "vendors");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ERPCore.Migrations
{
/// <inheritdoc />
public partial class AddPoLineTaxAmount : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "TaxAmount",
table: "po_lines",
type: "decimal(18,4)",
precision: 18,
scale: 4,
nullable: false,
defaultValue: 0m);
// Totals now sum the stored amount instead of recomputing qty x price x rate, so give any
// line that already carries a rate its amount (same rounding: half away from zero, 2 dp).
migrationBuilder.Sql("UPDATE po_lines SET TaxAmount = ROUND(Qty * UnitPrice * Tax, 2) WHERE Tax <> 0;");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "TaxAmount",
table: "po_lines");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,52 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ERPCore.Migrations
{
/// <inheritdoc />
public partial class AddPoApprovalsNav : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
table: "sub_nav_items",
columns: new[] { "SubNavItemId", "Code", "Href", "Icon", "Label", "NavItemId", "SortOrder" },
values: new object[] { 50, "procurement.po-approvals", "/dashboard/procurement/purchase-orders/approvals", null, "PO Approval Queue", 4, 6 });
migrationBuilder.InsertData(
table: "permissions",
columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" },
values: new object[] { 60, "NAV:procurement.po-approvals", null, 50 });
// Grant the new queue entry. Admin gets everything (the server only lets an Admin approve
// anyway); any other role that can already open Purchase Orders (permission 30) gets View.
// Idempotent, like the grants in AddDualApproval.
migrationBuilder.Sql("""
INSERT IGNORE INTO `role_permissions` (`RoleId`, `PermissionId`, `Actions`)
SELECT r.`RoleId`, 60, CASE WHEN LOWER(r.`Code`) = 'admin' THEN 31 ELSE 1 END
FROM `roles` r
WHERE LOWER(r.`Code`) = 'admin'
OR EXISTS (SELECT 1 FROM `role_permissions` rp
WHERE rp.`RoleId` = r.`RoleId` AND rp.`PermissionId` = 30);
""");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DELETE FROM `role_permissions` WHERE `PermissionId` = 60;");
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 60);
migrationBuilder.DeleteData(
table: "sub_nav_items",
keyColumn: "SubNavItemId",
keyValue: 50);
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,170 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ERPCore.Migrations
{
/// <inheritdoc />
public partial class AddOpeningBalances : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "opening_balance_runs",
columns: table => new
{
OpeningBalanceRunId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Kind = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false, collation: "utf8mb4_unicode_ci"),
OnceKey = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: true, collation: "utf8mb4_unicode_ci"),
CutoverDate = table.Column<DateOnly>(type: "date", nullable: false),
GlJournalNo = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: true, collation: "utf8mb4_unicode_ci"),
TotalAmount = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false),
Currency = table.Column<string>(type: "varchar(3)", maxLength: 3, nullable: false, collation: "utf8mb4_unicode_ci"),
PostedBy = table.Column<int>(type: "int", nullable: false),
PostedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_opening_balance_runs", x => x.OpeningBalanceRunId);
})
.Annotation("Relational:Collation", "utf8mb4_unicode_ci");
migrationBuilder.CreateTable(
name: "opening_balance_lines",
columns: table => new
{
OpeningBalanceLineId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
OpeningBalanceRunId = table.Column<int>(type: "int", nullable: false),
AccountCode = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false, collation: "utf8mb4_unicode_ci"),
AccountName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, collation: "utf8mb4_unicode_ci"),
Amount = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_opening_balance_lines", x => x.OpeningBalanceLineId);
table.ForeignKey(
name: "FK_opening_balance_lines_opening_balance_runs_OpeningBalanceRun~",
column: x => x.OpeningBalanceRunId,
principalTable: "opening_balance_runs",
principalColumn: "OpeningBalanceRunId",
onDelete: ReferentialAction.Cascade);
})
.Annotation("Relational:Collation", "utf8mb4_unicode_ci");
migrationBuilder.CreateTable(
name: "opening_stock_lines",
columns: table => new
{
OpeningStockLineId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
OpeningBalanceRunId = table.Column<int>(type: "int", nullable: false),
ItemId = table.Column<int>(type: "int", nullable: false),
WarehouseId = table.Column<int>(type: "int", nullable: false),
Qty = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false),
UnitCost = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false),
Value = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_opening_stock_lines", x => x.OpeningStockLineId);
table.ForeignKey(
name: "FK_opening_stock_lines_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_opening_stock_lines_opening_balance_runs_OpeningBalanceRunId",
column: x => x.OpeningBalanceRunId,
principalTable: "opening_balance_runs",
principalColumn: "OpeningBalanceRunId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_opening_stock_lines_warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
})
.Annotation("Relational:Collation", "utf8mb4_unicode_ci");
migrationBuilder.InsertData(
table: "sub_nav_items",
columns: new[] { "SubNavItemId", "Code", "Href", "Icon", "Label", "NavItemId", "SortOrder" },
values: new object[] { 51, "accounts.opening-balances", "/dashboard/accounts/opening-balances", null, "Opening Balances", 12, 7 });
migrationBuilder.InsertData(
table: "permissions",
columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" },
values: new object[] { 61, "NAV:accounts.opening-balances", null, 51 });
// Admin only: posting opening balances is a one-time ledger entry. Other roles can be granted it
// under Settings → Roles. Idempotent, like the other nav grants.
migrationBuilder.Sql("""
INSERT IGNORE INTO `role_permissions` (`RoleId`, `PermissionId`, `Actions`)
SELECT r.`RoleId`, 61, 31 FROM `roles` r WHERE LOWER(r.`Code`) = 'admin';
""");
migrationBuilder.CreateIndex(
name: "IX_opening_balance_lines_OpeningBalanceRunId",
table: "opening_balance_lines",
column: "OpeningBalanceRunId");
migrationBuilder.CreateIndex(
name: "IX_opening_balance_runs_Kind",
table: "opening_balance_runs",
column: "Kind");
migrationBuilder.CreateIndex(
name: "IX_opening_balance_runs_OnceKey",
table: "opening_balance_runs",
column: "OnceKey",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_opening_stock_lines_ItemId_WarehouseId",
table: "opening_stock_lines",
columns: new[] { "ItemId", "WarehouseId" });
migrationBuilder.CreateIndex(
name: "IX_opening_stock_lines_OpeningBalanceRunId",
table: "opening_stock_lines",
column: "OpeningBalanceRunId");
migrationBuilder.CreateIndex(
name: "IX_opening_stock_lines_WarehouseId",
table: "opening_stock_lines",
column: "WarehouseId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DELETE FROM `role_permissions` WHERE `PermissionId` = 61;");
migrationBuilder.DropTable(
name: "opening_balance_lines");
migrationBuilder.DropTable(
name: "opening_stock_lines");
migrationBuilder.DropTable(
name: "opening_balance_runs");
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 61);
migrationBuilder.DeleteData(
table: "sub_nav_items",
keyColumn: "SubNavItemId",
keyValue: 51);
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ERPCore.Migrations
{
/// <inheritdoc />
public partial class AddVendorFieldSwitches : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "VendorPaymentTermsEnabled",
table: "procurement_config",
type: "tinyint(1)",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn<bool>(
name: "VendorTaxRegEnabled",
table: "procurement_config",
type: "tinyint(1)",
nullable: false,
defaultValue: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "VendorPaymentTermsEnabled",
table: "procurement_config");
migrationBuilder.DropColumn(
name: "VendorTaxRegEnabled",
table: "procurement_config");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,129 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ERPCore.Migrations
{
/// <inheritdoc />
public partial class RolesOwnedByErp : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Level2RoleCodes",
table: "approval_config",
newName: "Level2RoleIds");
migrationBuilder.AlterColumn<Guid>(
name: "auth_role_id",
table: "roles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AddColumn<bool>(
name: "IsAdmin",
table: "roles",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "access_config",
columns: table => new
{
ConfigId = table.Column<int>(type: "int", nullable: false),
DefaultRoleId = table.Column<int>(type: "int", nullable: true),
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
UpdatedBy = table.Column<int>(type: "int", nullable: true),
RowVersion = table.Column<uint>(type: "int unsigned", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_access_config", x => x.ConfigId);
table.CheckConstraint("ck_access_config_singleton", "`ConfigId` = 1");
table.ForeignKey(
name: "FK_access_config_roles_DefaultRoleId",
column: x => x.DefaultRoleId,
principalTable: "roles",
principalColumn: "RoleId",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_access_config_users_UpdatedBy",
column: x => x.UpdatedBy,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
})
.Annotation("Relational:Collation", "utf8mb4_unicode_ci");
// ---- Data: the existing administrator role becomes THE administrator by flag, not by name.
migrationBuilder.Sql("UPDATE `roles` SET `IsAdmin` = 1 WHERE LOWER(`Code`) = 'admin';");
// ---- Data: "who may give the second approval" was a list of role CODES; it is now a list of role IDS
// (a rename can no longer break it). The renamed column still holds the codes — convert them in place.
// A code that matches no role simply drops out.
migrationBuilder.Sql("""
UPDATE `approval_config` c
SET c.`Level2RoleIds` = (
SELECT GROUP_CONCAT(r.`RoleId` ORDER BY r.`RoleId` SEPARATOR ',')
FROM `roles` r
WHERE FIND_IN_SET(LOWER(r.`Code`), LOWER(REPLACE(c.`Level2RoleIds`, ' ', ''))) > 0)
WHERE c.`Level2RoleIds` IS NOT NULL AND c.`Level2RoleIds` <> '';
""");
migrationBuilder.CreateIndex(
name: "IX_access_config_DefaultRoleId",
table: "access_config",
column: "DefaultRoleId");
migrationBuilder.CreateIndex(
name: "IX_access_config_UpdatedBy",
table: "access_config",
column: "UpdatedBy");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
// Turn the role ids back into codes before the column goes back to its old meaning.
migrationBuilder.Sql("""
UPDATE `approval_config` c
SET c.`Level2RoleIds` = (
SELECT GROUP_CONCAT(r.`Code` SEPARATOR ',')
FROM `roles` r
WHERE FIND_IN_SET(r.`RoleId`, REPLACE(c.`Level2RoleIds`, ' ', '')) > 0)
WHERE c.`Level2RoleIds` IS NOT NULL AND c.`Level2RoleIds` <> '';
""");
migrationBuilder.DropTable(
name: "access_config");
migrationBuilder.DropColumn(
name: "IsAdmin",
table: "roles");
migrationBuilder.RenameColumn(
name: "Level2RoleIds",
table: "approval_config",
newName: "Level2RoleCodes");
migrationBuilder.AlterColumn<Guid>(
name: "auth_role_id",
table: "roles",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,195 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace ERPCore.Migrations
{
/// <inheritdoc />
public partial class PermissionCoverage : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
table: "nav_items",
columns: new[] { "NavItemId", "Code", "Href", "Icon", "Label", "SortOrder" },
values: new object[,]
{
{ 15, "hrm", "/dashboard/hrm", null, "Human Resources", 15 },
{ 16, "sales-returns", "/dashboard/sales/sales-returns", null, "Sales Returns", 16 }
});
migrationBuilder.InsertData(
table: "permissions",
columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" },
values: new object[] { 71, "NAV:settings.notification-config", null, 24 });
migrationBuilder.InsertData(
table: "sub_nav_items",
columns: new[] { "SubNavItemId", "Code", "Href", "Icon", "Label", "NavItemId", "SortOrder" },
values: new object[] { 58, "settings.audit-logs", "/dashboard/settings/audit-logs", null, "Audit Log", 9, 5 });
migrationBuilder.InsertData(
table: "permissions",
columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" },
values: new object[,]
{
{ 62, "NAV:hrm", 15, null },
{ 63, "NAV:sales-returns", 16, null },
{ 70, "NAV:settings.audit-logs", null, 58 }
});
migrationBuilder.InsertData(
table: "sub_nav_items",
columns: new[] { "SubNavItemId", "Code", "Href", "Icon", "Label", "NavItemId", "SortOrder" },
values: new object[,]
{
{ 52, "hrm.employees", "/dashboard/hrm/employees", null, "Employees", 15, 1 },
{ 53, "hrm.attendance", "/dashboard/hrm/attendance", null, "Attendance", 15, 2 },
{ 54, "hrm.leave", "/dashboard/hrm/leave", null, "Leave", 15, 3 },
{ 55, "hrm.payroll", "/dashboard/hrm/payroll", null, "Payroll", 15, 4 },
{ 56, "hrm.reports", "/dashboard/hrm/reports", null, "Reports", 15, 5 },
{ 57, "hrm.settings", "/dashboard/hrm/settings", null, "HR Settings", 15, 6 }
});
migrationBuilder.InsertData(
table: "permissions",
columns: new[] { "PermissionId", "Code", "NavItemId", "SubNavItemId" },
values: new object[,]
{
{ 64, "NAV:hrm.employees", null, 52 },
{ 65, "NAV:hrm.attendance", null, 53 },
{ 66, "NAV:hrm.leave", null, 54 },
{ 67, "NAV:hrm.payroll", null, 55 },
{ 68, "NAV:hrm.reports", null, 56 },
{ 69, "NAV:hrm.settings", null, 57 }
});
// Grants. Idempotent (INSERT IGNORE on the (RoleId, PermissionId) key), and keyed on the role's IsAdmin flag,
// never on its code or name. Everything below is least-privilege: nobody who is not an administrator gets
// Human Resources, the audit log or notification config until an administrator grants it under Settings → Roles.
// (HRM used to be open to every signed-in user; this closes it.)
migrationBuilder.Sql("""
INSERT IGNORE INTO `role_permissions` (`RoleId`, `PermissionId`, `Actions`)
SELECT r.`RoleId`, p.`PermissionId`, 31
FROM `roles` r
JOIN `permissions` p ON p.`PermissionId` BETWEEN 62 AND 71
WHERE r.`IsAdmin` = 1;
""");
// Sales Returns used to ride on the Sales permission; it is its own sidebar entry now, so whoever could reach
// Sales (the module or any of its pages) keeps reaching Returns, with the same actions they hold on Sales.
migrationBuilder.Sql("""
INSERT IGNORE INTO `role_permissions` (`RoleId`, `PermissionId`, `Actions`)
SELECT rp.`RoleId`, 63, BIT_OR(rp.`Actions`)
FROM `role_permissions` rp
JOIN `permissions` p ON p.`PermissionId` = rp.`PermissionId`
WHERE p.`Code` = 'NAV:sales' OR p.`Code` LIKE 'NAV:sales.%'
GROUP BY rp.`RoleId`;
""");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DELETE FROM `role_permissions` WHERE `PermissionId` BETWEEN 62 AND 71;");
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 62);
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 63);
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 64);
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 65);
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 66);
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 67);
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 68);
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 69);
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 70);
migrationBuilder.DeleteData(
table: "permissions",
keyColumn: "PermissionId",
keyValue: 71);
migrationBuilder.DeleteData(
table: "nav_items",
keyColumn: "NavItemId",
keyValue: 16);
migrationBuilder.DeleteData(
table: "sub_nav_items",
keyColumn: "SubNavItemId",
keyValue: 52);
migrationBuilder.DeleteData(
table: "sub_nav_items",
keyColumn: "SubNavItemId",
keyValue: 53);
migrationBuilder.DeleteData(
table: "sub_nav_items",
keyColumn: "SubNavItemId",
keyValue: 54);
migrationBuilder.DeleteData(
table: "sub_nav_items",
keyColumn: "SubNavItemId",
keyValue: 55);
migrationBuilder.DeleteData(
table: "sub_nav_items",
keyColumn: "SubNavItemId",
keyValue: 56);
migrationBuilder.DeleteData(
table: "sub_nav_items",
keyColumn: "SubNavItemId",
keyValue: 57);
migrationBuilder.DeleteData(
table: "sub_nav_items",
keyColumn: "SubNavItemId",
keyValue: 58);
migrationBuilder.DeleteData(
table: "nav_items",
keyColumn: "NavItemId",
keyValue: 15);
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,95 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ERPCore.Migrations
{
/// <inheritdoc />
public partial class AddCustomerFieldSwitches : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "CustomerAddressEnabled",
table: "sales_config",
type: "tinyint(1)",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn<bool>(
name: "CustomerCityEnabled",
table: "sales_config",
type: "tinyint(1)",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn<bool>(
name: "CustomerCountryEnabled",
table: "sales_config",
type: "tinyint(1)",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn<bool>(
name: "CustomerCreditDaysEnabled",
table: "sales_config",
type: "tinyint(1)",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn<bool>(
name: "CustomerCreditLimitEnabled",
table: "sales_config",
type: "tinyint(1)",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn<bool>(
name: "CustomerEmailEnabled",
table: "sales_config",
type: "tinyint(1)",
nullable: false,
defaultValue: true);
migrationBuilder.AddColumn<bool>(
name: "CustomerPhoneEnabled",
table: "sales_config",
type: "tinyint(1)",
nullable: false,
defaultValue: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CustomerAddressEnabled",
table: "sales_config");
migrationBuilder.DropColumn(
name: "CustomerCityEnabled",
table: "sales_config");
migrationBuilder.DropColumn(
name: "CustomerCountryEnabled",
table: "sales_config");
migrationBuilder.DropColumn(
name: "CustomerCreditDaysEnabled",
table: "sales_config");
migrationBuilder.DropColumn(
name: "CustomerCreditLimitEnabled",
table: "sales_config");
migrationBuilder.DropColumn(
name: "CustomerEmailEnabled",
table: "sales_config");
migrationBuilder.DropColumn(
name: "CustomerPhoneEnabled",
table: "sales_config");
}
}
}
@@ -1,4 +1,4 @@
// <auto-generated />
// <auto-generated />
using System;
using ERPCore.Infra.Persistence;
using Microsoft.EntityFrameworkCore;
@@ -23,12 +23,42 @@ namespace ERPCore.Migrations
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
modelBuilder.Entity("ERPCore.Domain.Entities.AccessConfig", b =>
{
b.Property<int>("ConfigId")
.HasColumnType("int");
b.Property<int?>("DefaultRoleId")
.HasColumnType("int");
b.Property<uint>("RowVersion")
.IsConcurrencyToken()
.HasColumnType("int unsigned");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime(6)");
b.Property<int?>("UpdatedBy")
.HasColumnType("int");
b.HasKey("ConfigId");
b.HasIndex("DefaultRoleId");
b.HasIndex("UpdatedBy");
b.ToTable("access_config", null, t =>
{
t.HasCheckConstraint("ck_access_config_singleton", "`ConfigId` = 1");
});
});
modelBuilder.Entity("ERPCore.Domain.Entities.ApprovalConfig", b =>
{
b.Property<int>("ApprovalConfigId")
.HasColumnType("int");
b.Property<string>("Level2RoleCodes")
b.Property<string>("Level2RoleIds")
.HasMaxLength(500)
.HasColumnType("varchar(500)");
@@ -3382,6 +3412,24 @@ namespace ERPCore.Migrations
Label = "Production",
SortOrder = 14,
Status = "Active"
},
new
{
NavItemId = 15,
Code = "hrm",
Href = "/dashboard/hrm",
Label = "Human Resources",
SortOrder = 15,
Status = "Active"
},
new
{
NavItemId = 16,
Code = "sales-returns",
Href = "/dashboard/sales/sales-returns",
Label = "Sales Returns",
SortOrder = 16,
Status = "Active"
});
});
@@ -3556,6 +3604,127 @@ namespace ERPCore.Migrations
b.ToTable("number_sequences", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.OpeningBalanceLine", b =>
{
b.Property<int>("OpeningBalanceLineId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("OpeningBalanceLineId"));
b.Property<string>("AccountCode")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<string>("AccountName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<decimal>("Amount")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
b.Property<int>("OpeningBalanceRunId")
.HasColumnType("int");
b.HasKey("OpeningBalanceLineId");
b.HasIndex("OpeningBalanceRunId");
b.ToTable("opening_balance_lines", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.OpeningBalanceRun", b =>
{
b.Property<int>("OpeningBalanceRunId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("OpeningBalanceRunId"));
b.Property<string>("Currency")
.IsRequired()
.HasMaxLength(3)
.HasColumnType("varchar(3)");
b.Property<DateOnly>("CutoverDate")
.HasColumnType("date");
b.Property<string>("GlJournalNo")
.HasMaxLength(30)
.HasColumnType("varchar(30)");
b.Property<string>("Kind")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<string>("OnceKey")
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<DateTime>("PostedAt")
.HasColumnType("datetime(6)");
b.Property<int>("PostedBy")
.HasColumnType("int");
b.Property<decimal>("TotalAmount")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
b.HasKey("OpeningBalanceRunId");
b.HasIndex("Kind");
b.HasIndex("OnceKey")
.IsUnique();
b.ToTable("opening_balance_runs", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.OpeningStockLine", b =>
{
b.Property<int>("OpeningStockLineId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("OpeningStockLineId"));
b.Property<int>("ItemId")
.HasColumnType("int");
b.Property<int>("OpeningBalanceRunId")
.HasColumnType("int");
b.Property<decimal>("Qty")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
b.Property<decimal>("UnitCost")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
b.Property<decimal>("Value")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
b.Property<int>("WarehouseId")
.HasColumnType("int");
b.HasKey("OpeningStockLineId");
b.HasIndex("OpeningBalanceRunId");
b.HasIndex("WarehouseId");
b.HasIndex("ItemId", "WarehouseId");
b.ToTable("opening_stock_lines", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b =>
{
b.Property<int>("PayrollLineId")
@@ -4226,6 +4395,78 @@ namespace ERPCore.Migrations
PermissionId = 59,
Code = "NAV:settings.approvals",
SubNavItemId = 49
},
new
{
PermissionId = 60,
Code = "NAV:procurement.po-approvals",
SubNavItemId = 50
},
new
{
PermissionId = 61,
Code = "NAV:accounts.opening-balances",
SubNavItemId = 51
},
new
{
PermissionId = 62,
Code = "NAV:hrm",
NavItemId = 15
},
new
{
PermissionId = 63,
Code = "NAV:sales-returns",
NavItemId = 16
},
new
{
PermissionId = 64,
Code = "NAV:hrm.employees",
SubNavItemId = 52
},
new
{
PermissionId = 65,
Code = "NAV:hrm.attendance",
SubNavItemId = 53
},
new
{
PermissionId = 66,
Code = "NAV:hrm.leave",
SubNavItemId = 54
},
new
{
PermissionId = 67,
Code = "NAV:hrm.payroll",
SubNavItemId = 55
},
new
{
PermissionId = 68,
Code = "NAV:hrm.reports",
SubNavItemId = 56
},
new
{
PermissionId = 69,
Code = "NAV:hrm.settings",
SubNavItemId = 57
},
new
{
PermissionId = 70,
Code = "NAV:settings.audit-logs",
SubNavItemId = 58
},
new
{
PermissionId = 71,
Code = "NAV:settings.notification-config",
SubNavItemId = 24
});
});
@@ -4255,6 +4496,12 @@ namespace ERPCore.Migrations
.HasPrecision(9, 4)
.HasColumnType("decimal(9,4)");
b.Property<decimal>("TaxAmount")
.ValueGeneratedOnAdd()
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)")
.HasDefaultValue(0m);
b.Property<decimal>("UnitPrice")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
@@ -4398,6 +4645,58 @@ namespace ERPCore.Migrations
b.ToTable("price_adjustment_lines", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.ProcurementConfig", b =>
{
b.Property<int>("ConfigId")
.HasColumnType("int");
b.Property<bool>("PoTaxEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false);
b.Property<uint>("RowVersion")
.IsConcurrencyToken()
.HasColumnType("int unsigned");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime(6)");
b.Property<int?>("UpdatedBy")
.HasColumnType("int");
b.Property<bool>("VendorAddressEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false);
b.Property<string>("VendorContactMode")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(10)
.HasColumnType("varchar(10)")
.HasDefaultValue("None");
b.Property<bool>("VendorPaymentTermsEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.Property<bool>("VendorTaxRegEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.HasKey("ConfigId");
b.HasIndex("UpdatedBy");
b.ToTable("procurement_config", null, t =>
{
t.HasCheckConstraint("ck_procurement_config_singleton", "`ConfigId` = 1");
});
});
modelBuilder.Entity("ERPCore.Domain.Entities.ProductConfig", b =>
{
b.Property<int>("ConfigId")
@@ -5121,7 +5420,7 @@ namespace ERPCore.Migrations
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("RoleId"));
b.Property<Guid>("AuthRoleId")
b.Property<Guid?>("AuthRoleId")
.HasColumnType("char(36)")
.HasColumnName("auth_role_id");
@@ -5133,6 +5432,11 @@ namespace ERPCore.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<bool>("IsAdmin")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false);
b.Property<bool>("IsSystemRole")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
@@ -5530,6 +5834,41 @@ namespace ERPCore.Migrations
b.Property<int?>("CashCustomerId")
.HasColumnType("int");
b.Property<bool>("CustomerAddressEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.Property<bool>("CustomerCityEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.Property<bool>("CustomerCountryEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.Property<bool>("CustomerCreditDaysEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.Property<bool>("CustomerCreditLimitEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.Property<bool>("CustomerEmailEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.Property<bool>("CustomerPhoneEnabled")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.Property<int?>("DefaultWarehouseId")
.HasColumnType("int");
@@ -7403,6 +7742,16 @@ namespace ERPCore.Migrations
Status = "Active"
},
new
{
SubNavItemId = 50,
Code = "procurement.po-approvals",
Href = "/dashboard/procurement/purchase-orders/approvals",
Label = "PO Approval Queue",
NavItemId = 4,
SortOrder = 6,
Status = "Active"
},
new
{
SubNavItemId = 20,
Code = "procurement.purchase-returns",
@@ -7553,6 +7902,16 @@ namespace ERPCore.Migrations
Status = "Active"
},
new
{
SubNavItemId = 51,
Code = "accounts.opening-balances",
Href = "/dashboard/accounts/opening-balances",
Label = "Opening Balances",
NavItemId = 12,
SortOrder = 7,
Status = "Active"
},
new
{
SubNavItemId = 27,
Code = "production.templates",
@@ -7661,6 +8020,76 @@ namespace ERPCore.Migrations
NavItemId = 6,
SortOrder = 8,
Status = "Active"
},
new
{
SubNavItemId = 52,
Code = "hrm.employees",
Href = "/dashboard/hrm/employees",
Label = "Employees",
NavItemId = 15,
SortOrder = 1,
Status = "Active"
},
new
{
SubNavItemId = 53,
Code = "hrm.attendance",
Href = "/dashboard/hrm/attendance",
Label = "Attendance",
NavItemId = 15,
SortOrder = 2,
Status = "Active"
},
new
{
SubNavItemId = 54,
Code = "hrm.leave",
Href = "/dashboard/hrm/leave",
Label = "Leave",
NavItemId = 15,
SortOrder = 3,
Status = "Active"
},
new
{
SubNavItemId = 55,
Code = "hrm.payroll",
Href = "/dashboard/hrm/payroll",
Label = "Payroll",
NavItemId = 15,
SortOrder = 4,
Status = "Active"
},
new
{
SubNavItemId = 56,
Code = "hrm.reports",
Href = "/dashboard/hrm/reports",
Label = "Reports",
NavItemId = 15,
SortOrder = 5,
Status = "Active"
},
new
{
SubNavItemId = 57,
Code = "hrm.settings",
Href = "/dashboard/hrm/settings",
Label = "HR Settings",
NavItemId = 15,
SortOrder = 6,
Status = "Active"
},
new
{
SubNavItemId = 58,
Code = "settings.audit-logs",
Href = "/dashboard/settings/audit-logs",
Label = "Audit Log",
NavItemId = 9,
SortOrder = 5,
Status = "Active"
});
});
@@ -8005,6 +8434,10 @@ namespace ERPCore.Migrations
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("VendorId"));
b.Property<string>("Address")
.HasMaxLength(500)
.HasColumnType("varchar(500)");
b.Property<int>("BranchId")
.HasColumnType("int");
@@ -8023,6 +8456,14 @@ namespace ERPCore.Migrations
.HasColumnType("varchar(3)")
.HasDefaultValue("LKR");
b.Property<string>("Email")
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<string>("Mobile")
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
@@ -8334,6 +8775,23 @@ namespace ERPCore.Migrations
b.ToTable("hr_work_shifts", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.AccessConfig", b =>
{
b.HasOne("ERPCore.Domain.Entities.Role", "DefaultRole")
.WithMany()
.HasForeignKey("DefaultRoleId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser")
.WithMany()
.HasForeignKey("UpdatedBy")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("DefaultRole");
b.Navigation("UpdatedByUser");
});
modelBuilder.Entity("ERPCore.Domain.Entities.AttendanceRecord", b =>
{
b.HasOne("ERPCore.Domain.Entities.AttendanceUploadBatch", "AttendanceUploadBatch")
@@ -9127,6 +9585,44 @@ namespace ERPCore.Migrations
b.Navigation("Branch");
});
modelBuilder.Entity("ERPCore.Domain.Entities.OpeningBalanceLine", b =>
{
b.HasOne("ERPCore.Domain.Entities.OpeningBalanceRun", "Run")
.WithMany("Lines")
.HasForeignKey("OpeningBalanceRunId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Run");
});
modelBuilder.Entity("ERPCore.Domain.Entities.OpeningStockLine", b =>
{
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany()
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.OpeningBalanceRun", "Run")
.WithMany("StockLines")
.HasForeignKey("OpeningBalanceRunId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
.WithMany()
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Item");
b.Navigation("Run");
b.Navigation("Warehouse");
});
modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b =>
{
b.HasOne("ERPCore.Domain.Entities.Employee", "Employee")
@@ -9259,6 +9755,16 @@ namespace ERPCore.Migrations
b.Navigation("PriceAdjustment");
});
modelBuilder.Entity("ERPCore.Domain.Entities.ProcurementConfig", b =>
{
b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser")
.WithMany()
.HasForeignKey("UpdatedBy")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("UpdatedByUser");
});
modelBuilder.Entity("ERPCore.Domain.Entities.ProductConfig", b =>
{
b.HasOne("ERPCore.Domain.Entities.User", "UpdatedByUser")
@@ -10693,6 +11199,13 @@ namespace ERPCore.Migrations
b.Navigation("Modules");
});
modelBuilder.Entity("ERPCore.Domain.Entities.OpeningBalanceRun", b =>
{
b.Navigation("Lines");
b.Navigation("StockLines");
});
modelBuilder.Entity("ERPCore.Domain.Entities.PayrollLine", b =>
{
b.Navigation("Components");