In PayPal collect invoices script: Update throw unsuccessful invoices collections (#18572)

* Remove throw on `INVOICES_COLLECTED_SUCCESS.length === 0`

Effectively reverts https://github.com/overleaf/internal/pull/18310/commits/038377b511c56fab24959ce99b6f2c7d6429c282

See: https://digital-science.slack.com/archives/C20TZCMMF/p1716973110408049

* Update tests so they don't expect rejections

* Reject when some invoice collection failed

GitOrigin-RevId: aa37f7fa37c96b8624e87d94be675d115e3250a9
This commit is contained in:
Antoine Clausse
2024-05-30 08:04:31 +00:00
committed by Copybot
parent 69871fccbe
commit 01e1286a8b
2 changed files with 17 additions and 12 deletions
@@ -91,8 +91,9 @@ const main = async () => {
try {
await attemptInvoicesCollection()
if (INVOICES_COLLECTED_SUCCESS.length === 0) {
throw new Error('No invoices collected')
const diff = INVOICES_COLLECTED.length - INVOICES_COLLECTED_SUCCESS.length
if (diff !== 0) {
throw new Error(`Invoices collection failed for ${diff} invoices`)
}
return {