alexanderaw commited on
Commit
abb6d07
·
verified ·
1 Parent(s): 98e1fc9

use common record in "Completed Records Comparison (File 3 vs File 2)" result, check total number of the column "M5" not equal to "Y", and allow to download the excel to cross check

Browse files
Files changed (1) hide show
  1. index.html +94 -6
index.html CHANGED
@@ -387,8 +387,38 @@
387
  </button>
388
  </div>
389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
  <!-- Completion Date Monthly Breakdown Section -->
391
- <div class="bg-amber-50 border border-amber-200 rounded-xl p-6 mb-6">
392
  <div class="flex items-center justify-center mb-4">
393
  <i data-feather="calendar" class="w-6 h-6 text-amber-600 mr-2"></i>
394
  <h3 class="text-lg font-semibold text-amber-700">Completion Date Monthly Breakdown (Common Records)</h3>
@@ -804,9 +834,11 @@ if (!file1Data || !file2Data) return;
804
 
805
  // Call M5 comparison function
806
  compareM5WithFile2();
807
- }
808
 
809
- // Function to compare M5 (Y) records from File 3 with File 2
 
 
 
810
  function compareM5WithFile2() {
811
  if (!filteredFile3Data || !file2Data) return;
812
 
@@ -878,8 +910,8 @@ if (!file1Data || !file2Data) return;
878
  document.getElementById('m5-vs-f2-unique-file2-count').textContent = m5UniqueToFile2.size;
879
  // Enable download button
880
  document.getElementById('download-m5-vs-f2-btn').disabled = false;
881
-
882
- // Process completion date breakdown for common records
883
  processCompletionDateBreakdown(m5Common, m5File3DataMap);
884
  }
885
  // Function to process first module date breakdown for common records
@@ -1054,7 +1086,6 @@ const monthCounts = new Map();
1054
  // Enable download button if there's data
1055
  document.getElementById('download-completion-date-btn').disabled = sortedMonths.length === 0;
1056
  }
1057
-
1058
  // Download completion date breakdown
