Initial commit.

This commit is contained in:
2026-03-10 21:25:26 +08:00
commit 78739bf725
3089 changed files with 472990 additions and 0 deletions

View File

@@ -0,0 +1,177 @@
/* Woman's Voice
* accounting.js: The accounting-related JavaScript subroutines.
*/
/* Copyright (c) 2007-2018 imacat.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Author: imacat <imacat@mail.imacat.idv.tw>
* First written: 2007-09-26
*/
// setAutoSummary: Automatically supply a summary
function setAutoSummary(subj) {
var i, j, sum, dateText, today, subjText, subjCode, thisMonth;
// Get the name prefix of this selection
i = subj.name.indexOf("subj");
// Obtain the summary column
sum = subj.form[subj.name.substr(0, i) + "summary"];
// Get today's date
today = new Date;
dateText = trim(subj.form.date.value);
if (!isDate(dateText))
return;
today.setFullYear(dateText.substr(0, 4));
today.setMonth(dateText.substr(5, 2) - 1);
today.setDate(dateText.substr(8, 2));
thisMonth = today.getMonth() + 1;
// Obtain the selected subject
// The value of the selection is S/N but not subject code,
// so we have to obtain the subject code from the option text
subjText = subj.options[subj.selectedIndex].text;
subjCode = parseInt(subjText.substr(0, subjText.indexOf(" ")));
switch (subjCode) {
// 74811 共同生活基金-燕秋
case 74811:
sum.value = "燕秋" + thisMonth + "月";
break;
// 74812 共同生活基金-士青
case 74812:
sum.value = "士青" + thisMonth + "月";
break;
// 6252 租金支出
case 6252:
sum.value = "房租" + thisMonth + "月";
break;
// 62562 市話 02-3233-7444
case 62562:
// 2142 應付—電話費
case 2142:
// 20 or later - assume to be of this month
if (today.getDate() >= 20) {
sum.value = "電話費" + thisMonth + "月";
// Before 20 - assume to be of previous month
} else {
sum.value = "電話費" + ((thisMonth + 10) % 12 + 1) + "月";
}
break;
// 62611 電費
case 62611:
i = ((thisMonth + thisMonth % 2 + 8) % 12 + 1)
j = ((thisMonth + thisMonth % 2 + 9) % 12 + 1)
sum.value = "電費" + i + "" + j + "月";
break;
// 62612 水費
case 62612:
i = ((thisMonth + thisMonth % 2 + 8) % 12 + 1)
j = ((thisMonth + thisMonth % 2 + 9) % 12 + 1)
sum.value = "水費" + i + "" + j + "月";
break;
// 62613 瓦斯費
case 62613:
i = ((thisMonth + thisMonth % 2 + 8) % 12 + 1)
j = ((thisMonth + thisMonth % 2 + 9) % 12 + 1)
sum.value = "瓦斯費" + i + "" + j + "月";
break;
// 62614 公用電費
case 62614:
i = ((thisMonth + thisMonth % 2 + 8) % 12 + 1)
j = ((thisMonth + thisMonth % 2 + 9) % 12 + 1)
sum.value = "公用電費" + i + "" + j + "月";
break;
// 62732 有線電視—新視波
case 62732:
if (thisMonth == 12 || thisMonth == 1)
sum.value = "新視波16月"
else if (thisMonth == 6 || thisMonth == 7)
sum.value = "新視波712月"
break;
}
return;
}
// acctRepQueryDisableNoUseRanges: Disable range parameters that are not in use
function acctRepQueryDisableNoUseRanges() {
var i, form, curValue;
// Obtain our form
form = document.forms["acctrepquery"];
if (form == undefined)
return;
// Find the current selection
for (i = 0; i < form.r.length; i++) {
if (form["r"][i].checked) {
curValue = form["r"][i].value;
break;
}
}
// Disable or enable the month selection
if (curValue == "m")
form["m"].disabled = false;
else
form["m"].disabled = true;
// Disable or enable the year selection
if (curValue == "y")
form["y"].disabled = false;
else
form["y"].disabled = true;
// Disable or enable the start and end date
if (curValue == "s") {
form["f"].disabled = false;
form["t"].disabled = false;
} else {
form["f"].disabled = true;
form["t"].disabled = true;
}
return;
}
// calcTotal: Calculating the total
function calcTotal(amount) {
var i, j, side, sum, a, pos, isNumber;
a = "NT$ 3,433.00";
side = amount.name.substr(0, 4);
for ( i = 0, sum = 0;
amount.form[side + i + "amount"] != undefined;
i++) {
a = amount.form[side + i + "amount"];
// Trim the text
a.value = trim(a.value);
// Remove the dollar sign
if (a.value.substr(0, 3) == "NT$")
a.value = a.value.substr(3);
// Trim the text again, for possible spaces after the dollar sign
a.value = trim(a.value);
// Remove the decimal point
if (a.value.substr(a.value.length - 3) == ".00")
a.value = a.value.substr(0, a.value.length - 3);
// Remove the thousand seperators
while ((pos = a.value.indexOf(",")) != -1) {
a.value = a.value.substr(0, pos) + a.value.substr(pos + 1);
}
// Check if it is a number
for (j = 0, isNumber = true; j < a.value.length; j++) {
if (a.value.charCodeAt(j) < 48 || a.value.charCodeAt(j) > 57) {
isNumber = false;
break;
}
}
// Add the amount
if (isNumber)
sum = sum + a.value * 1;
}
a = amount.form[side + "total"];
if (a != undefined)
a.value = sum;
}