Skip to content

Commit 5efefb6

Browse files
author
Gerald Baulig
committed
fix(counter): null check for counter
1 parent a88b0be commit 5efefb6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/services/invoice_srv.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -581,18 +581,22 @@ export class InvoiceService
581581
shop => this.redis.get(`invoice:counter:${shop.id}`).then(
582582
(counter: any) => ({
583583
id: shop.id,
584-
counter: Number.parseInt(counter.toString())
584+
counter: Number(counter)
585585
})
586586
)
587587
)).then(
588588
counters => {
589589
this.invoice_number_srv.upsert(
590590
{
591-
items: counters.map(item => ({
592-
id: item.id,
593-
shop_id: item.id,
594-
counter: item.counter,
595-
})),
591+
items: counters.filter(
592+
item => Number.isInteger(item.counter)
593+
).map(
594+
item => ({
595+
id: item.id,
596+
shop_id: item.id,
597+
counter: item.counter,
598+
})
599+
),
596600
total_count: counters.length,
597601
subject: aggregation.subject
598602
},

0 commit comments

Comments
 (0)