Forráskód Böngészése

[FIX] undefined variables

robert 5 éve
szülő
commit
b0324283bb
3 módosított fájl, 20 hozzáadás és 11 törlés
  1. 2 1
      src/components/steps/Payment.vue
  2. 10 10
      src/store/actions.js
  3. 8 0
      src/store/modules/payment.js

+ 2 - 1
src/components/steps/Payment.vue

@@ -73,7 +73,7 @@
                     format='DD/MM/YYYY'
                     :clearable='false'
                     :editable='false'
-                    :not-before='firstPayment'
+                    :not-before='firstPaymentAfterDate'
                 )
             //- input para el vuelto del pago en caso de pago en efectivo
             div(v-show="paymentType === 'cash'")
@@ -161,6 +161,7 @@
                 'amountResidual',
                 'paymentLines',
                 'firstPaymentDate',
+                'firstPaymentAfterDate',
                 'cartItems',
                 'paymentType',
                 'paymentTerm',

+ 10 - 10
src/store/actions.js

@@ -162,11 +162,11 @@ const actions = {
                         packs: item.packs
                     }
                 }),
-                customerId: getters.selectedCustomer.id,
-                customerPricelistId: getters.customerPricelist.id,
-                currencyId: getters.selectedCurrency.id,
-                warehouseId: getters.selectedWarehouse.id,
-                userId: getters.selectedUser.id,
+                customerId: (getters.selectedCustomer && getters.selectedCustomer.id) || null,
+                customerPricelistId: (getters.customerPricelist && getters.customerPricelist.id) || null,
+                currencyId: (getters.selectedCurrency && getters.selectedCurrency.id) || null,
+                warehouseId: (getters.selectedWarehouse && getters.selectedWarehouse.id) || null,
+                userId: (getters.selectedUser && getters.selectedUser.id) || null,
             }
         }
 
@@ -179,10 +179,10 @@ const actions = {
                 journalId: getters.selectedJournal.id,
                 payment: getters.initialPayment > getters.amountToPay ? getters.amountToPay : getters.initialPayment,
                 paymentMethod: getters.paymentMethod,
-                customerId: getters.selectedCustomer.id,
-                customerPricelistId: getters.customerPricelist.id,
-                currencyId: getters.selectedCurrency.id,
-                warehouseId: getters.selectedWarehouse.id,
+                customerId: (getters.selectedCustomer && getters.selectedCustomer.id) || null,
+                customerPricelistId: (getters.customerPricelist && getters.customerPricelist.id) || null,
+                currencyId: (getters.selectedCurrency && getters.selectedCurrency.id) || null,
+                warehouseId: (getters.selectedWarehouse && getters.selectedWarehouse.id) || null,
                 bankPaymentData: {
                     ...getters.bankPaymentData
                 }
@@ -192,7 +192,7 @@ const actions = {
         if (mode === 'product_delivery') {
             data = {
                 ...data,
-                stockPickingId: getters.selectedStockPicking.id
+                stockPickingId: (getters.selectedStockPicking && getters.selectedStockPicking.id) || null
             }
         }
 

+ 8 - 0
src/store/modules/payment.js

@@ -10,6 +10,7 @@ const state = {
     amountResidual: 0,
     paymentLines: [],
     firstPaymentDate: new Date(),
+    firstPaymentAfterDate: new Date(),
     bankPaymentData: null,
 }
 
@@ -79,6 +80,9 @@ const getters = {
 
         return state.firstPaymentDate
     },
+    firstPaymentAfterDate(state) {
+        return state.firstPaymentAfterDate
+    },
     bankPaymentData(state) {
         return state.bankPaymentData
     }
@@ -200,6 +204,10 @@ const mutations = {
     },
     setFirstPaymentDate(state, paymentDate) {
         state.firstPaymentDate = paymentDate
+
+        if (moment(state.firstPaymentAfterDate).isSameOrBefore(paymentDate)) {
+            state.firstPaymentAfterDate = paymentDate
+        }
     },
     setBankPaymentData(state, bankPaymentData) {
         state.bankPaymentData = bankPaymentData