ソースを参照

لغو همه صورتحساب های درحال پرداخت

hgh 1 年間 前
親
コミット
5e09655358

+ 15 - 0
src/api/models/Invoice.js

@@ -10,6 +10,7 @@ export default class InvoiceAPI extends APIRepository {
       byId: (id) => '/accounting/invoices/' + id,
       pay: (id) => '/accounting/invoices/' + id + '/pay',
       cancel: (id) => '/accounting/invoices/' + id + '/cancel',
+      cancelAllPayingInvoices: '/accounting/invoices/cancel_all_paying_invoices',
       exportInvoiceReport: '/accounting/invoices/export_report'
     }
     this.CacheList = {
@@ -70,6 +71,20 @@ export default class InvoiceAPI extends APIRepository {
     })
   }
 
+  cancelAllPayingInvoices() {
+    return this.sendRequest({
+      apiMethod: 'put',
+      api: this.api,
+      request: this.APIAdresses.cancelAllPayingInvoices,
+      resolveCallback: (response) => {
+        return response.data.detail // String : message
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
   cancel(invoiceId) {
     return this.sendRequest({
       apiMethod: 'put',

+ 20 - 1
src/components/Widgets/Invoice/AdminInvoiceList/AdminInvoiceList.vue

@@ -13,7 +13,15 @@
                   :show-expand-button="false"
                   :show-reload-button="false">
       <template #toolbar>
-        <q-btn color="primary"
+        <q-btn class="q-ml-sm"
+               color="red"
+               outline
+               :loading="exportReportLoading"
+               @click="cancelAllPayingInvoices">
+          لغو همه درحال پرداخت
+        </q-btn>
+        <q-btn class="q-ml-sm"
+               color="primary"
                :loading="exportReportLoading"
                @click="getInvoicesListExcel">
           دریافت
@@ -180,6 +188,17 @@ export default {
     search () {
       this.$refs.entityIndex.search()
     },
+    cancelAllPayingInvoices () {
+      this.exportReportLoading = true
+      APIGateway.invoice.cancelAllPayingInvoices()
+        .then(() => {
+          this.$refs.entityIndex.search()
+          this.exportReportLoading = false
+        })
+        .catch((e) => {
+          this.exportReportLoading = false
+        })
+    },
     getInvoicesListExcel () {
       this.exportReportLoading = true
       const filter = this.$refs.entityIndex.createParams()