Browse Source

修改費用報銷單會計取T8費用項目的內容,應收帳款明細新增該階段應收金額

gary
Ellin 1 year ago
parent
commit
083d7ce4e8
  1. 2
      mkt/database.php
  2. 53
      wms/account-receivable-index.php
  3. 2
      wms/rib01-check.php
  4. 2
      wms/rib02-check.php
  5. 174
      wms/rib02-create.php
  6. 2
      wms/rib02-edit.php

2
mkt/database.php

@ -1,5 +1,5 @@
<?php
$envFile = __DIR__ . '/../.env'; // .env 文件的路径
$envFile = __DIR__ . '\.env'; // .env 文件的路径
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

53
wms/account-receivable-index.php

@ -8,7 +8,7 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx as xls;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
$arrayData = [];
echo "合約號,部門,經理,營業員,客戶名稱,簽約款,二次款,貨抵工地款,安裝款,試車款,交車款,取得許可證約交款,取得許可函後6個月約交款,狀態</br>";
echo "合約號;部門;經理;營業員;客戶名稱;簽約款;二次款;貨抵工地款;安裝款;試車款;交車款;取得許可證約交款;取得許可函後6個月約交款;目前應收;總作番數;貨抵;安裝;試車;移交數;狀態</br>";
// $T8_array = mysqli_fetch_all($T8_array, MYSQLI_ASSOC);
@ -25,7 +25,13 @@ $contract = $conn->query($sql_contract);
foreach ($contract as $cont) {
// print_r($cont);
// echo "<br>";
if ($cont['BillNo'] == 'SO20230801001') {
$BillNo = 'M230947';
}elseif ($cont['BillNo'] == 'SO20230801002'){
$BillNo = 'M231067';
}else{
$BillNo = $cont['BillNo'];
};
$PayStage = $cont['PayStage'];
$PayAmount = $cont['PlanPayAmt'];
$partnerName = $cont['BizPartnerName'];
@ -110,27 +116,56 @@ FROM department
) AS d
ON d.department_id = tmp2.department_id";
$facitities = "";
$total_facility_num = 0;
$arrive_num = 0;
$install_num = 0;
$tryrun_num = 0;
$delivery_num = 0;
$wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) {
$value[0] = $wip['depart_name'];
$value[1] = $wip['manager_name'];
$value[2] = $wip['name'];
if ($wip['delivery_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['delivery_date'] . "已移交);\n";
$facitities .= $wip['facilityno'] . "(" . $wip['delivery_date'] . "已移交),\n";
$total_facility_num += 1;
$arrive_num += 1;
$install_num += 1;
$tryrun_num += 1;
$delivery_num += 1;
} elseif ($wip['tryrun_end_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['tryrun_end_date'] . "試車完畢);\n";
$facitities .= $wip['facilityno'] . "(" . $wip['tryrun_end_date'] . "試車完畢),\n";
$total_facility_num += 1;
$arrive_num += 1;
$install_num += 1;
$tryrun_num += 1;
} elseif ($wip['install_end_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['install_end_date'] . "安裝完畢);\n";
$facitities .= $wip['facilityno'] . "(" . $wip['install_end_date'] . "安裝完畢),\n";
$total_facility_num += 1;
$arrive_num += 1;
$install_num += 1;
} elseif ($wip['real_arrival_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['real_arrival_date'] . "貨抵工地);\n";
$facitities .= $wip['facilityno'] . "(" . $wip['real_arrival_date'] . "貨抵工地),\n";
$total_facility_num += 1;
$arrive_num += 1;
} elseif ($wip['actual_tofactory_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['actual_tofactory_date'] . "實際到觀音日);\n";
$facitities .= $wip['facilityno'] . "(" . $wip['actual_tofactory_date'] . "實際到觀音日),\n";
$total_facility_num += 1;
} elseif ($wip['estimated_shipping_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['estimated_shipping_date'] . "預計到港);\n";
$facitities .= $wip['facilityno'] . "(" . $wip['estimated_shipping_date'] . "預計到港),\n";
$total_facility_num += 1;
} else {
$facitities .= $wip['facilityno'] . "(預計到港日待確認);\n";
$facitities .= $wip['facilityno'] . "(預計到港日待確認),\n";
$total_facility_num += 1;
}
}
if ($total_facility_num > 0) {
$receivable_budget = $value[4] + ($value[5] + $value[6]) * ($arrive_num / $total_facility_num) +
($value[7]) * ($install_num / $total_facility_num) + ($value[8]) * ($tryrun_num / $total_facility_num)
+ ($value[9] + $value[10] + $value[11]) * ($delivery_num / $total_facility_num);
}
echo $key . "," . $value[0] . "," . $value[1] . "," . $value[2] . "," . $value[3] . "," . $value[4] . "," . $value[5] . "," . $value[6] . "," . $value[7] . "," . $value[8] . "," . $value[9] . "," . $value[10] . "," . $value[11] . "," . $facitities . "<br>";
echo $key . ";" . $value[0] . ";" . $value[1] . ";" . $value[2] . ";" . $value[3] . ";" . $value[4] . ";" . $value[5] . ";" . $value[6] . ";" . $value[7] . ";" . $value[8] . ";" . $value[9] . ";" . $value[10] . ";" . $value[11] . ";" . $receivable_budget . ";" . $total_facility_num . ";" . $arrive_num . ";" . $install_num . ";" . $tryrun_num . ";" . $delivery_num . ";" . $facitities . "<br>";
}

2
wms/rib01-check.php

@ -335,7 +335,7 @@ $feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC);
?>
<div style="width: 80%;">
<?php
if ($state == 0) :
if (($state == 0)||($user_id='M0056') || $user_id=='M0209') :
?>
<a href="rib02-create.php?id=<?php echo $data['rib_id'] ?>&RowCode=<?= $RowCode ?>&CurrId=<?= $CurrId ?>&<?= $token_link ?>" class="btn btn-info btn-lg pull-right" style="margin: 1 rem;">
<span class=" glyphicon glyphicon-plus"></span>

2
wms/rib02-check.php

@ -7,7 +7,7 @@ $rib_query = mysqli_query($link, $sql_ribsub);
$ribsub = mysqli_fetch_assoc($rib_query);
//取得費用項目代碼
$sql_feetype = "SELECT * from feetype";
$sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%') AND(FeeTypeId NOT LIKE 'Z%')";
$feetype_query = mysqli_query($link, $sql_feetype);
$feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC);

174
wms/rib02-create.php

@ -15,6 +15,51 @@ if (mysqli_num_rows($rib_query) > 0) {
$rib_id = $rib['rib_id'];
$WrtieOffId = $rib['WriteOffId'];
$FeeDeptId = $rib['DeptId'];
$CurrId = $rib['CurrId'];
if ($rib['CurrentState'] == 1) {
// 爬蟲--匯率
function htmlContentGet($url)
{
$opts = [
"http" => [
"method" => "GET",
"header" => "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36\r\n"
]
];
return file_get_contents($url, false, stream_context_create($opts));
}
$week = date("w");
$currency_day = date("Y-m-d", strtotime("-1 day"));
if ($week == 1) {
$currency_day = date("Y-m-d", strtotime("-3 day"));
} elseif ($week == 0) {
$currency_day = date("Y-m-d", strtotime("-2 day"));
}
$X = htmlContentGet('https://rate.bot.com.tw/xrt/all/' . $currency_day);
$string = strip_tags($X); // 先清掉 html tag, 以免 html tag 被破壞
//美金
$USD = explode(' ', stristr($string, '美金'))[298];
//人民幣
$RMB = explode(' ', stristr($string, '人民幣'))[298];
//歐元
$EUR = explode(' ', stristr($string, '歐元'))[298];
//港幣
$HKD = explode(' ', stristr($string, '港幣'))[298];
//整理要變更的數據 -表身
$CurrLAmount = 1;
if ($rib['CurrId'] == "CNY") {
$CurrLAmount = $RMB;
} elseif ($rib['CurrId'] == "EUR") {
$CurrLAmount = $EUR;
} elseif ($rib['CurrId'] == "HKD") {
$CurrLAmount = $HKD;
} elseif ($rib['CurrId'] == "USD") {
$CurrLAmount = $USD;
}
}
}
}
@ -22,7 +67,7 @@ $RowCode = $_GET['RowCode'];
//取得費用項目代碼
$sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%')AND(FeeTypeId NOT LIKE 'M%') AND(FeeTypeId NOT LIKE 'Z%')";
$sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%') AND(FeeTypeId NOT LIKE 'Z%')";
$feetype = $conn->query($sql_feetype);
$member = array();
//取得人員名單與使用者的部門
@ -209,6 +254,24 @@ $materials = $conn->query($sql_Material);
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="TaxId">稅碼</label>
<select name="TaxId" class="form-control">
<option value="ST005" selected>營業稅5%</option>
<option value="ST101">零稅</option>
<option value="ST102">免稅</option>
</select>
</div>
<div class="col-md-3">
<label for="IsCounteract">抵扣</label>
<select name="IsCounteract" class="form-control">
<option value=1 selected>可抵扣</option>
<option value=0>不可抵扣</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
@ -234,24 +297,57 @@ $materials = $conn->query($sql_Material);
<input class="form-control" type="number" step="any" name="OAmount" id="OAmount" placeholder="單價x數量" required disabled>
</div>
</div>
<?php
if ($user_id == "M0056" || $user_id == "M0209") {
?>
<div class="form-group">
<div class="col-md-3">
<label for="TaxId">稅碼</label>
<select name="TaxId" class="form-control">
<option value="ST005" selected>營業稅5%</option>
<option value="ST101">零稅</option>
<option value="ST102">免稅</option>
</select>
<label for="CurrId">幣別</label>
<input class="form-control" type="text" name="CurrId" id="CurrId" value="<?php if ($CurrId == "TWD") {
echo "台幣";
} elseif ($CurrId == "CNY") {
echo "人民幣";
} elseif ($CurrId == "EUR") {
echo "歐元";
} elseif ($CurrId == "HKD") {
echo "港幣";
} else {
echo "美元";
} ?>" disabled>
</div>
<div class="col-md-3">
<label for="IsCounteract">抵扣</label>
<select name="IsCounteract" class="form-control">
<option value=1 selected>可抵扣</option>
<option value=0>不可抵扣</option>
</select>
<label for="CurrLAmount">匯率</label>
<input class="form-control" type="number" name="CurrLAmount" id="CurrLAmount" value="<?= $CurrLAmount ?>" disabled>
</div>
<div class="col-md-3">
<label for="OTax">稅金 (原幣值)</label>
<input class="form-control" type="number" name="OTax" id="OTax" value="<?= $ribsub['OTax'] ?>" disabled>
</div>
<div class="col-md-3">
<label for="LTax">本幣稅金</label>
<input class="form-control" type="number" step="any" name="LTax" id="LTax" value="<?= $ribsub['LTax'] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="OAmountUnWithTax">未稅報銷金額 (原幣值)</label>
<input class="form-control" type="number" name="OAmountUnWithTax" id="OAmountUnWithTax" value="<?= $ribsub['OAmountUnWithTax'] ?>" disabled>
</div>
<div class="col-md-3">
<label for="LAmountUnWithTax">本幣未稅報銷金額</label>
<input class="form-control" type="number" step="any" name="LAmountUnWithTax" id="LAmountUnWithTax" value="<?= $ribsub['LAmountUnWithTax'] ?>" disabled>
</div>
<div class="col-md-3">
<label for="LAmount">本幣報銷金額</label>
<input class="form-control" type="number" step="any" name="LAmount" id="LAmount" value="<?= $ribsub['LAmount'] ?>" disabled>
</div>
</div>
<?php
} ?>
<div class="form-group">
<div class="col-md-3">
<label for="VoucherCount">憑單張數</label>
@ -331,6 +427,7 @@ $materials = $conn->query($sql_Material);
$("#ProjectId").selectize();
$("#CU_MaterialId").selectize();
})
function checkBiz() {
if ($("#TaxNo").val().length !== 8) {
alert("統一編號格式錯誤");
@ -434,10 +531,52 @@ $materials = $conn->query($sql_Material);
})
$("#Price").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
}
});
$("#Quantity").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
}
});
$("#TaxId").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
}
})
$("#FeeDate").change(function() {
if ($("#FeeDate").val().length != 8) {
alert("輸入格式錯誤");
@ -454,7 +593,7 @@ $materials = $conn->query($sql_Material);
$("#FeeDate").val('');
} else {
now.setMonth(now.getMonth() - 2);
now.setDate(01);
now.setDate(1);
now.setDate(now.getDate() - 1)
if (feedate < now) {
alert("超過兩個月的費用無法進行報銷");
@ -493,6 +632,15 @@ $materials = $conn->query($sql_Material);
} else {
$("#OAmount").prop("disabled", false);
<?php
if ($user_id == "M0056" || $user_id == "M0209") { ?>
$("#OTax").prop("disabled", false);
$("#LTax").prop("disabled", false);
$("#OAmountUnWithTax").prop("disabled", false);
$("#LAmountUnWithTax").prop("disabled", false);
$("#LAmount").prop("disabled", false);
$("#OAmount").prop("disabled", false);
<?php } ?>
$('#ribsubform').submit();
}

2
wms/rib02-edit.php

@ -10,7 +10,7 @@ $ribsub = mysqli_fetch_assoc($rib_query);
//取得費用項目代碼
$sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%')AND(FeeTypeId NOT LIKE 'M%') AND(FeeTypeId NOT LIKE 'Z%')";
$sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%') AND(FeeTypeId NOT LIKE 'Z%')";
$feetype = $conn->query($sql_feetype);
$member = array();
//取得人員名單與使用者的部門

Loading…
Cancel
Save