add invoice date and text

master
嘉祥 詹 2024-09-16 18:21:18 +08:00
parent ff1aec3cd4
commit 33cd0cda3a
11 changed files with 157 additions and 26 deletions

View File

@ -21,6 +21,7 @@ using System.Text;
using System.Web;
using NPOI.SS.Util;
using NPOI.XSSF.Streaming;
using System.IO;
namespace QuotationMaker.Controllers
{
@ -109,7 +110,7 @@ namespace QuotationMaker.Controllers
row = (XSSFRow)sheet.GetRow(2);
row.Cells[0].SetCellValue(row.Cells[0].StringCellValue.Replace("{contactPerson_name}", objDetail.contactPerson.contactPerson_name));
row.Cells[2].SetCellValue(row.Cells[2].StringCellValue.Replace("{company_name}", objDetail.company.company_name));
row.Cells[3].SetCellValue(row.Cells[3].StringCellValue.Replace("{user_name}", objDetail.user.user_name));
row.Cells[3].SetCellValue(row.Cells[3].StringCellValue.Replace("{user_name}", objDetail.user.user_name + " " + objDetail.user.user_engName));
row = (XSSFRow)sheet.GetRow(3);
row.Cells[0].SetCellValue(row.Cells[0].StringCellValue.Replace("{contactPerson_email}", objDetail.contactPerson.contactPerson_email));
@ -118,7 +119,14 @@ namespace QuotationMaker.Controllers
row = (XSSFRow)sheet.GetRow(4);
row.Cells[0].SetCellValue(row.Cells[0].StringCellValue.Replace("{company_serialNo}", objDetail.company.company_serialNo));
row.Cells[2].SetCellValue(row.Cells[2].StringCellValue.Replace("{contactPerson_tel}", objDetail.contactPerson.contactPerson_tel));
string fax_string = "";
if (objDetail.contactPerson.contactPerson_fax != "") {
fax_string = " FAX" + objDetail.contactPerson.contactPerson_fax;
}
row.Cells[2].SetCellValue(row.Cells[2].StringCellValue.Replace("{contactPerson_tel}", objDetail.contactPerson.contactPerson_tel + fax_string));
//估價單契約有效期限
UpperConvert upcov = new UpperConvert();
@ -219,7 +227,16 @@ namespace QuotationMaker.Controllers
row = (XSSFRow)sheet.GetRow(rowIndex);
row.Cells[3].SetCellValue(objDetail.invoices[i - 1].invoice_name);
row.Cells[4].SetCellValue(objDetail.invoices[i - 1].invoice_year.ToString() + "/" + objDetail.invoices[i - 1].invoice_month.ToString().PadLeft(2, '0'));
if (objDetail.invoices[i - 1].invoice_type == "date")
{
row.Cells[4].SetCellValue(objDetail.invoices[i - 1].invoice_year.ToString() + "/" + objDetail.invoices[i - 1].invoice_month.ToString().PadLeft(2, '0'));
}
else {
row.Cells[4].SetCellValue(objDetail.invoices[i - 1].invoice_text);
}
//row.Cells[6].SetCellValue("$NT" + objDetail.invoices[i - 1].invoice_noTaxMoney.ToString("###,###"));
row.Cells[6].SetCellType(CellType.Numeric);
row.Cells[6].SetCellValue(objDetail.invoices[i - 1].invoice_noTaxMoney);
@ -1277,13 +1294,26 @@ namespace QuotationMaker.Controllers
newItem.invoice_uid = "inv_" + GlobalClass.CreateRandomCode(20);
newItem.quotation_uid = quotation_uid;
newItem.invoice_name = item.invoice_name;
newItem.invoice_type = item.invoice_type;
if (newItem.invoice_type == "date")
{
string yearmonth = item.invoice_date;
string strYear = yearmonth.Split('/')[0];
string strMonth = yearmonth.Split("/")[1];
newItem.invoice_year = int.Parse(strYear);
newItem.invoice_month = int.Parse(strMonth);
newItem.invoice_text = "";
}
else {
newItem.invoice_year = 0;
newItem.invoice_month = 0;
newItem.invoice_text = item.invoice_text;
}
string yearmonth = item.invoice_date;
string strYear = yearmonth.Split('/')[0];
string strMonth = yearmonth.Split("/")[1];
newItem.invoice_year = int.Parse(strYear);
newItem.invoice_month = int.Parse(strMonth);
newItem.invoice_noTaxMoney = int.Parse((string)item.invoice_noTaxMoney);
newItem.invoice_revoke = "N";
newItem.invoice_version = int.Parse((string)quotation_version);
@ -1459,12 +1489,23 @@ namespace QuotationMaker.Controllers
newItem.quotation_uid = quotation_uid;
newItem.invoice_name = item.invoice_name;
string yearmonth = item.invoice_date;
string strYear = yearmonth.Split('/')[0];
string strMonth = yearmonth.Split("/")[1];
if (newItem.invoice_type == "date")
{
string yearmonth = item.invoice_date;
string strYear = yearmonth.Split('/')[0];
string strMonth = yearmonth.Split("/")[1];
newItem.invoice_year = int.Parse(strYear);
newItem.invoice_month = int.Parse(strMonth);
newItem.invoice_text = "";
}
else
{
newItem.invoice_year = 0;
newItem.invoice_month = 0;
newItem.invoice_text = item.invoice_text;
}
newItem.invoice_year = int.Parse(strYear);
newItem.invoice_month = int.Parse(strMonth);
newItem.invoice_noTaxMoney = int.Parse((string)item.invoice_noTaxMoney);
newItem.invoice_revoke = "N";
newItem.invoice_version = int.Parse((string)quotation_version);

View File

@ -1500,6 +1500,7 @@ namespace QuotationMaker.Controllers
if (user_type == "N")
{
string user_id = obj["user_elabName"].ToString();
string user_engName = obj["user_engName"].ToString();
user newUser = conn.QueryFirstOrDefault<user>("select * from users where user_id = @user_id ", new { user_id = user_id });
@ -1540,6 +1541,7 @@ namespace QuotationMaker.Controllers
newUser = new user();
newUser.user_uid = user_uid;
newUser.user_name = elabUser.username;
newUser.user_engName = user_engName;
newUser.user_id = elabUser.userid;
newUser.user_email = elabUser.mail;
newUser.user_type = user_type;
@ -1578,6 +1580,7 @@ namespace QuotationMaker.Controllers
string user_uid = GlobalClass.CreateRandomCode(12);
string user_name = obj["user_name"].ToString();
string user_email = obj["user_email"].ToString();
string user_engName = obj["user_engName"].ToString();
if (user_id == "")
@ -1638,6 +1641,7 @@ namespace QuotationMaker.Controllers
newUser.user_uid = user_uid;
newUser.user_id = user_id;
newUser.user_name = user_name;
newUser.user_engName = user_engName;
newUser.user_pwd = user_pwd;
newUser.user_email = user_email;
newUser.user_type = user_type;
@ -1672,6 +1676,7 @@ namespace QuotationMaker.Controllers
string user_uid = obj["user_uid"].ToString();
string user_perm = obj["user_perm"].ToString();
string user_depts = obj["user_depts"].ToString().Trim(',');
string user_engName = obj["user_engName"].ToString();
string[] depts = user_depts.Split(",");
@ -1713,6 +1718,7 @@ namespace QuotationMaker.Controllers
if (user_type == "N")
{
editUser.user_perm = user_perm;
editUser.user_engName = user_engName;
}
else
{
@ -1720,6 +1726,7 @@ namespace QuotationMaker.Controllers
string user_name = obj["user_name"].ToString();
string user_email = obj["user_email"].ToString();
editUser.user_perm = user_perm;
if (user_name == "")
@ -1745,6 +1752,7 @@ namespace QuotationMaker.Controllers
editUser.user_name = user_name;
editUser.user_email = user_email;
editUser.user_engName = user_engName;
}
conn.Update<user>(editUser);
@ -1943,6 +1951,7 @@ namespace QuotationMaker.Controllers
adminToken.user_uid = GlobalClass.appsettings("Admin:uid");
adminToken.user_id = GlobalClass.appsettings("Admin:id");
adminToken.token_isremember = input_isRemember;
adminToken.token_key = token_key;
adminToken.token_createdate = DateTime.Now;

View File

@ -57,6 +57,9 @@ public class DbTableClass
public string invoice_uid { get; set; } = "";
public string quotation_uid { get; set; } = "";
public string invoice_name { get; set; } = "";
public string invoice_type { get; set; } = "";
public string invoice_text { get; set; } = "";
public int invoice_year { get; set; } = 2024;
public int invoice_month { get; set; } = 1;
public int invoice_noTaxMoney { get; set; } = 0;
@ -447,6 +450,8 @@ public class DbTableClass
public string user_name { get; set; } = "";
public string user_engName { get; set; } = "";
public string user_email { get; set; } = "";
public string user_onjob { get; set; } = "N";

View File

@ -94,13 +94,13 @@
</div>
</div><!-- /.form-group -->
<!-- /.form-group -->
<div class="form-group">
<div class="form-group" style="display: none;">
<div class="form-label-group">
<input type="text" id="modal_company_tel" class="form-control" value="" placeholder="電話" maxlength="20" required=""> <label for="modal_company_tel">電話</label>
</div>
</div><!-- /.form-group -->
<!-- /.form-group -->
<div class="form-group">
<div class="form-group" style="display: none;">
<div class="form-label-group">
<input type="text" id="modal_company_fax" class="form-control" value="" placeholder="傳真" maxlength="20" required=""> <label for="modal_company_fax">傳真</label>
</div>
@ -194,7 +194,7 @@
<!-- .form-group -->
<div class="form-group">
<div class="form-label-group">
<input type="text" id="modal_contactPerson_name" class="form-control" value="" placeholder="姓名" maxlength="16" required=""> <label for="modal_contactPerson_name">姓名</label>
<input type="text" id="modal_contactPerson_name" class="form-control" value="" placeholder="姓名" maxlength="25" required=""> <label for="modal_contactPerson_name">姓名</label>
</div>
</div><!-- /.form-group -->
<!-- .form-group -->

View File

@ -294,7 +294,7 @@
</div>
<div class="form-group">
<div class="form-label-group">
<input type="text" id="modelSubItem_number" class="form-control" value="" placeholder="數量" maxlength="5" required=""> <label for="modelSubItem_number">數量</label>
<input type="text" id="modelSubItem_number" class="form-control" value="" placeholder="數量" maxlength="10" required=""> <label for="modelSubItem_number">數量</label>
</div>
</div>
<!-- .list-group-item -->

View File

@ -593,7 +593,7 @@
</div>
<div class="form-group">
<div class="form-label-group">
<input type="text" id="modelSubItem_number" class="form-control" value="" placeholder="數量" maxlength="5" required=""> <label for="modelSubItem_number">數量</label>
<input type="text" id="modelSubItem_number" class="form-control" value="" placeholder="數量" maxlength="10" required=""> <label for="modelSubItem_number">數量</label>
</div>
</div>
<!-- .list-group-item -->
@ -685,10 +685,22 @@
</div><!-- /.form-group -->
<div class="form-group">
<label for="invoice_type">發票月份樣式</label> <select id="invoice_type" class="custom-select d-block w-100">
<option value="date"> 日期 </option>
<option value="text"> 文字敘述 </option>
</select>
</div>
<div class="form-group" id="invoice_type_date">
<label class="control-label" for="invoice_date">發票開立月份</label>
<input id="invoice_date" type="text" class="form-control flatpickr-input active" data-toggle="flatpickr" data-date-format="m.y" data-monthselect="true" readonly="readonly">
</div>
<!-- .form-group -->
<div class="form-group" id="invoice_type_text">
<label class="control-label" for="invoice_text">發票開立時間說明</label> <input id="invoice_text" maxlength="20" type="text" class="form-control" />
</div><!-- /.form-group -->
<!-- .form-group -->
<div class="form-group">
<label class="control-label" for="invoice_noTaxMoney">開立金額(未稅)</label> <input id="invoice_noTaxMoney" maxlength="12" type="text" class="form-control" />

View File

@ -111,6 +111,13 @@
<label for="user_name">使用者名稱</label> <input type="text" id="user_name" class="form-control">
</div>
</div>
<div class="col-md-12" id="user_engname_div">
<div class="form-group">
<label for="user_engName">使用者英文名稱</label> <input type="text" id="user_engName" class="form-control">
</div>
</div>
<div class="col-md-12" id="user_id_div">
<div class="form-group">
<label for="user_id">使用者帳號</label> <input type="text" id="user_id" class="form-control">

View File

@ -176,6 +176,16 @@ $(document).ready(function () {
$('#clientModelQuotationModal').modal("toggle");
});
$('#invoice_type').on('change', function () {
if ($('#invoice_type').val() == "date") {
$('#invoice_type_date').show();
$('#invoice_type_text').hide();
} else {
$('#invoice_type_date').hide();
$('#invoice_type_text').show();
}
});
$('#dept_select').on('change', function () {
$('#dt-responsive').DataTable().ajax.reload();
});
@ -647,6 +657,8 @@ $(document).ready(function () {
initInvoiceSelectItem();
fpInvoiceDate.setDate(new Date(endTxt + '/1'));
$('#invoice_type').val('date');
$('#invoice_type_text').hide();
$('#invoice_method').val('add');
$('#invoiceModal').modal('toggle');
});
@ -656,7 +668,11 @@ $(document).ready(function () {
var invoice_method = $('#invoice_method').val();
var invoice_name = $("#invoice_name").val();
var invoice_date = $('#invoice_date').val();
var invoice_noTaxMoney = $('#invoice_noTaxMoney').val();
var invoice_type = $('#invoice_type').val();
var invoice_text = $('#invoice_text').val();
var invoice_noTaxMoney = $('#invoice_noTaxMoney').val().replace(/,/g, "");
if (invoice_noTaxMoney.isNumber() == false || invoice_noTaxMoney == '') {
alert('發票金額得為純數字!');
@ -668,23 +684,45 @@ $(document).ready(function () {
return;
}
if (invoice_date == '') {
alert('請輸入發票月份!');
return;
if (invoice_type == 'date') {
if (invoice_date == '') {
alert('請輸入發票月份!');
return;
}
}
if (invoice_type == 'text') {
if (invoice_text == '') {
alert('請輸入發票開立時間說明!');
return;
}
}
var invoice_display = "開立品項: " + invoice_name + ", 開立月份: " + invoice_date + ", 金額(未稅): " + AppendComma(invoice_noTaxMoney);
if (invoice_type == 'text') {
invoice_display = "開立品項: " + invoice_name + ", 開立月份: " + invoice_text + ", 金額(未稅): " + AppendComma(invoice_noTaxMoney);
}
var htmlCode = '';
htmlCode += ' <li class="list-group-item align-items-center drag-handle">\n';
htmlCode += ' <textarea style="display:none;" data-name="data_method">add</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="invoice_name">' + invoice_name + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="invoice_type">' + invoice_type + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="invoice_date">' + invoice_date + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="invoice_text">' + invoice_text + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="invoice_noTaxMoney">' + invoice_noTaxMoney + '</textarea>';
htmlCode += ' <span class="drag-indicator"></span>\n';
htmlCode += ' <span style="width: 15%;"> ' + "開立品項: " + invoice_name + ' </span>\n';
htmlCode += ' <span style="width: 15%;"> ' + "開立月份: " + invoice_date + ' </span\n';
if (invoice_type == 'date') {
htmlCode += ' <span style="width: 15%;"> ' + "開立月份: " + invoice_date + ' </span\n';
} else {
htmlCode += ' <span style="width: 15%;"> ' + "開立月份: " + invoice_text + ' </span\n';
}
htmlCode += ' <span style="width: 20%;">' + "金額(未稅): " + AppendComma(invoice_noTaxMoney) + ' </span>\n';
htmlCode += ' <span style="width: 50%;"></span>';
htmlCode += ' <div class="btn-group ml-auto">\n';
@ -955,17 +993,21 @@ $(document).ready(function () {
$('#invoice_div').find('ol li').each(function (i, item) {
var invoice_name = $(item).find('[data-name="invoice_name"]').val();
var invoice_type = $(item).find('[data-name="invoice_type"]').val();
var invoice_date = $(item).find('[data-name="invoice_date"]').val();
var invoice_text = $(item).find('[data-name="invoice_text"]').val();
var invoice_noTaxMoney = $(item).find('[data-name="invoice_noTaxMoney"]').val();
var data_method = $(item).find('[data-name="data_method"]').val();
if (quotation_method == 'edit' && data_method == 'add') {
quotation_log += '發票品項增加了 [' + invoice_name + ' (' + invoice_date + ') ' + AppendComma(invoice_noTaxMoney) + ']\n';
quotation_log += '發票品項增加了 [' + invoice_name + ' (' + invoice_date + invoice_text + ') ' + AppendComma(invoice_noTaxMoney) + ']\n';
}
var invoiceFormData = {
invoice_name: invoice_name,
invoice_type: invoice_type,
invoice_date: invoice_date,
invoice_text: invoice_text,
invoice_noTaxMoney: invoice_noTaxMoney
}
@ -1893,16 +1935,27 @@ function makePaymentHtml(obj) {
function makeInvoiceHtml(obj) {
var invoice_display = "開立品項: " + obj.invoice_name + ", 開立月份: " + obj.invoice_date + ", 金額(未稅): " + AppendComma(obj.invoice_noTaxMoney);
var invoice_date = obj.invoice_year + "/" + String(obj.invoice_month).padStart(2, "0");
var invoice_text = obj.invoice_text;
var invoice_type = obj.invoice_type;
var htmlCode = '';
htmlCode += ' <li class="list-group-item align-items-center drag-handle">\n';
htmlCode += ' <textarea style="display:none;" data-name="data_method">edit</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="invoice_name">' + obj.invoice_name + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="invoice_type">' + obj.invoice_type + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="invoice_date">' + invoice_date + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="invoice_text">' + invoice_text + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="invoice_noTaxMoney">' + obj.invoice_noTaxMoney + '</textarea>';
htmlCode += ' <span class="drag-indicator"></span>\n';
htmlCode += ' <span style="width: 15%;"> ' + "開立品項: " + obj.invoice_name + ' </span>\n';
htmlCode += ' <span style="width: 15%;"> ' + "開立月份: " + invoice_date + ' </span\n';
if (invoice_type == 'date') {
htmlCode += ' <span style="width: 15%;"> ' + "開立月份: " + invoice_date + ' </span\n';
} else {
htmlCode += ' <span style="width: 15%;"> ' + "開立月份: " + invoice_text + ' </span\n';
}
htmlCode += ' <span style="width: 20%;">' + "金額(未稅): " + AppendComma(obj.invoice_noTaxMoney) + ' </span>\n';
htmlCode += ' <span style="width: 50%;"></span>';
htmlCode += ' <div class="btn-group ml-auto">\n';

View File

@ -140,7 +140,7 @@ function buttonClick(obj) {
$("#user_uid").val(obj.user_uid);
$("#user_type").val(obj.user_type).trigger('change');
$("#user_perm").val(obj.user_perm).trigger('change');
$("#user_engName").val(obj.user_engName).trigger('change');
if (obj.user_type == "N") {
$("#user_elabName").val(obj.user_id).trigger('change');
@ -233,6 +233,7 @@ $(document).ready(function () {
var user_id = $("#user_id").val();
var user_elabName = $("#user_elabName").val();
var user_name = $("#user_name").val();
var user_engName = $("#user_engName").val();
var user_pwd = $("#user_pwd").val();
var user_chkpwd = $("#user_chkpwd").val();
var user_email = $("#user_email").val();
@ -299,6 +300,7 @@ $(document).ready(function () {
user_id: user_id,
user_elabName: user_elabName,
user_name: user_name,
user_engName: user_engName,
user_email: user_email,
user_pwd: user_pwd,
user_perm: user_perm,
@ -358,6 +360,7 @@ $(document).ready(function () {
if (user_type == "Y") {
$("#user_elab_div").hide();
$("#user_name_div").show();
$("#user_engname_div").show();
$("#user_id_div").show();
$("#user_pwd_div").show();
$("#user_chkpwd_div").show();
@ -365,6 +368,7 @@ $(document).ready(function () {
} else {
$("#user_elab_div").show();
$("#user_name_div").hide();
$("#user_engname_div").show();
$("#user_id_div").hide();
$("#user_pwd_div").hide();
$("#user_chkpwd_div").hide();

Binary file not shown.

Binary file not shown.