修正
This commit is contained in:
@@ -1731,9 +1731,9 @@
|
||||
// 年月を解析
|
||||
const [startYear, startMonth] = startYM.split("-").map(Number);
|
||||
const endYM = document.getElementById("voucherEndYearMonth").value;
|
||||
const [endYear, endMonth] = endYM
|
||||
? endYM.split("-").map(Number)
|
||||
: [startYear, startMonth];
|
||||
const endParts = endYM ? endYM.split("-").map(Number) : null;
|
||||
const endYear = endParts ? endParts[0] : null;
|
||||
const endMonth = endParts ? endParts[1] : null;
|
||||
|
||||
const voucherType = document.querySelector(
|
||||
"input[name='voucherType']:checked",
|
||||
@@ -1751,6 +1751,8 @@
|
||||
format: "preview",
|
||||
};
|
||||
|
||||
console.log("送信ペイロード:", JSON.stringify(payload, null, 2));
|
||||
|
||||
const response = await fetch(`${API_BASE}/payroll/vouchers/export`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -1758,6 +1760,7 @@
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
console.log("レスポンス:", result);
|
||||
|
||||
if (!result.has_data) {
|
||||
alert(result.message || "データが見つかりません");
|
||||
@@ -1845,9 +1848,8 @@
|
||||
|
||||
const generationDate = new Date().toLocaleDateString("ja-JP");
|
||||
|
||||
// グループ化: 従業員ごと、年月ごと
|
||||
let currentEmployeeId = null;
|
||||
let currentYearMonth = null;
|
||||
// グループ化: 従業員ごと、年月ごと、給与/賞与ごと
|
||||
let currentKey = null;
|
||||
let pageOpen = false;
|
||||
|
||||
if (result.summary && Array.isArray(result.summary)) {
|
||||
@@ -1864,16 +1866,15 @@
|
||||
// 給与データの処理
|
||||
salaries.forEach((salary) => {
|
||||
const salaryYearMonth = `${salary.payroll_year}-${salary.payroll_month}`;
|
||||
const currentKey_new = `${emp.employee_id}-${salaryYearMonth}-salary`;
|
||||
const paymentDate = `${salary.payroll_year}年${String(salary.payroll_month).padStart(2, "0")}月${getLastDayOfMonth(salary.payroll_year, salary.payroll_month)}日`;
|
||||
if (
|
||||
currentEmployeeId !== emp.employee_id ||
|
||||
currentYearMonth !== salaryYearMonth
|
||||
) {
|
||||
|
||||
// 新しいキーが異なる場合は新しいページを開く
|
||||
if (currentKey !== currentKey_new) {
|
||||
if (pageOpen) {
|
||||
printHtml += "</div>";
|
||||
}
|
||||
currentEmployeeId = emp.employee_id;
|
||||
currentYearMonth = salaryYearMonth;
|
||||
currentKey = currentKey_new;
|
||||
printHtml += '<div class="page">';
|
||||
printHtml += `<div style="font-size: 11px; color: #999; margin-bottom: 10px; text-align: right;">帳票生成日: ${generationDate}</div>`;
|
||||
pageOpen = true;
|
||||
@@ -1978,16 +1979,15 @@
|
||||
// 賞与データの処理
|
||||
bonuses.forEach((bonus) => {
|
||||
const bonusYearMonth = `${bonus.bonus_year}-${bonus.bonus_month}`;
|
||||
const currentKey_new = `${emp.employee_id}-${bonusYearMonth}-bonus`;
|
||||
const bonusPaymentDate = `${bonus.bonus_year}年${String(bonus.bonus_month).padStart(2, "0")}月${getLastDayOfMonth(bonus.bonus_year, bonus.bonus_month)}日`;
|
||||
if (
|
||||
currentEmployeeId !== emp.employee_id ||
|
||||
currentYearMonth !== bonusYearMonth
|
||||
) {
|
||||
|
||||
// 新しいキーが異なる場合は新しいページを開く
|
||||
if (currentKey !== currentKey_new) {
|
||||
if (pageOpen) {
|
||||
printHtml += "</div>";
|
||||
}
|
||||
currentEmployeeId = emp.employee_id;
|
||||
currentYearMonth = bonusYearMonth;
|
||||
currentKey = currentKey_new;
|
||||
printHtml += '<div class="page">';
|
||||
printHtml += `<div style="font-size: 11px; color: #999; margin-bottom: 10px; text-align: right;">帳票生成日: ${generationDate}</div>`;
|
||||
pageOpen = true;
|
||||
@@ -2101,9 +2101,9 @@
|
||||
|
||||
const [startYear, startMonth] = startYM.split("-").map(Number);
|
||||
const endYM = document.getElementById("voucherEndYearMonth").value;
|
||||
const [endYear, endMonth] = endYM
|
||||
? endYM.split("-").map(Number)
|
||||
: [startYear, startMonth];
|
||||
const endParts = endYM ? endYM.split("-").map(Number) : null;
|
||||
const endYear = endParts ? endParts[0] : null;
|
||||
const endMonth = endParts ? endParts[1] : null;
|
||||
const voucherType = document.querySelector(
|
||||
"input[name='voucherType']:checked",
|
||||
).value;
|
||||
|
||||
Reference in New Issue
Block a user