u
This commit is contained in:
@@ -105,14 +105,15 @@ export default function add(provider) {
|
||||
const transactionText = String(rawTransactionText);
|
||||
|
||||
const doAdd = async (runner) => {
|
||||
const { companyId } = await access(googleAuthId, runner);
|
||||
const { companyId, companyuserId, rootCategoryId } = await access(googleAuthId, runner);
|
||||
|
||||
const check = await runner.query(queries.CHECK_MANIFESTARTICLE_ACCESS, {
|
||||
manifestarticleId,
|
||||
companyId,
|
||||
});
|
||||
|
||||
if (!check.rows[0]) {
|
||||
const manifestArticle = check.rows[0];
|
||||
if (!manifestArticle) {
|
||||
throw new Error('Manifest article not found');
|
||||
}
|
||||
|
||||
@@ -134,6 +135,22 @@ export default function add(provider) {
|
||||
throw new Error('Failed to insert ledger entry');
|
||||
}
|
||||
|
||||
const sku = manifestArticle.sku ? String(manifestArticle.sku).trim() : '';
|
||||
if (sku) {
|
||||
const articleMatches = await runner.query(queries.FIND_ARTICLES_FOR_HISTORY, {
|
||||
sku,
|
||||
companyId,
|
||||
});
|
||||
|
||||
for (const match of articleMatches.rows) {
|
||||
await runner.query(queries.INSERT_ARTICLE_HISTORY, {
|
||||
articleId: match.articleId,
|
||||
companyuserId,
|
||||
text: transactionText,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return shape(row);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user