Explorar o código

include last purchase order to subscription page

Olivier Massot hai 8 meses
pai
achega
a4a3d72a91
Modificáronse 4 ficheiros con 51 adicións e 5 borrados
  1. 1 0
      i18n/lang/fr.json
  2. 3 0
      models/Organization/DolibarrAccount.ts
  3. 42 5
      pages/subscription.vue
  4. 5 0
      types/enum/enums.ts

+ 1 - 0
i18n/lang/fr.json

@@ -543,6 +543,7 @@
   "client_id": "Numéro de client",
   "version": "Version logiciel",
   "services": "Services",
+  "purchase_order": "Bon de commande",
   "bills": "Factures",
   "paid": "Payée",
   "unpaid": "Impayée",

+ 3 - 0
models/Organization/DolibarrAccount.ts

@@ -26,6 +26,9 @@ export default class DolibarrAccount extends ApiResource {
   @Attr({})
   declare contract: object
 
+  @Attr(null)
+  declare order: object
+
   @Attr([])
   declare bills: Array<{
     ref: string

+ 42 - 5
pages/subscription.vue

@@ -65,7 +65,41 @@ Page 'Mon abonnement'
       </UiExpansionPanel>
 
       <UiExpansionPanel
-        v-if="showDolibarrPanel"
+        v-if="dolibarrAccount !== null && dolibarrAccount.order"
+        title="purchase_order"
+        icon="fas fa-file"
+      >
+        <v-container :fluid="true" class="container">
+          <v-row>
+            <v-table>
+              <thead>
+              <tr>
+                <th>{{ $t('reference') }}</th>
+                <th>{{ $t('date') }}</th>
+                <th></th>
+              </tr>
+              </thead>
+              <tbody>
+              <tr>
+                <td>{{ dolibarrAccount.order.ref }}</td>
+                <td>{{ $d(dolibarrAccount.order.date) }}</td>
+                <td>
+                  <a
+                    @click="downloadDolibarrBillingDoc(DOLIBARR_BILLING_DOC_TYPE.ORDER, dolibarrAccount.order.ref)"
+                    class="clickable"
+                  >
+                    {{ $t('download') }}
+                  </a>
+                </td>
+              </tr>
+              </tbody>
+            </v-table>
+          </v-row>
+        </v-container>
+      </UiExpansionPanel>
+
+      <UiExpansionPanel
+        v-if="showDolibarrBillsPanel"
         title="bills"
         icon="fas fa-file"
       >
@@ -98,7 +132,7 @@ Page 'Mon abonnement'
                   </td>
                   <td>
                     <a
-                      @click="downloadDolibarrBill(bill.ref)"
+                      @click="downloadDolibarrBillingDoc(DOLIBARR_BILLING_DOC_TYPE.INVOICE, bill.ref)"
                       class="clickable"
                     >
                       {{ $t('download') }}
@@ -440,6 +474,7 @@ import UrlUtils from '~/services/utils/urlUtils'
 import { useDownloadFromRoute } from '~/composables/utils/useDownloadFromRoute'
 import { useApiLegacyRequestService } from '~/composables/data/useApiLegacyRequestService'
 import { usePageStore } from '~/stores/page'
+import {DOLIBARR_BILLING_DOC_TYPE} from '~/types/enum/enums';
 
 //meta
 definePageMeta({
@@ -467,12 +502,13 @@ const { data: dolibarrAccount, pending: dolibarrPending } = fetch(
   organizationProfile.id,
 )
 
-const showDolibarrPanel = computed(
+const showDolibarrBillsPanel = computed(
   () =>
     !dolibarrPending.value &&
     dolibarrAccount.value &&
     dolibarrAccount.value.bills.length > 0,
 )
+
 const formatCurrency = (value: number, currency: string): string => {
   return value.toLocaleString(i18n.locale.value, {
     style: 'currency',
@@ -526,6 +562,7 @@ function initPanel(): Ref<Array<string>> {
     openedPanels.value = [
       'subscription_page',
       'service_detail',
+      'purchase_order',
       'bills',
       'opentalent_offers',
       'opentalent_options',
@@ -615,8 +652,8 @@ async function stopTrial() {
   })
 }
 
-const downloadDolibarrBill = (ref: string): void => {
-  const route = UrlUtils.join('api/dolibarr/download/invoice', ref)
+const downloadDolibarrBillingDoc = (type: DOLIBARR_BILLING_DOC_TYPE, ref: string): void => {
+  const route = UrlUtils.join('api/dolibarr/download', type, encodeURIComponent(ref))
 
   useDownloadFromRoute(route, `${ref}.pdf`)
 }

+ 5 - 0
types/enum/enums.ts

@@ -111,3 +111,8 @@ export const enum TABLE_ACTION {
   DELETE = 'delete',
   ADD = 'add',
 }
+
+export const enum DOLIBARR_BILLING_DOC_TYPE {
+  INVOICE = 'invoice',
+  ORDER = 'order',
+}