1059
  document.getElementById('download-completion-date-btn').addEventListener('click', function() {
1060
  if (!window.completionDateBreakdownData || window.completionDateBreakdownData.length === 0) return;
@@ -1103,6 +1134,62 @@ const monthCounts = new Map();
1103
  // Export to file
1104
  XLSX.writeFile(wb, "completion_date_breakdown.xlsx");
1105
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1106
  // Download filtered File 3
1107
  document.getElementById('download-file3-btn').addEventListener('click', function() {
1108
  if (!filteredFile3Data || filteredFile3Data.length === 0) return;
@@ -1739,6 +1826,7 @@ const monthCounts = new Map();
1739
  document.getElementById('download-f3-vs-f2-btn').disabled = true;
1740
  document.getElementById('download-first-module-date-btn').disabled = true;
1741
  document.getElementById('download-m5-vs-f2-btn').disabled = true;
 
1742
  // Download M5 (Y) vs File 2 comparison
1743
  document.getElementById('download-m5-vs-f2-btn').addEventListener('click', function() {
1744
  if (!filteredFile3Data || !file2Data) return;
 
387
  </button>
388
  </div>
389
 
390
+ <!-- M5 Not Equal to Y for Common Records Section -->
391
+ <div class="bg-slate-50 border border-slate-200 rounded-xl p-6 mb-6">
392
+ <div class="flex items-center justify-center mb-4">
393
+ <i data-feather="alert-circle" class="w-6 h-6 text-slate-600 mr-2"></i>
394
+ <h3 class="text-lg font-semibold text-slate-700">M5 ≠ "Y" in Common Records (Completed)</h3>
395
+ </div>
396
+ <p class="text-center text-slate-600 text-sm mb-4">Checking common records from Completed comparison where M5 is not equal to "Y"</p>
397
+
398
+ <div class="grid md:grid-cols-2 gap-4">
399
+ <div class="bg-white rounded-lg p-4 text-center border border-slate-200">
400
+ <div class="text-2xl font-bold text-slate-600 mb-1" id="common-m5-not-y-count">0</div>
401
+ <div class="text-sm text-slate-700 font-medium">M5 ≠ "Y" Records</div>
402
+ <div class="text-xs text-slate-500 mt-1">Common records with M5 not equal to Y</div>
403
+ </div>
404
+ <div class="bg-emerald-50 border border-emerald-200 rounded-lg p-4 text-center">
405
+ <div class="text-2xl font-bold text-emerald-600 mb-1" id="common-m5-y-count">0</div>
406
+ <div class="text-sm text-emerald-700 font-medium">M5 = "Y" Records</div>
407
+ <div class="text-xs text-emerald-500 mt-1">Common records with M5 equal to Y</div>
408
+ </div>
409
+ </div>
410
+ </div>
411
+
412
+ <!-- Download Button for M5 Not Equal to Y in Common Records -->
413
+ <div class="text-center mb-6">
414
+ <button id="download-common-m5-not-y-btn" class="bg-slate-500 hover:bg-slate-600 text-white px-6 py-2 rounded-lg font-medium transition-colors inline-flex items-center" disabled>
415
+ <i data-feather="download" class="w-4 h-4 mr-2"></i>
416
+ Download M5 ≠ "Y" in Common Records
417
+ </button>
418
+ </div>
419
+
420
  <!-- Completion Date Monthly Breakdown Section -->
421
+ <div class="bg-amber-50 border border-amber-200 rounded-xl p-6 mb-6">
422
  <div class="flex items-center justify-center mb-4">
423
  <i data-feather="calendar" class="w-6 h-6 text-amber-600 mr-2"></i>
424
  <h3 class="text-lg font-semibold text-amber-700">Completion Date Monthly Breakdown (Common Records)</h3>
 
834
 
835
  // Call M5 comparison function
836
  compareM5WithFile2();
 
837
 
838
+ // Process M5 not equal to Y for common records
839
+ processM5NotYInCommonRecords(common, file3DataMap);
840
+ }
841
+ // Function to compare M5 (Y) records from File 3 with File 2
842
  function compareM5WithFile2() {
843
  if (!filteredFile3Data || !file2Data) return;
844
 
 
910
  document.getElementById('m5-vs-f2-unique-file2-count').textContent = m5UniqueToFile2.size;
911
  // Enable download button
912
  document.getElementById('download-m5-vs-f2-btn').disabled = false;
913
+ document.getElementById('download-common-m5-not-y-btn').disabled = window.commonM5NotYRecords && window.commonM5NotYRecords.length > 0 ? false : true;
914
+ // Process completion date breakdown for common records
915
  processCompletionDateBreakdown(m5Common, m5File3DataMap);
916
  }
917
  // Function to process first module date breakdown for common records
 
1086
  // Enable download button if there's data
1087
  document.getElementById('download-completion-date-btn').disabled = sortedMonths.length === 0;
1088
  }
 
1089
  // Download completion date breakdown
1090
  document.getElementById('download-completion-date-btn').addEventListener('click', function() {
1091
  if (!window.completionDateBreakdownData || window.completionDateBreakdownData.length === 0) return;
 
1134
  // Export to file
1135
  XLSX.writeFile(wb, "completion_date_breakdown.xlsx");
1136
  });
1137
+
1138
+ // Function to process M5 not equal to Y for common records
1139
+ function processM5NotYInCommonRecords(commonSet, dataMap) {
1140
+ let m5NotYCount = 0;
1141
+ let m5YCount = 0;
1142
+ const m5NotYRecords = [];
1143
+
1144
+ commonSet.forEach(cna => {
1145
+ const row = dataMap.get(cna);
1146
+ if (row) {
1147
+ const m5Value = row['M5'] || row['m5'] || row['M5_STATUS'] || row.m5;
1148
+ let isM5Y = false;
1149
+
1150
+ if (m5Value && typeof m5Value === 'string') {
1151
+ const m5Trimmed = m5Value.toString().trim().toUpperCase();
1152
+ if (m5Trimmed === 'Y') {
1153
+ m5YCount++;
1154
+ isM5Y = true;
1155
+ }
1156
+ }
1157
+
1158
+ if (!isM5Y) {
1159
+ m5NotYCount++;
1160
+ m5NotYRecords.push({
1161
+ ...row,
1162
+ Status: "M5 not equal to Y"
1163
+ });
1164
+ }
1165
+ }
1166
+ });
1167
+
1168
+ // Update UI
1169
+ document.getElementById('common-m5-not-y-count').textContent = m5NotYCount;
1170
+ document.getElementById('common-m5-y-count').textContent = m5YCount;
1171
+
1172
+ // Store data for download
1173
+ window.commonM5NotYRecords = m5NotYRecords;
1174
+
1175
+ // Enable download button if there's data
1176
+ document.getElementById('download-common-m5-not-y-btn').disabled = m5NotYRecords.length === 0;
1177
+ }
1178
+
1179
+ // Download M5 not equal to Y in common records
1180
+ document.getElementById('download-common-m5-not-y-btn').addEventListener('click', function() {
1181
+ if (!window.commonM5NotYRecords || window.commonM5NotYRecords.length === 0) return;
1182
+
1183
+ // Create worksheet from data
1184
+ const ws = XLSX.utils.json_to_sheet(window.commonM5NotYRecords);
1185
+
1186
+ // Create workbook and add worksheet
1187
+ const wb = XLSX.utils.book_new();
1188
+ XLSX.utils.book_append_sheet(wb, ws, "M5 Not Y in Common Records");
1189
+
1190
+ // Export to file
1191
+ XLSX.writeFile(wb, "common_records_m5_not_y.xlsx");
1192
+ });
1193
  // Download filtered File 3
1194
  document.getElementById('download-file3-btn').addEventListener('click', function() {
1195
  if (!filteredFile3Data || filteredFile3Data.length === 0) return;
 
1826
  document.getElementById('download-f3-vs-f2-btn').disabled = true;
1827
  document.getElementById('download-first-module-date-btn').disabled = true;
1828
  document.getElementById('download-m5-vs-f2-btn').disabled = true;
1829
+ document.getElementById('download-common-m5-not-y-btn').disabled = true;
1830
  // Download M5 (Y) vs File 2 comparison
1831
  document.getElementById('download-m5-vs-f2-btn').addEventListener('click', function() {
1832
  if (!filteredFile3Data || !file2Data) return;