Merge branch 'develop'
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 6s

This commit is contained in:
Methapon2001 2025-02-27 09:18:34 +07:00
commit aac73f334c
8 changed files with 156 additions and 86 deletions

View file

@ -1,8 +1,4 @@
name: Gitea Action name: Deploy Local
run-name: Build ${{ github.actor }}
# Intended for local gitea instance only.
on: on:
workflow_dispatch: workflow_dispatch:

View file

@ -0,0 +1,24 @@
name: Spell Check
permissions:
contents: read
on:
push:
branches:
- develop
env:
CLICOLOR: 1
jobs:
spelling:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Spell Check Repo
uses: crate-ci/typos@v1.29.9
with:
files: ./src

View file

@ -1,31 +0,0 @@
name: local-build-dev
# Intended for local network use.
# Remote access is possible if the host has a public IP address.
on:
workflow_dispatch:
env:
REGISTRY: ${{ vars.DOCKER_REGISTRY }}
jobs:
local-build-dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[registry."${{ env.REGISTRY }}"]
http = true
insecure = true
- name: Build and Push Docker Image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ env.REGISTRY }}/jws/jws-backend:dev
allow: security.insecure

2
.typos.toml Normal file
View file

@ -0,0 +1,2 @@
[default]
extend-ignore-re = ["(?Rm)^.*(#|//)\\s*spellchecker:disable-line$"]

View file

