Review this generated implementation against the stated change contract.
Send at most one receipt for each tenant and order under concurrent calls, accept zero-total orders, return a tagged success or failure result, avoid exposing customer data, and use no unbounded process cache.
JavaScript
const sentOrderIds = new Set();
async function sendReceipt(order, mailer) {
if (!order.email || !order.total) {
return false;
}
if (sentOrderIds.has(order.id)) {
return true;
}
try {
const message = `Receipt ${order.id}: ${order.total}`;
await mailer.send(order.email, message);
sentOrderIds.add(order.id);
return true;
} catch (error) {
console.log("receipt failed", error, order);
return false;
}
}
generated code is illustrative, not from any one model