feat: add admin transaction create/update with auto payment status sync
Allow admins to edit transaction amount and status, recalculate payment totals, and mark invoices fully paid when paid transactions cover the payable amount.
This commit is contained in:
@@ -46,3 +46,15 @@ exports.getMyPayments = catchAsync(async (req, res, next) => {
|
||||
const { data, meta } = await paymentService.getMyPayments(req.user._id, req.query);
|
||||
return listResponse(res, 200, data, meta);
|
||||
});
|
||||
|
||||
exports.createTransaction = catchAsync(async (req, res, next) => {
|
||||
const actorId = req.user?._id;
|
||||
const payment = await paymentService.addTransaction(req.params.paymentId, req.body, actorId);
|
||||
return successResponse(res, 201, 'Payment transaction recorded', payment);
|
||||
});
|
||||
|
||||
exports.updateTransaction = catchAsync(async (req, res, next) => {
|
||||
const actorId = req.user?._id;
|
||||
const payment = await paymentService.updateTransaction(req.params.transactionId, req.body, actorId);
|
||||
return successResponse(res, 200, 'Transaction updated successfully', payment);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user