diff --git a/wms/WriteOff.xlsx b/wms/WriteOff.xlsx index 2cb16743..f0bd5f01 100644 Binary files a/wms/WriteOff.xlsx and b/wms/WriteOff.xlsx differ diff --git a/wms/rib02-create.php b/wms/rib02-create.php index 7cc5dd20..ee2dbad2 100644 --- a/wms/rib02-create.php +++ b/wms/rib02-create.php @@ -636,28 +636,24 @@ $materials = $conn->query($sql_Material); $("#FeeDate").val(''); } else { let year = $("#FeeDate").val().substr(0, 4); - let month = $("#FeeDate").val().substr(4, 2); + let month = parseInt($("#FeeDate").val().substr(4, 2)) - 1; let day = $("#FeeDate").val().substr(6, 2); let feedate = new Date(year, month, day); - feedate.setMonth(feedate.getMonth() - 1); let now = new Date(); - if (feedate > now) { - alert("費用日期不可大於今天"); - $("#FeeDate").val(''); + if (feedate.getMonth() != month) { + alert("請輸入正確格式的日期"); } else { - now.setMonth(now.getMonth() - 2); - now.setDate(1); - now.setDate(now.getDate() - 1); - console.log(now.getFullYear()); - console.log(now.getMonth()); - console.log(now.getDate()); - console.log(feedate.getFullYear()); - console.log(feedate.getMonth()); - console.log(feedate.getDate()); - if (feedate <= now) { - - alert("超過兩個月的費用無法進行報銷"); + if (feedate > now) { + alert("費用日期不可大於今天"); $("#FeeDate").val(''); + } else { + now.setMonth(now.getMonth() - 2); + now.setDate(1); + now.setDate(now.getDate() - 1); + if (feedate <= now) { + alert("超過兩個月的費用無法進行報銷"); + $("#FeeDate").val(''); + } } } } @@ -685,7 +681,7 @@ $materials = $conn->query($sql_Material); }; function senddata() { - if ($("#FeeDate").val() == "" || $("#FeeNoteShow").val() == "" || $("#Price").val() == "" || $("#Quantity").val() == "") { + if ($("#FeeDate").val() == "" || $("#FeeNoteShow").val() == "" || $("#Price").val() == "" || $("#Quantity").val() == "" || $("#WriteOffId").val() == "") { alert("請確認紅字部分皆有填寫"); } else if ($("#OAmount").val() <= 0) { alert("金額必須大於零"); diff --git a/wms/rib02-edit.php b/wms/rib02-edit.php index a78cde97..f1ea8ccc 100644 --- a/wms/rib02-edit.php +++ b/wms/rib02-edit.php @@ -550,21 +550,24 @@ $materials = $conn->query($sql_Material); $("#FeeDate").val(''); } else { let year = $("#FeeDate").val().substr(0, 4); - let month = $("#FeeDate").val().substr(4, 2); + let month = parseInt($("#FeeDate").val().substr(4, 2)) - 1; let day = $("#FeeDate").val().substr(6, 2); let feedate = new Date(year, month, day); - feedate.setMonth(feedate.getMonth() - 1); let now = new Date(); - if (feedate > now) { - alert("費用日期不可大於今天"); - $("#FeeDate").val(''); + if (feedate.getMonth() != month) { + alert("請輸入正確格式的日期"); } else { - now.setMonth(now.getMonth() - 2); - now.setDate(1); - now.setDate(now.getDate() - 1) - if (feedate < now) { - alert("超過兩個月的費用無法進行報銷"); + if (feedate > now) { + alert("費用日期不可大於今天"); $("#FeeDate").val(''); + } else { + now.setMonth(now.getMonth() - 2); + now.setDate(1); + now.setDate(now.getDate() - 1); + if (feedate <= now) { + alert("超過兩個月的費用無法進行報銷"); + $("#FeeDate").val(''); + } } } } diff --git a/wms/rib03-submit.php b/wms/rib03-submit.php index 336be643..bbc05b82 100644 --- a/wms/rib03-submit.php +++ b/wms/rib03-submit.php @@ -224,13 +224,13 @@ OAmount =$OAmount, UnPayOAmount=$UnPayOAmount, Balance = $OAmountWithTax, LBalan $WriteOffDescribe = empty($rib['WriteOffDescribe']) ? null : $rib['WriteOffDescribe']; $DeptId = $rib['DeptId']; $CostCenterId = empty($rib['CostCenterId']) ? Null : $rib['CostCenterId']; - $HadPayOAmount = $rib['HadPayOAmount']; - $HadPayLAmount = $rib['HadPayLAmount']; - $UnPayOAmount = $rib['UnPayOAmount']; - $UnPayLAmount = $rib['UnPayLAmount']; + $HadPayOAmount = $CurrId=="TWD"? round($rib['HadPayOAmount']):round($rib['HadPayOAmount'],2); + $HadPayLAmount = $CurrId=="TWD"? round($rib['HadPayLAmount']):round($rib['HadPayLAmount'],2); + $UnPayOAmount = $CurrId=="TWD"? round($rib['UnPayOAmount']):round($rib['UnPayOAmount'],2); + $UnPayLAmount = $CurrId=="TWD"? round($rib['UnPayLAmount']):round($rib['UnPayLAmount'],2); $PaymentState = $rib['PaymentState']; - $Balance = $rib['Balance']; - $LBalance = $rib['LBalance']; + $Balance = $CurrId=="TWD"? round($rib['Balance']):round($rib['Balance'],2); + $LBalance = $CurrId=="TWD"? round($rib['LBalance']):round($rib['LBalance'],2); $GatheringPersonId = $rib['GatheringPersonId']; $GatheringPersonDescribe = empty($rib['GatheringPersonDescribe']) ? Null : $rib['GatheringPersonDescribe']; $BankId = empty($rib['BankId']) ? Null : $rib['BankId']; @@ -241,19 +241,20 @@ OAmount =$OAmount, UnPayOAmount=$UnPayOAmount, Balance = $OAmountWithTax, LBalan $BankAccount = empty($rib['BankAccount']) ? Null : $rib['BankAccount']; $BankAccountName = empty($rib['BankAccountName']) ? Null : $rib['BankAccountName']; $IsTaxBill = $rib['IsTaxBill']; - $OAmount = $rib['OAmount']; - $LAmount = $rib['LAmount']; - $OTax = $rib['OTax']; - $LTax = $rib['LTax']; - $LAmountWithTax = $rib['LAmountWithTax']; - $OAmountWithTax = $rib['OAmountWithTax']; + $OAmount = $CurrId=="TWD"? round($rib['OAmount']):round($rib['OAmount'],2); + $LAmount = $CurrId=="TWD"? round($rib['LAmount']):round($rib['LAmount'],2); + $OTax = $CurrId=="TWD"? round($rib['OTax']):round($rib['OTax'],2); + $LTax = $CurrId=="TWD"? round($rib['LTax']):round($rib['LTax'],2); + $LAmountWithTax = $CurrId=="TWD"? round($rib['LAmountWithTax']):round($rib['LAmountWithTax'],2); + $OAmountWithTax = $CurrId=="TWD"? round($rib['OAmountWithTax']):round($rib['OAmountWithTax'],2); $IsContainTax = $rib['IsContainTax']; - $AdvanceOAmount = $rib['AdvanceOAmount']; - $AdvanceLAmount = $rib['AdvanceLAmount']; + $AdvanceOAmount = $CurrId=="TWD"? round($rib['AdvanceOAmount']):round($rib['AdvanceOAmount'],2); + $AdvanceLAmount = $CurrId=="TWD"? round($rib['AdvanceLAmount']):round($rib['AdvanceLAmount'],2); $PrePayWriteOffAmount = $rib['PrePayWriteOffAmount']; - $WriteOffAmount = $rib['WriteOffAmount']; + $WriteOffAmount = $CurrId=="TWD"? round($rib['WriteOffAmount']):round($rib['WriteOffAmount'],2); $TelNo = empty($rib['TelNo']) ? Null : $rib['TelNo']; - $UnPaymentLAmt = empty($rib['UnPaymentLAmt']) ? null : $rib['UnPaymentLAmt']; + $UnPaymentLAmt = empty($rib['UnPaymentLAmt']) ? null : ($CurrId=="TWD"? round($rib['UnPaymentLAmt']):round($rib['UnPaymentLAmt'],2)); + $CreatorId = $rib['CreatorId']; $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -262,14 +263,14 @@ OAmount =$OAmount, UnPayOAmount=$UnPayOAmount, Balance = $OAmountWithTax, LBalan HadPayOAmount,HadPayLAmount,UnPayOAmount,UnPayLAmount,PaymentState,Balance,LBalance, FillUp,GatheringBizOrgId, GatheringPersonId, IsTaxBill, OAmount,LAmount,OTax,LTax,LAmountWithTax,OAmountWithTax, IsContainTax,AdvanceOAmount,AdvanceLAmount,PrePayWriteOffAmount,WriteOffAmount, - CompId,UnPaymentOAmt,UnPaymentLAmt,IsPayment, CurrentState,PermitState"; + CompId,UnPaymentOAmt,UnPaymentLAmt,IsPayment, CurrentState,PermitState,CreatorId"; $sql2 = ") VALUES ('$BillNo',$BillDate,'1000','1000','$TypeId','1000', '$CurrId','$TransactId',$WriteOffType,'1000','$WriteOffId','$DeptId', $HadPayOAmount,$HadPayLAmount,$UnPayOAmount,$UnPayLAmount,$PaymentState,$Balance,$LBalance, 0,'1000','$GatheringPersonId',$IsTaxBill,$OAmount,$LAmount,$OTax,$LTax,$LAmountWithTax,$OAmountWithTax, $IsContainTax,$AdvanceOAmount,$AdvanceLAmount,$PrePayWriteOffAmount,$WriteOffAmount, - '1001',$WriteOffAmount,$UnPaymentLAmt,0,2,0"; + '1001',$WriteOffAmount,$UnPaymentLAmt,0,2,0,'$CreatorId'"; $sql .= empty($CostCenterId) ? "" : ",CostCenterId"; $sql2 .= empty($CostCenterId) ? "" : ",'" . $CostCenterId . "'"; @@ -309,18 +310,18 @@ OAmount =$OAmount, UnPayOAmount=$UnPayOAmount, Balance = $OAmountWithTax, LBalan $CostCenterId = empty($ribsub['CostCenterId']) ? Null : $ribsub['CostCenterId']; $UnitId = $ribsub['UnitId']; $Quantity = $ribsub['Quantity']; - $Price = $ribsub['Price']; - $CurrOAmount = $ribsub['CurrOAmount']; - $CurrLAmount = $ribsub['CurrentLAmount']; + $Price = $CurrId=="TWD"? round($ribsub['Price']) : round($ribsub['Price'],2); + $CurrOAmount = $CurrId=="TWD"? round($ribsub['CurrOAmount']) : round($ribsub['CurrOAmount'],2); + $CurrLAmount = $CurrId=="TWD"? round($ribsub['CurrentLAmount']): round($ribsub['CurrentLAmount'],2); $TaxId = $ribsub['TaxId']; $TaxRate = $ribsub['TaxRate']; - $OTax = $ribsub['OTax']; - $LTax = $ribsub['LTax']; - $LAmountUnWithTax = $ribsub['LAmountUnWithTax']; - $OAmountUnWithTax = $ribsub['OAmountUnWithTax']; - $OAmount = $ribsub['OAmount']; - $LAmount = $ribsub['LAmount']; - $FeeBalance = $ribsub['FeeBalance']; + $OTax = $CurrId=="TWD"? round($ribsub['OTax']): round($ribsub['OTax'],2); + $LTax = $CurrId=="TWD"? round($ribsub['LTax']): round($ribsub['LTax'],2); + $LAmountUnWithTax = $CurrId=="TWD"? round($ribsub['LAmountUnWithTax']): round($ribsub['LAmountUnWithTax'],2); + $OAmountUnWithTax = $CurrId=="TWD"? round($ribsub['OAmountUnWithTax']): round($ribsub['OAmountUnWithTax'],2); + $OAmount = $CurrId=="TWD"? round($ribsub['OAmount']): round($ribsub['OAmount'],2); + $LAmount = $CurrId=="TWD"? round($ribsub['LAmount']): round($ribsub['LAmount'],2); + $FeeBalance = $CurrId=="TWD"? round($ribsub['FeeBalance']): round($ribsub['FeeBalance'],2); $VoucherCount = $ribsub['VoucherCount']; $FeeNoteShow = empty($ribsub['FeeNoteShow']) ? Null : $ribsub['FeeNoteShow']; @@ -341,13 +342,13 @@ OAmount =$OAmount, UnPayOAmount=$UnPayOAmount, Balance = $OAmountWithTax, LBalan $sqlsub = "INSERT INTO glFeeWriteOffSub (BillNo, RowCode,RowNo,FeeDate,FeeTypeId, WriteOffType, BizOrgId, WriteOffId, FeeOrgId, FeeDeptId, FeeCompanyId, UnitId , Quantity, Price, CurrOAmount,CurrLAmount,TaxId,TaxRate,OTax,LTax,LAmountUnWithTax - ,OAmountUnWithTax,OAmount,LAmount,FeeBalance,VoucherCount,CurrId,WriteOffAmount,SupplyOrgId,IsCounteract,IsKeyByFeeInfo,CreatorId + ,OAmountUnWithTax,OAmount,LAmount,FeeBalance,VoucherCount,CurrId,WriteOffAmount,SupplyOrgId,IsCounteract,IsKeyByFeeInfo "; $sqlsub2 = ") VALUES ('$BillNo',$RowCode, $RowNo,$FeeDate,'$FeeTypeId',$WriteOffType, '1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId', $Quantity, $Price, $CurrOAmount, $CurrLAmount,'$TaxId',$TaxRate,$OTax,$LTax,$LAmountUnWithTax - ,$OAmountUnWithTax,$OAmount,$LAmount,$FeeBalance,$VoucherCount,'$CurrId',$WriteOffAmount,'1000',$IsCounteract,0,$CreatorId + ,$OAmountUnWithTax,$OAmount,$LAmount,$FeeBalance,$VoucherCount,'$CurrId',$WriteOffAmount,'1000',$IsCounteract,0 "; $sqlsub .= empty($WriteOffDescribe) ? "" : ",WriteOffDescribe"; @@ -374,7 +375,6 @@ OAmount =$OAmount, UnPayOAmount=$UnPayOAmount, Balance = $OAmountWithTax, LBalan $sqlsub .= $sqlsub2; $sqlsub .= ")"; - $result2 = $conn->query($sqlsub); }