Skip to content

Commit

Permalink
removed conv to base64, adjusted endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninarchive committed Dec 4, 2023
1 parent c398562 commit ee79473
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions backend/src/controllers/invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const createInvoice = async (invoice: IInvoice, db: Db, pdfBuffer: Buffer, user:
let xmlBuffer;
if (!invoice.isQuotation) {
const companyConfig: ICompanyConfig = await db.collection(CollectionNames.CONFIG).findOne({ key: 'conf' });
xmlBuffer = Buffer.from(btoa(createXml(invoice, companyConfig)));
xmlBuffer = Buffer.from(createXml(invoice, companyConfig));
await db.collection<Pick<IAttachmentCollection, '_id' | 'pdf' | 'xml'>>(CollectionNames.ATTACHMENTS).insertOne({
_id: new ObjectID(createdInvoice._id),
pdf: pdfBuffer,
Expand Down Expand Up @@ -269,9 +269,9 @@ export const generateExcelForInvoicesController = async (req: Request, res: Resp


export const getInvoiceXmlController = async (req: Request, res: Response) => {
const { id: invoiceId }: { id: string; } = req.body;
const { id } = req.params;
const invoiceAttachments: IAttachmentCollection | null = await req.db.collection(CollectionNames.ATTACHMENTS)
.findOne({ _id: new ObjectID(invoiceId) as ObjectID });
.findOne({ _id: new ObjectID(id) as ObjectID });
if (invoiceAttachments && invoiceAttachments.xml) {
return res.type('application/xml').send(atob(invoiceAttachments.xml.toString()));
} else {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/routes/invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ invoicesRouter.post('/excel', generateExcelForInvoicesController);
invoicesRouter.put('/', updateInvoiceController as any);

invoicesRouter.delete('/', deleteInvoiceController);
invoicesRouter.post('/xml', getInvoiceXmlController);
invoicesRouter.get('/xml/:id', getInvoiceXmlController);

export default invoicesRouter;

0 comments on commit ee79473

Please sign in to comment.