diff --git a/src/modules/purchase/down-payment.js b/src/modules/purchase/down-payment.js index 39c6c91f..8a53d751 100644 --- a/src/modules/purchase/down-payment.js +++ b/src/modules/purchase/down-payment.js @@ -153,6 +153,16 @@ const actions = { reject(error) }) }) + }, + sendBulkRequestApproval (context, payload) { + return new Promise((resolve, reject) => { + api.post(url + '/send-bulk-request-approval', payload) + .then(response => { + resolve(response) + }).catch(error => { + reject(error) + }) + }) } } diff --git a/src/modules/purchase/order-history.js b/src/modules/purchase/order-history.js new file mode 100644 index 00000000..74e7eb93 --- /dev/null +++ b/src/modules/purchase/order-history.js @@ -0,0 +1,56 @@ +import api from '@/api' + +const url = '/purchase/orders' + +const state = { + purchaseOrderHistories: [], + pagination: {} +} + +const getters = { + purchaseOrderHistories: state => { + return state.purchaseOrderHistories + }, + pagination: state => { + return state.pagination + } +} + +const mutations = { + 'FETCH_ARRAY' (state, payload) { + state.purchaseOrderHistories = payload.data + state.pagination = payload.meta + } +} + +const actions = { + get ({ commit }, payload) { + return new Promise((resolve, reject) => { + api.get(url + '/' + payload.id + '/histories', payload) + .then(response => { + commit('FETCH_ARRAY', response) + resolve(response) + }).catch(error => { + reject(error) + }) + }) + }, + add (context, payload) { + return new Promise((resolve, reject) => { + api.post(url + '/' + payload.id + '/histories', payload) + .then(response => { + resolve(response) + }).catch(error => { + reject(error) + }) + }) + } +} + +export default { + namespaced: true, + state, + getters, + mutations, + actions +} diff --git a/src/modules/purchase/order.js b/src/modules/purchase/order.js index 6a3cfcda..b4e0b991 100644 --- a/src/modules/purchase/order.js +++ b/src/modules/purchase/order.js @@ -22,6 +22,7 @@ const state = { items: [] }, purchaseOrders: [], + histories: [], pagination: {} } @@ -32,6 +33,9 @@ const getters = { purchaseOrders: state => { return state.purchaseOrders }, + histories: state => { + return state.histories + }, pagination: state => { return state.pagination } @@ -48,6 +52,10 @@ const mutations = { }) state.purchaseOrder = payload.data }, + 'FETCH_HISTORY' (state, payload) { + state.histories = payload.data + state.pagination = payload.meta + }, 'CREATE' (state, payload) { state.purchaseOrder = payload }, @@ -71,6 +79,27 @@ const actions = { }) }) }, + history ({ commit }, payload) { + return new Promise((resolve, reject) => { + api.get(url + '/history', payload) + .then(response => { + commit('FETCH_HISTORY', response) + resolve(response) + }).catch(error => { + reject(error) + }) + }) + }, + storeHistory (context, payload) { + return new Promise((resolve, reject) => { + api.post(url + '/history', payload) + .then(response => { + resolve(response) + }).catch(error => { + reject(error) + }) + }) + }, find ({ commit }, payload) { return new Promise((resolve, reject) => { api.get(url + '/' + payload.id, payload) @@ -151,6 +180,16 @@ const actions = { reject(error) }) }) + }, + sendBulkRequestApproval (context, payload) { + return new Promise((resolve, reject) => { + api.post(url + '/send-bulk-request-approval', payload) + .then(response => { + resolve(response) + }).catch(error => { + reject(error) + }) + }) } } diff --git a/src/views/Approval.vue b/src/views/Approval.vue index a5dccaab..27ba1667 100644 --- a/src/views/Approval.vue +++ b/src/views/Approval.vue @@ -147,6 +147,9 @@ export default { if (this.resourceType === 'CashAdvance') { ({ resource, projectName, approvalStatus } = await this.handleApprovalCashAdvance(headers)) } + if (this.resourceType === 'PurchaseOrder') { + ({ resource, projectName, approvalStatus } = await this.handleApprovalPurchaseOrder(headers)) + } if (this.resourceType === 'TransferSend') { this.handleApprovalTransferSend() } @@ -232,6 +235,27 @@ export default { } } }, + async handleApprovalPurchaseOrder (headers) { + let status = 0 + if (this.action === 'approve') { + status = 1 + } else if (this.action === 'reject') { + status = -1 + } + + console.log(this.token, this.id, status, headers) + const { data: { data: purchaseOrder } } = await axios.post('approval-with-token/purchase/orders', { token: this.token, id: this.id, status: status }) + if (purchaseOrder.form.approval_status == 0) { + this.warningMessage = 'Balance Not Enough' + } else if (purchaseOrder.form.approval_status != status) { + if (purchaseOrder.form.approval_status == 1) { + this.warningMessage = 'Purchase Order was approved before' + } else if (purchaseOrder.form.approval_status == -1) { + this.warningMessage = 'Purchase Order was rejected before' + } + } + return { resource: purchaseOrder, projectName: this.projectName, approvalStatus: purchaseOrder.form.approval_status } + }, async handleApprovalCashAdvance (headers) { let status = 0 if (this.action === 'approve') { diff --git a/src/views/ApprovalAll.vue b/src/views/ApprovalAll.vue index 581bd49c..5cd4eb7e 100644 --- a/src/views/ApprovalAll.vue +++ b/src/views/ApprovalAll.vue @@ -202,6 +202,9 @@ export default { if (this.resourceType === 'SalesDeliveryOrder') { this.handleApprovalDeliveryOrder() } + if (this.resourceType === 'PurchaseOrder') { + this.handleApprovalPurchaseOrder() + } if (this.resourceType === 'PaymentCollection') { this.handleApprovalPaymentCollection() } @@ -301,6 +304,17 @@ export default { }) } }, + async handleApprovalPurchaseOrder (headers) { + let activity = '' + if (this.action === 'approve') { + activity = 'approved by email' + } else if (this.action === 'reject') { + activity = 'rejected by email' + } + const bulkId = JSON.parse(this.$route.query.ids) + const { data: { data: purchaseOrders } } = await axios.post('approval-with-token/purchase/orders/bulk', { token: this.token, bulk_id: bulkId, status: this.actionCode, activity: activity }, { headers }) + this.resources = purchaseOrders + }, async handleApprovalCashAdvance (headers) { let activity = '' if (this.action === 'approve') { diff --git a/src/views/purchase/down-payment/Index.vue b/src/views/purchase/down-payment/Index.vue index 00265877..37f3d5bc 100644 --- a/src/views/purchase/down-payment/Index.vue +++ b/src/views/purchase/down-payment/Index.vue @@ -29,13 +29,22 @@ @input="filterSearch" /> -
|
+
+
+
+
+
+
+ + Down Payment +++ {{ tenantName }} +++ {{ tenantAddress }} + ++ {{ tenantPhone }} + ++
+
+
|
+ ||||||||||
+
+
+
+
+ Created by++ {{ dp.form.created_by.full_name }} +
+
+ Approved by++ {{ dp.form.request_approval_to.full_name }} + |
+