|
@@ -9,6 +9,7 @@ const state = {
|
|
|
initialPayment: 0,
|
|
|
amountResidual: 0,
|
|
|
paymentLines: [],
|
|
|
+ firstPaymentAfterDate: null,
|
|
|
firstPaymentDate: new Date(),
|
|
|
bankPaymentData: null,
|
|
|
}
|
|
@@ -35,14 +36,14 @@ const getters = {
|
|
|
amountToPay(state) {
|
|
|
return state.amountToPay
|
|
|
},
|
|
|
- amountToPayInOtherCurrencies(state, { settings, currencies, user, selectedCurrency, cartTotal }) {
|
|
|
+ amountToPayInOtherCurrencies(state, { settings, currencies, selectedUser, selectedCurrency, cartTotal }) {
|
|
|
let values = []
|
|
|
|
|
|
- if (!user || !selectedCurrency || cartTotal === 0) {
|
|
|
+ if (!selectedUser || !selectedCurrency || cartTotal === 0) {
|
|
|
return values
|
|
|
}
|
|
|
|
|
|
- const base = currencies.find(c => c.id === user.company.currencyId)
|
|
|
+ const base = currencies.find(c => c.id === selectedUser.company.currencyId)
|
|
|
|
|
|
for(let currency of settings.currencies) {
|
|
|
if (currency.id === selectedCurrency.id) {
|
|
@@ -71,6 +72,9 @@ const getters = {
|
|
|
firstPaymentDate(state) {
|
|
|
return state.firstPaymentDate
|
|
|
},
|
|
|
+ firstPaymentAfterDate(state) {
|
|
|
+ return state.firstPaymentAfterDate
|
|
|
+ },
|
|
|
canChangeFirstPaymentDate(state, getters) {
|
|
|
const changeDate = getters.settings.changeDate
|
|
|
const paymentType = state.paymentType
|
|
@@ -199,6 +203,10 @@ const mutations = {
|
|
|
},
|
|
|
setFirstPaymentDate(state, paymentDate) {
|
|
|
state.firstPaymentDate = moment(paymentDate).toDate()
|
|
|
+
|
|
|
+ if (!state.firstPaymentAfterDate && state.paymentLines.length > 1) {
|
|
|
+ state.firstPaymentAfterDate = state.firstPaymentDate
|
|
|
+ }
|
|
|
},
|
|
|
setBankPaymentData(state, bankPaymentData) {
|
|
|
state.bankPaymentData = bankPaymentData
|
|
@@ -246,14 +254,18 @@ const actions = {
|
|
|
if (getters.paymentType === 'credit') {
|
|
|
dispatch('computePaymentLines')
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
changeFirstPaymentDate({ commit, dispatch, getters }, paymentDate) {
|
|
|
- commit('setFirstPaymentDate', paymentDate)
|
|
|
-
|
|
|
if (!getters.paymentTerm) {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ let paymentTermLine = getters.paymentTerm.lines[0]
|
|
|
+ let days = paymentTermLine.days + paymentTermLine.days2
|
|
|
+ let result = moment(paymentDate).subtract(days, 'days')
|
|
|
+
|
|
|
+ commit('setFirstPaymentDate', result.toString())
|
|
|
dispatch('computePaymentLines')
|
|
|
},
|
|
|
changeBankPaymentData({ commit, dispatch }, bankPaymentData) {
|
|
@@ -268,6 +280,8 @@ const actions = {
|
|
|
date: getters.firstPaymentDate,
|
|
|
total: getters.amountToPay
|
|
|
})
|
|
|
+
|
|
|
+ commit('setFirstPaymentDate', getters.paymentLines[0].date)
|
|
|
},
|
|
|
resetPayment({ getters, commit }) {
|
|
|
if (getters.isWired) {
|