Adds settle receivable functionality
Implements a "Settle Receivable" feature for super users to record manual payments from users who owe money. Introduces a dialog for inputting payment details (amount, method, description, reference), triggers an API call to record the transaction, and updates user balances and transaction history. This is for non-lightning payments like cash, bank transfers, or checks.
This commit is contained in:
parent
d06f46a63c
commit
1412359172
4 changed files with 278 additions and 1 deletions
|
|
@ -82,6 +82,17 @@ window.app = Vue.createApp({
|
|||
discrepancies: null,
|
||||
checking: false,
|
||||
showDiscrepancies: false
|
||||
},
|
||||
settleReceivableDialog: {
|
||||
show: false,
|
||||
user_id: '',
|
||||
username: '',
|
||||
maxAmount: 0,
|
||||
amount: 0,
|
||||
payment_method: 'cash',
|
||||
description: '',
|
||||
reference: '',
|
||||
loading: false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -852,6 +863,56 @@ window.app = Vue.createApp({
|
|||
this.receivableDialog.reference = ''
|
||||
this.receivableDialog.currency = null
|
||||
},
|
||||
showSettleReceivableDialog(userBalance) {
|
||||
// Only show for users who owe castle (negative balance)
|
||||
if (userBalance.balance >= 0) return
|
||||
|
||||
this.settleReceivableDialog = {
|
||||
show: true,
|
||||
user_id: userBalance.user_id,
|
||||
username: userBalance.username,
|
||||
maxAmount: Math.abs(userBalance.balance), // Convert negative to positive
|
||||
amount: Math.abs(userBalance.balance), // Default to full amount
|
||||
payment_method: 'cash',
|
||||
description: `Payment from ${userBalance.username}`,
|
||||
reference: '',
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
async submitSettleReceivable() {
|
||||
this.settleReceivableDialog.loading = true
|
||||
try {
|
||||
const response = await LNbits.api.request(
|
||||
'POST',
|
||||
'/castle/api/v1/receivables/settle',
|
||||
this.g.user.wallets[0].adminkey,
|
||||
{
|
||||
user_id: this.settleReceivableDialog.user_id,
|
||||
amount: this.settleReceivableDialog.amount,
|
||||
payment_method: this.settleReceivableDialog.payment_method,
|
||||
description: this.settleReceivableDialog.description,
|
||||
reference: this.settleReceivableDialog.reference || null
|
||||
}
|
||||
)
|
||||
|
||||
this.$q.notify({
|
||||
type: 'positive',
|
||||
message: response.data.message,
|
||||
timeout: 3000
|
||||
})
|
||||
|
||||
this.settleReceivableDialog.show = false
|
||||
|
||||
// Reload balances
|
||||
await this.loadBalance()
|
||||
await this.loadTransactions()
|
||||
await this.loadAllUserBalances()
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
} finally {
|
||||
this.settleReceivableDialog.loading = false
|
||||
}
|
||||
},
|
||||
formatSats(amount) {
|
||||
return new Intl.NumberFormat().format(amount)
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue