Check-in gate: block when unpaid, require payment or explicit allow-checkbox
Browse files- index.html +50 -1
index.html
CHANGED
|
@@ -714,6 +714,10 @@ function openBookingModal(no){
|
|
| 714 |
channel:$('#f_channel').value,roomNo,checkin:ci,checkout:co,
|
| 715 |
guests:+$('#f_guests').value||1,extra:+$('#f_extra').value||0,discount:+$('#f_discount').value||0,
|
| 716 |
status:$('#f_status').value,note:$('#f_note').value.trim()};
|
|
|
|
|
|
|
|
|
|
|
|
|
| 717 |
const others=DB.bookings.filter(x=>x.no!==obj.no&&x.roomNo===roomNo&&x.status!=='取消'&&x.checkin<co&&ci<x.checkout);
|
| 718 |
if(others.length&&!confirm(`⚠ 重複訂房警示!\n${roomNo} 與下列訂單日期重疊:\n${others.map(o=>`${o.no} ${o.name} ${o.checkin}~${o.checkout}`).join('\n')}\n\n仍要儲存嗎?`))return;
|
| 719 |
const i=DB.bookings.findIndex(x=>x.no===obj.no);
|
|
@@ -750,6 +754,46 @@ function openPayModal(no){
|
|
| 750 |
save();closeModal();render();toast(`已收款 ${fmtMoney(amt)},訂單 ${no} 已更新`);
|
| 751 |
});
|
| 752 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 753 |
function genTxnNo(date){let i=1,no;do{no='T'+date.replace(/-/g,'')+pad(i);i++;}while(DB.txns.some(t=>t.no===no));return no;}
|
| 754 |
|
| 755 |
/* ---- 收支傳票表單 ---- */
|
|
@@ -810,6 +854,7 @@ function openHelp(){
|
|
| 810 |
<b>📊 營運報表</b>:月營收(應收/實收)、入住率、ADR、通路佔比、房型營收排行、費用分類彙總、應收未收清單,資料異動即時更新。<br>
|
| 811 |
<b>⚙️ 基本資料</b>:房型房價、通路、收支類別、支付方式維護;CSV/JSON 匯入匯出備份。<br>
|
| 812 |
<b>狀態流轉</b>:待付訂 → 已付訂 → 入住中 → 已退房(或取消)。取消單之已收款請以「支出/退款」登記沖銷。<br>
|
|
|
|
| 813 |
<span style="color:var(--sub)">※ 資料存於瀏覽器 localStorage,請定期匯出備份。內建示範假資料可於基本資料頁重置。</span></div>`);
|
| 814 |
}
|
| 815 |
|
|
@@ -895,7 +940,11 @@ function bind(){
|
|
| 895 |
switch(btn.dataset.act){
|
| 896 |
case 'edit':openBookingModal(no);break;
|
| 897 |
case 'pay':openPayModal(no);break;
|
| 898 |
-
case 'in':
|
|
|
|
|
|
|
|
|
|
|
|
|
| 899 |
case 'out':b.status='已退房';save();render();toast(no+' 已辦理退房');break;
|
| 900 |
case 'cancel':if(confirm(`確定取消訂單 ${no}?\n(已收款請於記帳以「支出/退款」登記沖銷)`)){b.status='取消';save();render();toast(no+' 已取消');}break;
|
| 901 |
case 'del':if(confirm(`刪除訂單 ${no}?\n其關聯收款紀錄將一併刪除!`)){
|
|
|
|
| 714 |
channel:$('#f_channel').value,roomNo,checkin:ci,checkout:co,
|
| 715 |
guests:+$('#f_guests').value||1,extra:+$('#f_extra').value||0,discount:+$('#f_discount').value||0,
|
| 716 |
status:$('#f_status').value,note:$('#f_note').value.trim()};
|
| 717 |
+
if(obj.status==='入住中'&&(!b||b.status!=='入住中')){
|
| 718 |
+
const bal=receivableOf(obj);
|
| 719 |
+
if(bal>0&&!confirm(`⚠ 款項未收清(尚欠 ${fmtMoney(bal)}),依規則不可直接入住。\n確定仍要設為「入住中」嗎?(未收金額將列入應收追蹤)`))return;
|
| 720 |
+
}
|
| 721 |
const others=DB.bookings.filter(x=>x.no!==obj.no&&x.roomNo===roomNo&&x.status!=='取消'&&x.checkin<co&&ci<x.checkout);
|
| 722 |
if(others.length&&!confirm(`⚠ 重複訂房警示!\n${roomNo} 與下列訂單日期重疊:\n${others.map(o=>`${o.no} ${o.name} ${o.checkin}~${o.checkout}`).join('\n')}\n\n仍要儲存嗎?`))return;
|
| 723 |
const i=DB.bookings.findIndex(x=>x.no===obj.no);
|
|
|
|
| 754 |
save();closeModal();render();toast(`已收款 ${fmtMoney(amt)},訂單 ${no} 已更新`);
|
| 755 |
});
|
| 756 |
}
|
| 757 |
+
|
| 758 |
+
/* ---- 辦理入住把關:款項未收清不可直接入住,須先登記收款補完(或勾選允許未付清) ---- */
|
| 759 |
+
function openCheckinModal(no){
|
| 760 |
+
const b=DB.bookings.find(x=>x.no===no);if(!b)return;
|
| 761 |
+
const total=calcTotalOf(b),rec=receivedOf(no),bal=Math.max(0,total-rec);
|
| 762 |
+
openModal(`<h2>🛏️ 辦理入住 — ${esc(b.no)} ${esc(b.name)}<button class="x" onclick="closeModal()">✕</button></h2>
|
| 763 |
+
<div class="calc" style="border-color:#fecaca;background:#fff1f2;color:#7f1d1d">
|
| 764 |
+
總價 ${fmtMoney(total)}|已收 ${fmtMoney(rec)}|尚欠 <b>${fmtMoney(bal)}</b><br>
|
| 765 |
+
⚠ 款項未收清,<b>不可以直接入住</b>:請先登記收款補完,或勾選下方「允許未付清仍辦理入住」。
|
| 766 |
+
</div>
|
| 767 |
+
<div class="fgrid" style="margin-top:12px">
|
| 768 |
+
<div><label>收款日期</label><input id="c_date" type="date" value="${todayStr()}"></div>
|
| 769 |
+
<div><label>收款項目</label><select id="c_cat">${optList(['尾款','訂金','房費','其他收入'],'尾款')}</select></div>
|
| 770 |
+
<div><label>金額(建議補足尚欠)</label><input id="c_amount" type="number" min="0" value="${bal}"></div>
|
| 771 |
+
<div><label>支付方式</label><select id="c_method">${optList(DB.payMethods,'匯款/轉帳')}</select></div>
|
| 772 |
+
<div class="full"><label>備註</label><input id="c_note" value="入住時收款"></div>
|
| 773 |
+
</div>
|
| 774 |
+
<label style="display:flex;align-items:center;gap:8px;margin-top:12px;font-size:13.5px;cursor:pointer">
|
| 775 |
+
<input type="checkbox" id="c_allow" style="width:auto">
|
| 776 |
+
允許未付清仍辦理入住(<b>預設不勾選</b>;勾選後未收金額將列入應收持續追蹤)
|
| 777 |
+
</label>
|
| 778 |
+
<div class="err" id="cErr"></div>
|
| 779 |
+
<div class="mact"><button class="btn" onclick="closeModal()">取消</button><button class="btn primary" id="cSave">💾 登記收款並辦理入住</button></div>`);
|
| 780 |
+
$('#cSave').addEventListener('click',()=>{
|
| 781 |
+
const amt=+$('#c_amount').value||0;
|
| 782 |
+
if(amt<0)return $('#cErr').textContent='金額不可為負';
|
| 783 |
+
if(amt>0){
|
| 784 |
+
DB.txns.push({no:genTxnNo($('#c_date').value||todayStr()),date:$('#c_date').value||todayStr(),
|
| 785 |
+
type:'收入',cat:$('#c_cat').value,orderNo:no,amount:amt,method:$('#c_method').value,
|
| 786 |
+
handler:'櫃台',note:$('#c_note').value.trim()||'入住時收款'});
|
| 787 |
+
}
|
| 788 |
+
const newBal=Math.max(0,total-receivedOf(no));
|
| 789 |
+
if(newBal>0&&!$('#c_allow').checked){
|
| 790 |
+
return $('#cErr').innerHTML=`⚠ 款項尚欠 <b>${fmtMoney(newBal)}</b>,不可入住。請把收款金額補足到 ${fmtMoney(bal)},或勾選「允許未付清仍辦理入住」。`;
|
| 791 |
+
}
|
| 792 |
+
b.status='入住中';
|
| 793 |
+
save();closeModal();render();
|
| 794 |
+
toast(newBal>0?`${no} 已辦理入住(未付清 ${fmtMoney(newBal)},列入應收追蹤)`:`${no} 已收清並辦理入住`);
|
| 795 |
+
});
|
| 796 |
+
}
|
| 797 |
function genTxnNo(date){let i=1,no;do{no='T'+date.replace(/-/g,'')+pad(i);i++;}while(DB.txns.some(t=>t.no===no));return no;}
|
| 798 |
|
| 799 |
/* ---- 收支傳票表單 ---- */
|
|
|
|
| 854 |
<b>📊 營運報表</b>:月營收(應收/實收)、入住率、ADR、通路佔比、房型營收排行、費用分類彙總、應收未收清單,資料異動即時更新。<br>
|
| 855 |
<b>⚙️ 基本資料</b>:房型房價、通路、收支類別、支付方式維護;CSV/JSON 匯入匯出備份。<br>
|
| 856 |
<b>狀態流轉</b>:待付訂 → 已付訂 → 入住中 → 已退房(或取消)。取消單之已收款請以「支出/退款」登記沖銷。<br>
|
| 857 |
+
<b>🛏️ 入住把關</b>:款項未收清時按「辦理入住」會跳出通知視窗且不可直接入住,須先登記收款補完;例外請勾選「允許未付清仍辦理入住」(預設不勾選,未收金額列入應收追蹤)。<br>
|
| 858 |
<span style="color:var(--sub)">※ 資料存於瀏覽器 localStorage,請定期匯出備份。內建示範假資料可於基本資料頁重置。</span></div>`);
|
| 859 |
}
|
| 860 |
|
|
|
|
| 940 |
switch(btn.dataset.act){
|
| 941 |
case 'edit':openBookingModal(no);break;
|
| 942 |
case 'pay':openPayModal(no);break;
|
| 943 |
+
case 'in':{
|
| 944 |
+
const bal=receivableOf(b);
|
| 945 |
+
if(bal>0){openCheckinModal(no);} // 款項不全:跳出通知視窗,不可直接入住
|
| 946 |
+
else{b.status='入住中';save();render();toast(no+' 已辦理入住');}
|
| 947 |
+
break;}
|
| 948 |
case 'out':b.status='已退房';save();render();toast(no+' 已辦理退房');break;
|
| 949 |
case 'cancel':if(confirm(`確定取消訂單 ${no}?\n(已收款請於記帳以「支出/退款」登記沖銷)`)){b.status='取消';save();render();toast(no+' 已取消');}break;
|
| 950 |
case 'del':if(confirm(`刪除訂單 ${no}?\n其關聯收款紀錄將一併刪除!`)){
|