feat: add ABN existence check in createPayer function
This commit is contained in:
parent
92a6b4275c
commit
2f57da4fa4
|
@ -14,12 +14,15 @@ console.log = Debug('invoiceIssuer:func/createPayer.ts')
|
|||
*/
|
||||
export default async (prisma: PrismaClient, name: string, address: string[], email: string, abn?: string) => {
|
||||
// 验证 ABN 是否已存在
|
||||
const existingPayer = await prisma.payer.findFirst({
|
||||
where: {
|
||||
payer_abn: abn
|
||||
}
|
||||
})
|
||||
if (existingPayer) throw new HttpError(ErrorDescEnum.item_exists, 400, ['abn'])
|
||||
if (abn) {
|
||||
console.log('Checking if ABN exists:', abn)
|
||||
const existingPayer = await prisma.payer.findFirst({
|
||||
where: {
|
||||
payer_abn: abn
|
||||
}
|
||||
})
|
||||
if (existingPayer) throw new HttpError(ErrorDescEnum.item_exists, 400, ['abn'])
|
||||
}
|
||||
|
||||
// 创建新的付款人
|
||||
const payer = await prisma.payer.create({
|
||||
|
|
Loading…
Reference in New Issue
Block a user