Compare commits

..

4 commits

4 changed files with 60 additions and 49 deletions

View file

@ -108,8 +108,8 @@ func connect() {
array2 := []string{} array2 := []string{}
results, err := db.Query(`SELECT IFNULL(o.controlNo, '') AS result, IF(c.firstName IS NULL OR c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', IF(c.middleInitial IS NULL OR c.middleInitial = '', '', CONCAT(c.middleInitial, '. ')), c.lastName) ) AS result2 results, err := db.Query(`SELECT IFNULL(o.controlNo, '') AS result, IF(c.firstName IS NULL OR c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', IF(c.middleInitial IS NULL OR c.middleInitial = '', '', CONCAT(c.middleInitial, '. ')), c.lastName) ) AS result2
FROM occupancy o JOIN customer c ON o.customerid = c.customerid JOIN ref_occupancy_type ot ON o.ref_occupancy_typeid = ot.ref_occupancy_typeid JOIN ref_occupancy ro ON ot.ref_occupancyid = ro.ref_occupancyid JOIN occupancydocflowtxn od ON o.occupancyid = od.occupancyreceivingid FROM occupancy o JOIN customer c ON o.customerid = c.customerid JOIN ref_occupancy_type ot ON o.ref_occupancy_typeid = ot.ref_occupancy_typeid JOIN ref_occupancy ro ON ot.ref_occupancyid = ro.ref_occupancyid JOIN occupancydocflowtxn od ON o.occupancyid = od.occupancyreceivingid JOIN (SELECT occupancyreceivingid, MAX(occupancydocflowtxnid) AS latest_occupancydocflowtxnid FROM occupancydocflowtxn GROUP BY occupancyreceivingid) latest_doc ON od.occupancyreceivingid = latest_doc.occupancyreceivingid AND od.occupancydocflowtxnid = latest_doc.latest_occupancydocflowtxnid
JOIN (SELECT occupancyreceivingid, MAX(occupancydocflowtxnid) AS latest_occupancydocflowtxnid FROM occupancydocflowtxn GROUP BY occupancyreceivingid) latest_doc ON od.occupancyreceivingid = latest_doc.occupancyreceivingid AND od.occupancydocflowtxnid = latest_doc.latest_occupancydocflowtxnid WHERE remarks = ? AND is_approve = 0 ORDER BY od.txndate DESC`, "FOR OCCUPANCY RECOMMENDING APPROVAL") WHERE (remarks = "FOR OCCUPANCY RECOMMENDING APPROVAL" OR remarks = "FOR ADDITIONAL ORDER OF PAYMENT RECOMMENDING APPROVAL") AND od.is_approve = 0 ORDER BY od.txndate DESC`)
if err != nil { if err != nil {
c.AbortWithError(http.StatusBadRequest, err) c.AbortWithError(http.StatusBadRequest, err)
c.String(http.StatusBadRequest, err.Error()) c.String(http.StatusBadRequest, err.Error())
@ -137,7 +137,7 @@ func connect() {
array2 := []string{} array2 := []string{}
results, err := db.Query(`SELECT IFNULL(e.electricalno, '') AS result, IF(c.firstName IS NULL OR c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', IF(c.middleInitial IS NULL OR c.middleInitial = '', '', CONCAT(c.middleInitial, '. ')), c.lastName) ) AS result2 results, err := db.Query(`SELECT IFNULL(e.electricalno, '') AS result, IF(c.firstName IS NULL OR c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', IF(c.middleInitial IS NULL OR c.middleInitial = '', '', CONCAT(c.middleInitial, '. ')), c.lastName) ) AS result2
FROM iips.electrical e JOIN iips.customer c ON e.customerid = c.customerid JOIN iips.ref_elec_occupancy ec ON e.ref_elec_occupancyid = ec.ref_elec_occupancyid JOIN iips.electricaldocflowtxn ed ON e.electricalid = ed.electricalid JOIN (SELECT electricalid, MAX(electricaldocflowtxnid) AS latest_electricaldocflowtxnid FROM electricaldocflowtxn GROUP BY electricalid) latest_doc ON ed.electricalid = latest_doc.electricalid AND ed.electricaldocflowtxnid = latest_doc.latest_electricaldocflowtxnid WHERE remarks = ? AND is_approve = 0 ORDER BY ed.txndate DESC`, "FOR ELECTRICAL ORDER OF PAYMENT APPROVAL") FROM iips.electrical e JOIN iips.customer c ON e.customerid = c.customerid JOIN iips.ref_elec_occupancy ec ON e.ref_elec_occupancyid = ec.ref_elec_occupancyid JOIN iips.electricaldocflowtxn ed ON e.electricalid = ed.electricalid JOIN (SELECT electricalid, MAX(electricaldocflowtxnid) AS latest_electricaldocflowtxnid FROM electricaldocflowtxn GROUP BY electricalid) latest_doc ON ed.electricalid = latest_doc.electricalid AND ed.electricaldocflowtxnid = latest_doc.latest_electricaldocflowtxnid WHERE remarks = ? AND is_approve = 0 ORDER BY ed.txndate DESC`, "FOR ELECTRICAL ORDER OF PAYMENT APPROVAL")
if err != nil { if err != nil {
c.AbortWithError(http.StatusBadRequest, err) c.AbortWithError(http.StatusBadRequest, err)
c.String(http.StatusBadRequest, err.Error()) c.String(http.StatusBadRequest, err.Error())
@ -1214,7 +1214,7 @@ func connect() {
router.POST("/api/update-docflow-occupancy", middleware.TokenChecker(), func(c *gin.Context) { router.POST("/api/update-docflow-occupancy", middleware.TokenChecker(), func(c *gin.Context) {
type UpdateDocflowData struct { type UpdateDocflowData struct {
Data int `json:"data"` Data string `json:"data"`
Data2 string `json:"data2"` Data2 string `json:"data2"`
} }
var updateDocflowData UpdateDocflowData var updateDocflowData UpdateDocflowData
@ -1230,7 +1230,7 @@ func connect() {
c.Writer.Header().Set("X-Download-Options", "noopen") c.Writer.Header().Set("X-Download-Options", "noopen")
c.Writer.Header().Set("Referrer-Policy", "no-referrer") c.Writer.Header().Set("Referrer-Policy", "no-referrer")
dbpost, err := db.Prepare("UPDATE occupancydocflowtxn SET is_approve = 1 WHERE occupancyreceivingid = ? AND remarks = ?") dbpost, err := db.Prepare("UPDATE occupancydocflowtxn SET is_approve = 1 WHERE remarks = ? AND occupancyreceivingid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?)")
if err != nil { if err != nil {
c.AbortWithError(http.StatusInternalServerError, err) c.AbortWithError(http.StatusInternalServerError, err)
c.String(http.StatusInternalServerError, "Internal Server Error") c.String(http.StatusInternalServerError, "Internal Server Error")
@ -1261,7 +1261,7 @@ func connect() {
router.POST("/api/update-docflow-electrical", middleware.TokenChecker(), func(c *gin.Context) { router.POST("/api/update-docflow-electrical", middleware.TokenChecker(), func(c *gin.Context) {
type UpdateDocflowData struct { type UpdateDocflowData struct {
Data int `json:"data"` Data string `json:"data"`
Data2 string `json:"data2"` Data2 string `json:"data2"`
} }
var updateDocflowData UpdateDocflowData var updateDocflowData UpdateDocflowData
@ -1277,7 +1277,7 @@ func connect() {
c.Writer.Header().Set("X-Download-Options", "noopen") c.Writer.Header().Set("X-Download-Options", "noopen")
c.Writer.Header().Set("Referrer-Policy", "no-referrer") c.Writer.Header().Set("Referrer-Policy", "no-referrer")
dbpost, err := db.Prepare("UPDATE electricaldocflowtxn SET is_approve = 1 WHERE electricalid = ? AND remarks = ?") dbpost, err := db.Prepare("UPDATE electricaldocflowtxn SET is_approve = 1 WHERE remarks = ? AND electricalid = (SELECT electricalid FROM electrical WHERE electricalNo = ?)")
if err != nil { if err != nil {
c.AbortWithError(http.StatusInternalServerError, err) c.AbortWithError(http.StatusInternalServerError, err)
c.String(http.StatusInternalServerError, "Internal Server Error") c.String(http.StatusInternalServerError, "Internal Server Error")
@ -1323,7 +1323,7 @@ func connect() {
c.Writer.Header().Set("X-Download-Options", "noopen") c.Writer.Header().Set("X-Download-Options", "noopen")
c.Writer.Header().Set("Referrer-Policy", "no-referrer") c.Writer.Header().Set("Referrer-Policy", "no-referrer")
dbpost, err := db.Prepare("UPDATE iips.occupancy_orderofpayment SET popstransmitted = 1, is_release = 1 WHERE occupancyid = ? AND for_approval = 1 AND is_paid = 0 AND is_approve = 1") dbpost, err := db.Prepare("UPDATE occupancy_orderofpayment SET popstransmitted = 1, is_release = 1 WHERE occupancyid = ? AND for_approval = 1 AND is_paid = 0 AND is_approve = 1")
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())
} }

View file

@ -212,8 +212,6 @@ export default () => {
} }
const printHandler = async (division: string, application: string) => { const printHandler = async (division: string, application: string) => {
let signed: boolean = false
let forprinting: boolean = false
let updateOrderofpayment: boolean = false let updateOrderofpayment: boolean = false
setConnected(await checkConnection()) setConnected(await checkConnection())
@ -222,22 +220,28 @@ export default () => {
return return
} }
// signed = await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT PRINTED', '171', 'ELECOPPRINTED', 1)
// if (!signed) return
// forprinting = await setNewStatus(division, 'FOR ELECTRICAL OFFICIAL RECEIPT VALIDATION', '98', 'ELECORVALIDATE', 0)
// if (!forprinting) return
// updateOrderofpayment = await updateOp(division)
// if (updateOrderofpayment) {
// postTransaction(application)
setPrintedApplication(application)
setPrinted(true)
if (division === 'electrical') { if (division === 'electrical') {
createPdf() await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT PRINTED', '171', 'ELECOPPRINTED', 1)
} else createPdfOccupancy() await setNewStatus(division, 'ELECTRICAL ORDERPAYMENT RELEASED', '97', 'ELECRELEASED', 1)
// } await setNewStatus(division, 'FOR ELECTRICAL OFFICIAL RECEIPT VALIDATION', '98', 'ELECORVALIDATE', 0)
await updateDocflow(division, application, 'FOR ELECTRICAL ORDER OF PAYMENT PRINTING')
} else if (division === 'occupancy') {
await setNewStatus(division, 'OCCUPANCY ORDER OF PAYMENT PRINTED', '173', 'OCCOPPRINTED', 1)
await setNewStatus(division, 'OCCUPANCY ORDER OF PAYMENT RELEASED', '174', 'OCCOPRELEASED', 1)
await setNewStatus(division, 'ORDER OF PAYMENT RELEASE FOR BUREAU OF FIRE', '24', 'OCOOPRELEASE', 0)
await updateDocflow(division, application, 'APPROVED FOR PRINTING OF BUREAU OF FIRE AND ORDER OF PAYMENT')
}
updateOrderofpayment = await updateOp(division)
if (updateOrderofpayment) {
postTransaction(application)
setPrintedApplication(application)
setPrinted(true)
if (division === 'electrical') {
createPdf()
} else createPdfOccupancy()
}
} }
const updateOp = async (division: string) => { const updateOp = async (division: string) => {
@ -254,6 +258,10 @@ export default () => {
return post return post
} }
const updateDocflow = async (division: string, application: string, status: string) => {
await postApi(`update-docflow-${division}`, { data: status, data2: application })
}
const getSignatureImage = async (id: number) => { const getSignatureImage = async (id: number) => {
try { try {
const response = await getApi('get-signatureimage', id) const response = await getApi('get-signatureimage', id)
@ -490,7 +498,7 @@ export default () => {
<section class="modal__row"> <section class="modal__row">
<span class="modal__row__label">Total Fee:</span> <span class="modal__row__label">Total Fee:</span>
<span class="modal__row__detail__price"> <span class="modal__row__detail__price">
{PESO} {totalOp().toFixed(2)} {PESO} {totalOp().toLocaleString('en-US', { minimumFractionDigits: 2 })}
</span> </span>
</section> </section>
</Padding> </Padding>
@ -578,7 +586,7 @@ export default () => {
<section class="modal__row"> <section class="modal__row">
<span class="modal__row__label">Total Fee:</span> <span class="modal__row__label">Total Fee:</span>
<span class="modal__row__detail__price"> <span class="modal__row__detail__price">
{PESO} {totalOp().toFixed(2)} {PESO} {totalOp().toLocaleString('en-US', { minimumFractionDigits: 2 })}
</span> </span>
</section> </section>
</Padding> </Padding>

View file

@ -166,8 +166,8 @@ export default () => {
if (division === 'electrical') { if (division === 'electrical') {
signed = await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED', 1) signed = await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED', 1)
const approvedid = await getIdByApplication(division, application) // const approvedid = await getIdByApplication(division, application)
updateDocflow(division, approvedid, 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL') updateDocflow(division, application, 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL')
if (!signed) return if (!signed) return
forprinting = await setNewStatus(division, 'FOR ELECTRICAL ORDER OF PAYMENT PRINTING', '95', 'ELECOPPRINT', 0) forprinting = await setNewStatus(division, 'FOR ELECTRICAL ORDER OF PAYMENT PRINTING', '95', 'ELECOPPRINT', 0)
@ -183,8 +183,9 @@ export default () => {
} }
} else if (division === 'occupancy') { } else if (division === 'occupancy') {
signed = await setNewStatus(division, 'OCCUPANCY ORDER OF PAYMENT APPROVED AND SIGNED', '172', 'OCCOPAPPROVEDSIGNED', 1) signed = await setNewStatus(division, 'OCCUPANCY ORDER OF PAYMENT APPROVED AND SIGNED', '172', 'OCCOPAPPROVEDSIGNED', 1)
const approvedid = await getIdByApplication(division, application) // const approvedid = await getIdByApplication(division, application)
updateDocflow(division, approvedid, 'FOR OCCUPANCY RECOMMENDING APPROVAL') updateDocflow(division, application, 'FOR OCCUPANCY RECOMMENDING APPROVAL')
updateDocflow(division, application, 'FOR ADDITIONAL ORDER OF PAYMENT RECOMMENDING APPROVAL')
if (!signed) return if (!signed) return
forprinting = await setNewStatus(division, 'APPROVED FOR PRINTING OF BUREAU OF FIRE AND ORDER OF PAYMENT', '23', 'OCORDEROFPAYMENT', 0) forprinting = await setNewStatus(division, 'APPROVED FOR PRINTING OF BUREAU OF FIRE AND ORDER OF PAYMENT', '23', 'OCORDEROFPAYMENT', 0)
@ -333,23 +334,25 @@ export default () => {
await postApi('post-esigntransaction', { data: parseInt(id), data2: approvedApplication(), data3: formatedDate }) await postApi('post-esigntransaction', { data: parseInt(id), data2: approvedApplication(), data3: formatedDate })
} }
const updateDocflow = async (division: string, applicationid: number, status: string) => { const updateDocflow = async (division: string, application: string, status: string) => {
if (division === 'electrical') { // if (division === 'electrical') {
await postApi('update-docflow-electrical', { data: parseInt(applicationid.toString()), data2: status }) // await postApi('update-docflow-electrical', { data: parseInt(applicationid.toString()), data2: status })
} else if (division === 'occupancy') { // } else if (division === 'occupancy') {
await postApi('update-docflow-occupancy', { data: parseInt(applicationid.toString()), data2: status }) // await postApi('update-docflow-occupancy', { data: parseInt(applicationid.toString()), data2: status })
} // }
await postApi(`update-docflow-${division}`, { data: status, data2: application })
} }
const getIdByApplication = async (division: string, applicationNo: string) => { // const getIdByApplication = async (division: string, applicationNo: string) => {
let response // let response
if (division === 'electrical') { // if (division === 'electrical') {
response = await getApi('get-idbyapplication-electrical', applicationNo) // response = await getApi('get-idbyapplication-electrical', applicationNo)
} else if (division === 'occupancy') { // } else if (division === 'occupancy') {
response = await getApi('get-idbyapplication-occupancy', applicationNo) // response = await getApi('get-idbyapplication-occupancy', applicationNo)
} // }
return parseInt(response) // return parseInt(response)
} // }
const refresh = async (division: string) => { const refresh = async (division: string) => {
if (division === 'electrical') { if (division === 'electrical') {

View file

@ -195,7 +195,7 @@ export default async () => {
yPosition = 82 yPosition = 82
AMOUNTS.forEach((amount) => { AMOUNTS.forEach((amount) => {
doc.text(`${PESO} ${parseInt(amount).toFixed(2)}`, 122, yPosition) doc.text(`${PESO} ${parseInt(amount).toLocaleString('en-US', { minimumFractionDigits: 2 })}`, 122, yPosition)
yPosition += 4 yPosition += 4
}) })
@ -206,7 +206,7 @@ export default async () => {
yPosition = 82 yPosition = 82
AMOUNTS.forEach((amount) => { AMOUNTS.forEach((amount) => {
doc.text(`${PESO} ${parseInt(amount).toFixed(2)}`, 156, yPosition) doc.text(`${PESO} ${parseInt(amount).toLocaleString('en-US', { minimumFractionDigits: 2 })}`, 156, yPosition)
yPosition += 4 yPosition += 4
}) })
@ -218,7 +218,7 @@ export default async () => {
doc.setFont('arial-bold', 'bold') doc.setFont('arial-bold', 'bold')
doc.text('Total :', 146, newYPosition + 4) doc.text('Total :', 146, newYPosition + 4)
const totalAmount = AMOUNTS.reduce((sum, amount) => sum + parseFloat(amount), 0) const totalAmount = AMOUNTS.reduce((sum, amount) => sum + parseFloat(amount), 0)
doc.text(`${PESO} ${totalAmount.toFixed(2)}`, 156, newYPosition + 4) doc.text(`${PESO} ${totalAmount.toLocaleString('en-US', { minimumFractionDigits: 2 })}`, 156, newYPosition + 4)
doc.text('Assessed By :', 16, newYPosition + 12) doc.text('Assessed By :', 16, newYPosition + 12)
doc.text('Approved By :', 142, newYPosition + 12) doc.text('Approved By :', 142, newYPosition + 12)