import { PurchaseOrderPrintService } from "../purchases/purchase-order/purchase-order-print.service"; import { DCWithoutPricePdfService } from "../sales/delivery-challan/dc-without-price-pdf.service"; import { DeliveryChallanPdfService } from "../sales/delivery-challan/delivery-challan-pdf.service"; import { DeliveryChallanPrintService } from "../sales/delivery-challan/delivery-challan-print.service"; import { SalesPdfService } from "../sales/sales/sales-pdf.service"; import { SalesPrintService } from "../sales/sales/sales-print.service"; import { Add } from "./math-operations"; import { TrUtils } from "../utils/tr-utils"; import { PosReceiptPrintService } from "../accounting/counter-sales/pos-receipt-pdf"; import { SaleReceiptPrintService } from "../accounting/counter-sales/sales-receipt-print.service"; import { CNPrintService } from "../accounting/credit-note/cn-print.service"; import { CreditNotePdfService } from "../accounting/credit-note/credit-note-pdf.service"; import { GetInvoicePrintInfo } from "../accounting/invoice/inv-print.service"; import { CreateInvoicePDFService } from "../accounting/invoice/invoice-pdf/invoice-pdf.service"; import { GetInvoicePrint } from "../accounting/invoice/unified-invoice-pdf.service"; export function GetInvoicePDF(invoiceData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], withPass: boolean = false, options: any = null) { if (!options) { options = { ShowGST: (invoiceData?.Settings?.Tax === 'TI') ? true : false, ConsolidateGST: false, PartInvoice: true, LaborInvoice: true, Size: 'full', MoreDiscDetails: false, IsProforma: false, Orientation: 'portrait' }; } const printConfigData: any = TrUtils.ConcatObjects( TrUtils.Stringify(headerConfig), TrUtils.Stringify(printConfig) ); printConfigData.withPass = withPass; const invoicePrintData: any = GetInvoicePrintInfo(invoiceData, entityData, image, options.ShowGST, options.ConsolidateGST, taxCodes, options.IsProforma, options.PartInvoice, options.LaborInvoice); let invPrint: any; if (options.ConsolidateGST) { invPrint = GetInvoicePrint(invoicePrintData, numberofCopies, withPass, options.Size, options.MoreDiscDetails, options.Orientation); } else { if(options.PartInvoice && options.LaborInvoice){ invoicePrintData.Round = TrUtils.FixedTo(invoiceData.Round); invoicePrintData.Total = TrUtils.FixedTo(invoiceData.Total); invoicePrintData.SubToal = TrUtils.FixedTo(invoiceData.SubToal); invoicePrintData.TaxTotal = TrUtils.FixedTo(invoiceData.TaxTotal); } delete invoicePrintData.SIndTotal; invPrint = CreateInvoicePDFService(invoicePrintData, printConfigData, numberofCopies); } return invPrint; } export function GetSalesOrderPDF(salesOrderData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], options: any = null) { if (!options) { options = { ShowGST: (salesOrderData?.Settings?.Tax === 'TI') ? true : false, ConsolidateGST: false, Size: 'full', isOtherIndustry: false, Design: false, MoreDiscDetails: false, Orientation: 'portrait' }; } const printConfigData: any = TrUtils.ConcatObjects( TrUtils.Stringify(headerConfig), TrUtils.Stringify(printConfig) ); const soPrintData: any = SalesPrintService.GetSalesPrintInfo(salesOrderData, entityData, image, options.ShowGST, options.ConsolidateGST, taxCodes, false, options.isOtherIndustry); let soPrint: any; if (options.ConsolidateGST) { soPrint = SalesPdfService.GetSalesPrint(salesOrderData, numberofCopies, options.isOtherIndustry, entityData, options.Design, options.SoItems, image, options.MoreDiscDetails); } else { soPrintData.Round = TrUtils.FixedTo(salesOrderData.Round); soPrintData.Total = TrUtils.FixedTo(salesOrderData.Total); soPrintData.SubToal = TrUtils.FixedTo(salesOrderData.SubToal); soPrintData.TaxTotal = TrUtils.FixedTo(salesOrderData.TaxTotal); soPrint = CreateInvoicePDFService(soPrintData, printConfigData, numberofCopies); } return soPrint; } export function GetDeliveryChallanPDF(deliveryChallanData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], options: any = null) { if (!options) { options = { ShowGST: (deliveryChallanData?.Settings?.Tax === 'TI') ? true : false, ConsolidateGST: false, Size: 'full', MoreDiscDetails: false, Orientation: 'portrait' }; } const printConfigData: any = TrUtils.ConcatObjects( TrUtils.Stringify(headerConfig), TrUtils.Stringify(printConfig) ); const dcPrintData: any = DeliveryChallanPrintService.GetChallanDataPrintInfo(deliveryChallanData, entityData, image, options.ShowGST, options.ConsolidateGST, taxCodes, false); let dcPrint: any; if (options.ConsolidateGST) { dcPrint = DeliveryChallanPdfService.GetDeliveryChallanPrint(deliveryChallanData, numberofCopies, false); } else { dcPrintData.Round = TrUtils.FixedTo(deliveryChallanData.Round); dcPrintData.Total = TrUtils.FixedTo(deliveryChallanData.Total); dcPrintData.SubToal = TrUtils.FixedTo(deliveryChallanData.SubToal); dcPrintData.TaxTotal = TrUtils.FixedTo(deliveryChallanData.TaxTotal); dcPrint = CreateInvoicePDFService(dcPrintData, printConfigData, numberofCopies); } return dcPrint; } export function GetCreditNotePDF(creditNoteData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], options: any = null) { if (!options) { options = { ShowGST: (creditNoteData?.Settings?.Tax === 'TI') ? true : false, ConsolidateGST: false, Size: 'full', MoreDiscDetails: false, Orientation: 'portrait' }; } const printConfigData: any = TrUtils.ConcatObjects( TrUtils.Stringify(headerConfig), TrUtils.Stringify(printConfig) ); const creditNotePrintData: any = CNPrintService.GetCreditNotePrintInfo(creditNoteData, entityData, image, options.ShowGST, options.ConsolidateGST, taxCodes, false); let cnPrint: any; if (options.ConsolidateGST) { cnPrint = CreditNotePdfService.GetInvoicePrint(creditNotePrintData, null, false); } else { creditNotePrintData.Round = TrUtils.FixedTo(creditNoteData.Round); creditNotePrintData.Total = TrUtils.FixedTo(creditNoteData.Total); creditNotePrintData.SubToal = TrUtils.FixedTo(creditNoteData.SubToal); creditNotePrintData.TaxTotal = TrUtils.FixedTo(creditNoteData.TaxTotal); cnPrint = CreateInvoicePDFService(creditNotePrintData, printConfigData, numberofCopies); } return cnPrint; } export function GetSalesReceiptPDF(salesReceiptData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], withPass: boolean = false, options: any = null) { if (!options) { options = { ShowGST: (salesReceiptData?.Settings?.Tax === 'TI') ? true : false, ConsolidateGST: false, PartInvoice: true, LaborInvoice: true, Size: 'full', MoreDiscDetails: false, Orientation: 'portrait', OwnBatch: false }; } const printConfigData: any = TrUtils.ConcatObjects( TrUtils.Stringify(headerConfig), TrUtils.Stringify(printConfig) ); printConfigData.withPass = withPass; const posPrintData: any = SaleReceiptPrintService.GetSaleReceiptPrintInfo(salesReceiptData, entityData, image, options.ShowGST, options.ConsolidateGST, taxCodes, false, options.OwnBatch); posPrintData.TotalTax = Add(posPrintData.CustPartCGST, posPrintData.CustPartSGST, posPrintData.CustPartIGST); posPrintData.Customer.Code = salesReceiptData.BillTo.Code; let posPrint: any; if (options.ConsolidateGST) { posPrint = PosReceiptPrintService.GetPrint(posPrintData, options.Size); } else { posPrint = CreateInvoicePDFService(posPrintData, printConfigData, numberofCopies); } return posPrint; } export function GetBillPDF(billData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null) { const printConfigData: any = TrUtils.ConcatObjects( TrUtils.Stringify(headerConfig), TrUtils.Stringify(printConfig) ); let billPrintData: any = PurchaseOrderPrintService.GetDataForPurchaseOrderPrint(billData, entityData, image, billData.BFrom, taxCodes, false); let billPrint: any = CreateInvoicePDFService(billPrintData, printConfigData, ['Original']); return billPrint; }