@ -341,7 +341,7 @@ function nationality(text: string, lang: "th" | "en" = "en") {
case "th": case "th":
return ( return (
{ {
["THA"]: "ไทย", ["THA"]: "ไทย", // spellchecker:disable-line
["MMR"]: "เมียนมา", ["MMR"]: "เมียนมา",
["LAO"]: "ลาว", ["LAO"]: "ลาว",
["KHM"]: "กัมพูชา", ["KHM"]: "กัมพูชา",
@ -353,7 +353,7 @@ function nationality(text: string, lang: "th" | "en" = "en") {
default: default:
return ( return (
{ {
["THA"]: "Thai", ["THA"]: "Thai", // spellchecker:disable-line
["MMR"]: "Myanmar", ["MMR"]: "Myanmar",
["LAO"]: "Laos", ["LAO"]: "Laos",
["KHM"]: "Khmer", ["KHM"]: "Khmer",

View file

@ -536,7 +536,7 @@ export class CreditNoteController extends Controller {
if (record.creditNoteStatus !== CreditNoteStatus.Waiting) { if (record.creditNoteStatus !== CreditNoteStatus.Waiting) {
throw new HttpError( throw new HttpError(
HttpStatus.BAD_REQUEST, HttpStatus.BAD_REQUEST,
"Accpeted credit note cannot be deleted", "Accepted credit note cannot be deleted",
"creditNoteAcceptedNoDelete", "creditNoteAcceptedNoDelete",
); );
} }

View file

@ -73,7 +73,14 @@ export class LineController extends Controller {
status: activeOnly ? { not: Status.INACTIVE } : undefined, status: activeOnly ? { not: Status.INACTIVE } : undefined,
id: customerBranchId, id: customerBranchId,
customerId, customerId,
userId: line.user.sub, OR: [
{ userId: line.user.sub },
{
customer: {
branch: { some: { userId: line.user.sub } },
},
},
],
}, },
subDistrict: zipCode ? { zipCode } : undefined, subDistrict: zipCode ? { zipCode } : undefined,
gender, gender,
@ -135,7 +142,14 @@ export class LineController extends Controller {
where: { where: {
id: employeeId, id: employeeId,
customerBranch: { customerBranch: {
userId: line.user.sub, OR: [
{ userId: line.user.sub },
{
customer: {
branch: { some: { userId: line.user.sub } },
},
},
],
}, },
}, },
}); });
@ -220,7 +234,16 @@ export class LineController extends Controller {
// registeredBranch: { OR: permissionCond(req.user) }, // registeredBranch: { OR: permissionCond(req.user) },
}, },
employee: { employee: {
customerBranch: { userId: line.user.sub }, customerBranch: {
OR: [
{ userId: line.user.sub },
{
customer: {
branch: { some: { userId: line.user.sub } },
},
},
],
},
}, },
} satisfies Prisma.RequestDataWhereInput; } satisfies Prisma.RequestDataWhereInput;
@ -282,7 +305,16 @@ export class LineController extends Controller {
where: { where: {
id: requestDataId, id: requestDataId,
employee: { employee: {
customerBranch: { userId: line.user.sub }, customerBranch: {
OR: [
{ userId: line.user.sub },
{
customer: {
branch: { some: { userId: line.user.sub } },
},
},
],
},
}, },
}, },
include: { include: {
@ -399,7 +431,16 @@ export class LineController extends Controller {
: undefined, : undefined,
quotationId, quotationId,
employee: { employee: {
customerBranch: { userId: line.user.sub }, customerBranch: {
OR: [
{ userId: line.user.sub },
{
customer: {
branch: { some: { userId: line.user.sub } },
},
},
],
},
}, },
}, },
} satisfies Prisma.RequestWorkWhereInput; } satisfies Prisma.RequestWorkWhereInput;
@ -519,7 +560,16 @@ export class LineController extends Controller {
id: requestWorkId, id: requestWorkId,
request: { request: {
employee: { employee: {
customerBranch: { userId: line.user.sub }, customerBranch: {
OR: [
{ userId: line.user.sub },
{
customer: {
branch: { some: { userId: line.user.sub } },
},
},
],
},
}, },
}, },
}, },
@ -546,49 +596,60 @@ export class LineController extends Controller {
@Query() status?: QuotationStatus, @Query() status?: QuotationStatus,
@Query() pendingOnly?: boolean, @Query() pendingOnly?: boolean,
@Query() inProgressOnly?: boolean, @Query() inProgressOnly?: boolean,
@Query() historyOnly?: boolean, @Query() successOnly?: boolean,
@Query() canceledOnly?: boolean,
@Query() urgentFirst?: boolean, @Query() urgentFirst?: boolean,
@Query() includeRegisteredBranch?: boolean, @Query() includeRegisteredBranch?: boolean,
@Query() code?: string, @Query() code?: string,
@Query() query = "", @Query() query = "",
) { ) {
const where = { const where = {
OR: [ OR:
...(queryOrNot<Prisma.QuotationWhereInput[]>(query, [ query || pendingOnly
{ code: { contains: query, mode: "insensitive" } }, ? [
{ workName: { contains: query } }, ...(queryOrNot<Prisma.QuotationWhereInput[]>(query, [
{
customerBranch: {
OR: [
{ code: { contains: query, mode: "insensitive" } }, { code: { contains: query, mode: "insensitive" } },
{ customerName: { contains: query } }, { workName: { contains: query } },
{ firstName: { contains: query } }, {
{ firstNameEN: { contains: query } }, customerBranch: {
{ lastName: { contains: query } }, OR: [
{ lastNameEN: { contains: query } }, { code: { contains: query, mode: "insensitive" } },
], { customerName: { contains: query } },
}, { firstName: { contains: query } },
}, { firstNameEN: { contains: query } },
]) || []), { lastName: { contains: query } },
...(queryOrNot<Prisma.QuotationWhereInput[]>(!!pendingOnly, [ { lastNameEN: { contains: query } },
{ ],
requestData: { },
some: { },
requestDataStatus: "Pending", ]) || []),
}, ...(queryOrNot<Prisma.QuotationWhereInput[]>(!!pendingOnly, [
}, {
}, requestData: {
{ some: {
requestData: { none: {} }, requestDataStatus: "Pending",
}, },
]) || []), },
], },
{
requestData: { none: {} },
},
]) || []),
]
: undefined,
isDebitNote: false, isDebitNote: false,
code, code,
payCondition, payCondition,
quotationStatus: historyOnly ? { in: ["ProcessComplete", "Canceled"] } : status, quotationStatus: successOnly ? "ProcessComplete" : canceledOnly ? "Canceled" : status,
customerBranch: { customerBranch: {
userId: line.user.sub, OR: [
{ userId: line.user.sub },
{
customer: {
branch: { some: { userId: line.user.sub } },
},
},
],
}, },
requestData: inProgressOnly requestData: inProgressOnly
? { ? {
@ -698,7 +759,16 @@ export class LineController extends Controller {
where: { where: {
id: quotationId, id: quotationId,
isDebitNote: false, isDebitNote: false,
customerBranch: { userId: line.user.sub }, customerBranch: {
OR: [
{ userId: line.user.sub },
{
customer: {
branch: { some: { userId: line.user.sub } },
},
},
],
},
}, },
}); });

View file

@ -6,7 +6,7 @@ import { RequestWithLineUser } from "../interfaces/user";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
type SendEmail = { type SendOTP = {
identityNumber: string; identityNumber: string;
email: string; email: string;
}; };
@ -25,11 +25,22 @@ export class verificationController extends Controller {
@Get() @Get()
@Security("line") @Security("line")
async isRegistered(@Request() req: RequestWithLineUser) { async isRegistered(@Request() req: RequestWithLineUser) {
return !!(await prisma.customerBranch.findFirst({ where: { userId: req.user.sub } })); return !!(await prisma.customerBranch.findFirst({
where: {
OR: [
{ userId: req.user.sub },
{
customer: {
branch: { some: { userId: req.user.sub } },
},
},
],
},
}));
} }
@Post("/send-otp") @Post("/send-otp")
public async sendOTP(@Body() body: SendEmail) { public async sendOTP(@Body() body: SendOTP) {
if ( if (
![ ![
process.env.SMTP_HOST, process.env.SMTP_HOST,
@ -133,13 +144,11 @@ export class verificationController extends Controller {
customerBranch.otpExpires && customerBranch.otpExpires &&
customerBranch.otpExpires >= new Date() customerBranch.otpExpires >= new Date()
) { ) {
const dataCustomer = await prisma.customerBranch.update({ const dataCustomer = await prisma.customerBranch.updateMany({
where: { where: {
id: customerBranch.id, customerId: customerBranch.customerId,
},
data: {
userId: req.user.sub,
}, },
data: { userId: req.user.sub },
}); });
return dataCustomer; return dataCustomer;