u
This commit is contained in:
26
src/store/payment/delete.js
Normal file
26
src/store/payment/delete.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { queriesFor, requireId } from '../logistics/helpers.js';
|
||||
import resolveSelectedCompanyAccess from '../companyuser/resolveSelectedCompanyAccess.js';
|
||||
import makeRunner from '../runner.js';
|
||||
|
||||
/**
|
||||
* Deletes a payment belonging to a manifest of the user's selected company.
|
||||
*
|
||||
* @param {number} googleAuthId - The id of the Google auth user.
|
||||
* @param {number} id - The payment id.
|
||||
* @param {object} [tx] - Optional transaction to run within.
|
||||
* @returns {Promise<void>}
|
||||
*
|
||||
* @example
|
||||
* await store.payment.delete(googleAuthId, 7);
|
||||
*/
|
||||
export default function del(provider) {
|
||||
const access = resolveSelectedCompanyAccess(provider);
|
||||
const q = queriesFor(provider);
|
||||
|
||||
return async (googleAuthId, id, tx) => {
|
||||
const paymentId = requireId(id, 'Payment');
|
||||
const runner = makeRunner(provider, tx);
|
||||
const { companyId } = await access(googleAuthId, runner);
|
||||
await runner.query(q.PAYMENT_DELETE, { id: paymentId, companyId });
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user