feat: end-point for pdf of all deal's barcodes, client and marketplace info in bill of payment
This commit is contained in:
		@@ -1,3 +1,4 @@
 | 
			
		||||
import base64
 | 
			
		||||
from io import BytesIO
 | 
			
		||||
from typing import Annotated
 | 
			
		||||
 | 
			
		||||
@@ -7,8 +8,10 @@ from sqlalchemy.ext.asyncio import AsyncSession
 | 
			
		||||
from backend.dependecies import SessionDependency, CurrentUserDependency
 | 
			
		||||
from backend.session import get_session
 | 
			
		||||
from models import User
 | 
			
		||||
from schemas.barcode import GetProductBarcodePdfResponse, GetDealProductsBarcodesPdfRequest
 | 
			
		||||
from schemas.deal import *
 | 
			
		||||
from services.auth import get_current_user, authorized_user, guest_user
 | 
			
		||||
from services.barcode import BarcodeService
 | 
			
		||||
from services.billing import BillingService
 | 
			
		||||
from services.deal import DealService
 | 
			
		||||
 | 
			
		||||
@@ -391,4 +394,24 @@ async def add_kit_to_deal_product(
 | 
			
		||||
        user: CurrentUserDependency
 | 
			
		||||
):
 | 
			
		||||
    return await DealService(session).add_kit_to_deal_product(user, request)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@deal_router.post(
 | 
			
		||||
    '/barcodes/get-pdf',
 | 
			
		||||
    operation_id='get_deal_barcodes_pdf',
 | 
			
		||||
    response_model=GetProductBarcodePdfResponse
 | 
			
		||||
)
 | 
			
		||||
async def get_deal_products_barcodes_pdf(
 | 
			
		||||
        request: GetDealProductsBarcodesPdfRequest,
 | 
			
		||||
        session: Annotated[AsyncSession, Depends(get_session)]
 | 
			
		||||
):
 | 
			
		||||
    filename, pdf_buffer = await BarcodeService(session).get_deal_barcodes_pdf(request)
 | 
			
		||||
    pdf_buffer: BytesIO
 | 
			
		||||
    base64_string = base64.b64encode(pdf_buffer.read()).decode('utf-8')
 | 
			
		||||
    return GetProductBarcodePdfResponse(
 | 
			
		||||
        base64_string=base64_string,
 | 
			
		||||
        filename=filename,
 | 
			
		||||
        mime_type='application/pdf'
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user