add startDate endDate in instition and receipt , codeProductRecieve in taskOrder
This commit is contained in:
parent
e42b772dcf
commit
f98371132a
7 changed files with 84 additions and 5 deletions
|
|
@ -17,7 +17,7 @@ import {
|
|||
} from "tsoa";
|
||||
import prisma from "../db";
|
||||
import { isUsedError, notFoundError } from "../utils/error";
|
||||
import { queryOrNot } from "../utils/relation";
|
||||
import { queryOrNot, whereDateQuery } from "../utils/relation";
|
||||
import { RequestWithUser } from "../interfaces/user";
|
||||
import { deleteFile, fileLocation, getFile, getPresigned, listFile, setFile } from "../utils/minio";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
|
|
@ -108,8 +108,19 @@ export class InstitutionController extends Controller {
|
|||
@Query() status?: Status,
|
||||
@Query() activeOnly?: boolean,
|
||||
@Query() group?: string,
|
||||
@Query() startDate?: Date,
|
||||
@Query() endDate?: Date,
|
||||
) {
|
||||
return this.getInstitutionListByCriteria(query, page, pageSize, status, activeOnly, group);
|
||||
return this.getInstitutionListByCriteria(
|
||||
query,
|
||||
page,
|
||||
pageSize,
|
||||
status,
|
||||
activeOnly,
|
||||
group,
|
||||
startDate,
|
||||
endDate,
|
||||
);
|
||||
}
|
||||
|
||||
@Post("list")
|
||||
|
|
@ -122,6 +133,8 @@ export class InstitutionController extends Controller {
|
|||
@Query() status?: Status,
|
||||
@Query() activeOnly?: boolean,
|
||||
@Query() group?: string,
|
||||
@Query() startDate?: Date,
|
||||
@Query() endDate?: Date,
|
||||
@Body()
|
||||
body?: {
|
||||
group?: string[];
|
||||
|
|
@ -134,6 +147,7 @@ export class InstitutionController extends Controller {
|
|||
{ name: { contains: query, mode: "insensitive" } },
|
||||
{ code: { contains: query, mode: "insensitive" } },
|
||||
]),
|
||||
...whereDateQuery(startDate, endDate),
|
||||
} satisfies Prisma.InstitutionWhereInput;
|
||||
|
||||
const [result, total] = await prisma.$transaction([
|
||||
|
|
@ -178,6 +192,7 @@ export class InstitutionController extends Controller {
|
|||
body: InstitutionPayload & {
|
||||
status?: Status;
|
||||
},
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
return await prisma.$transaction(async (tx) => {
|
||||
const last = await tx.runningNo.upsert({
|
||||
|
|
@ -194,6 +209,8 @@ export class InstitutionController extends Controller {
|
|||
return await tx.institution.create({
|
||||
include: {
|
||||
bank: true,
|
||||
createdBy: true,
|
||||
updatedBy: true,
|
||||
},
|
||||
data: {
|
||||
...body,
|
||||
|
|
@ -204,6 +221,8 @@ export class InstitutionController extends Controller {
|
|||
data: body.bank ?? [],
|
||||
},
|
||||
},
|
||||
createdByUserId: req.user.sub,
|
||||
updatedByUserId: req.user.sub,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { Prisma } from "@prisma/client";
|
|||
import { notFoundError } from "../utils/error";
|
||||
import { RequestWithUser } from "../interfaces/user";
|
||||
import { createPermCondition } from "../services/permission";
|
||||
import { whereDateQuery } from "../utils/relation";
|
||||
|
||||
const permissionCondCompany = createPermCondition((_) => true);
|
||||
|
||||
|
|
@ -21,6 +22,8 @@ export class ReceiptController extends Controller {
|
|||
@Query() quotationId?: string,
|
||||
@Query() debitNoteId?: string,
|
||||
@Query() debitNoteOnly?: boolean,
|
||||
@Query() startDate?: Date,
|
||||
@Query() endDate?: Date,
|
||||
) {
|
||||
const where: Prisma.PaymentWhereInput = {
|
||||
paymentStatus: "PaymentSuccess",
|
||||
|
|
@ -33,6 +36,7 @@ export class ReceiptController extends Controller {
|
|||
},
|
||||
},
|
||||
},
|
||||
...whereDateQuery(startDate, endDate),
|
||||
};
|
||||
|
||||
const [result, total] = await prisma.$transaction([
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ export class QuotationPayment extends Controller {
|
|||
async updatePayment(
|
||||
@Path() paymentId: string,
|
||||
@Body() body: { amount?: number; date?: Date; paymentStatus?: PaymentStatus },
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
const record = await prisma.payment.findUnique({
|
||||
where: { id: paymentId },
|
||||
|
|
@ -164,6 +165,7 @@ export class QuotationPayment extends Controller {
|
|||
code: lastReceipt
|
||||
? `RE${year}${month}${lastReceipt.value.toString().padStart(6, "0")}`
|
||||
: undefined,
|
||||
updatedByUserId: req.user.sub,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -697,12 +697,31 @@ export class TaskActionController extends Controller {
|
|||
if (!record) throw notFoundError("Task Order");
|
||||
|
||||
await prisma.$transaction(async (tx) => {
|
||||
const last = await tx.runningNo.upsert({
|
||||
where: {
|
||||
key: "TASK_RI",
|
||||
},
|
||||
create: {
|
||||
key: "TASK_RI",
|
||||
value: 1,
|
||||
},
|
||||
update: {
|
||||
value: { increment: 1 },
|
||||
},
|
||||
});
|
||||
const current = new Date();
|
||||
const year = `${current.getFullYear()}`.padStart(2, "0");
|
||||
const month = `${current.getMonth() + 1}`.padStart(2, "0");
|
||||
|
||||
const code = `RI${year}${month}${last.value.toString().padStart(6, "0")}`;
|
||||
|
||||
await Promise.all([
|
||||
tx.taskOrder.update({
|
||||
where: { id: taskOrderId },
|
||||
data: {
|
||||
urgent: false,
|
||||
taskOrderStatus: TaskOrderStatus.Complete,
|
||||
codeProductReceived: code,
|
||||
userTask: {
|
||||
updateMany: {
|
||||
where: { taskOrderId },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue