Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tiny): Updating with https://github.com/ecomplus/app-tiny-erp #218

Merged
merged 11 commits into from
Oct 3, 2023

Conversation

wisley7l
Copy link
Member

No description provided.

@wisley7l wisley7l changed the title [WIP] fix(tiny): Update app fix(tiny): Updating with https://github.com/ecomplus/app-tiny-erp Sep 20, 2023
@wisley7l wisley7l requested a review from leomp12 September 20, 2023 16:24
const tinyOrder = parseOrder(order, appData);
logger.info(`${orderId} ${JSON.stringify(tinyOrder)}`);
return postTiny('/pedido.incluir.php', {
pedido: {
pedido: tinyOrder,
},
}).then((response) => {
// TODO: middleware ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO: middleware ?

// https://github.com/ecomplus/app-tiny-erp/blob/d5eef0c6be83485805ec94ba801a8cf111d24ed6/functions/lib/integration/export-order.js#L91
const updateTrackingCode = global.$tinyErpUpdateTrackingCode;
if (updateTrackingCode && typeof updateTrackingCode === 'function') {
return updateTrackingCode(response, order, postTiny);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return updateTrackingCode(response, order, postTiny);
return updateTrackingCode({ response, order, postTiny });

Especialmente nesses middlewares a gente não sabe se vai ter que adicionar parâmetros depois, muito granularizado pra cada app, melhor convencionar sempre um argumento só, sempre um objeto.

Comment on lines 71 to 85
const validStatusesTiny = {
aberto: true,
cancelado: true,
aprovado: true,
preparando_envio: true,
faturado: true,
};

if (
validStatusesTiny[tinyStatus]
&& (!order.fulfillment_status || order.fulfillment_status.current !== 'ready_for_shipping')
) {
logger.info(`${orderId} skipped with status "${tinyStatus}"`);
return null;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esse trecho aqui deveria ser um switch case né, foi copiado? Nem sabia que ele existia no outro repo...
cc @matheusgnreis

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não é um erro aqui, só um comentário especialmente pra uma ocasião parecida no futuro

Comment on lines 65 to 68
const setWeightUnitProduct = global.$tinyErpSetWeightUnitProduct;
if (setWeightUnitProduct && typeof setWeightUnitProduct === 'function') {
setWeightUnitProduct({ product });
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esse aqui tá esquisito, é só pra setar uma unidade padrão pro peso? Se for deveria ser só um metafield no config.json em vez de um middleware

@@ -124,6 +127,11 @@ export default (order: Orders, appData) => {
}
}

const middlewareOrderParser = global.$tinyErpOrderParser;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um middleware tá nomeado no imperativo (UpdateTrackingCode) e outro não, é bom tentar manter o padrões...

const tinyOrder = parseOrder(order, appData);
logger.info(`${orderId} ${JSON.stringify(tinyOrder)}`);
return postTiny('/pedido.incluir.php', {
pedido: {
pedido: tinyOrder,
},
}).then((response) => {
// https://github.com/ecomplus/app-tiny-erp/blob/d5eef0c6be83485805ec94ba801a8cf111d24ed6/functions/lib/integration/export-order.js#L91
const updateTrackingCode = global.$tinyErpUpdateTrackingCode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Além do tempo verbal no nome das funções, na verdade isso aqui nem necessariamente é pra tracking code inclusive, talvez global.$tinyErpOnNewOrder ?

Copy link
Member

@leomp12 leomp12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valeu @wisley7l 👍🏾

@leomp12 leomp12 merged commit a5ffd26 into main Oct 3, 2023
1 check passed
@leomp12 leomp12 deleted the fix/update-tiny-app branch October 3, 2023 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants