i have modified invoice and gst related fields for actuall data mapping still getting validation error after making thses changes

This commit is contained in:
laxmanhalaki 2026-02-27 19:46:42 +05:30
parent 3c8fed7d2f
commit ba5cb952b9
4 changed files with 28 additions and 17 deletions

View File

@ -11,8 +11,8 @@ interface DealerClaimDetailsAttributes {
dealerName: string;
dealerEmail?: string;
dealerPhone?: string;
dealerAddress?: string;
activityDate?: Date;
dealerAddress?: string | null;
activityDate?: Date | null;
location?: string;
periodStartDate?: Date;
periodEndDate?: Date;
@ -20,7 +20,7 @@ interface DealerClaimDetailsAttributes {
updatedAt: Date;
}
interface DealerClaimDetailsCreationAttributes extends Optional<DealerClaimDetailsAttributes, 'claimId' | 'dealerEmail' | 'dealerPhone' | 'dealerAddress' | 'activityDate' | 'location' | 'periodStartDate' | 'periodEndDate' | 'createdAt' | 'updatedAt'> {}
interface DealerClaimDetailsCreationAttributes extends Optional<DealerClaimDetailsAttributes, 'claimId' | 'dealerEmail' | 'dealerPhone' | 'dealerAddress' | 'activityDate' | 'location' | 'periodStartDate' | 'periodEndDate' | 'createdAt' | 'updatedAt'> { }
class DealerClaimDetails extends Model<DealerClaimDetailsAttributes, DealerClaimDetailsCreationAttributes> implements DealerClaimDetailsAttributes {
public claimId!: string;
@ -31,8 +31,8 @@ class DealerClaimDetails extends Model<DealerClaimDetailsAttributes, DealerClaim
public dealerName!: string;
public dealerEmail?: string;
public dealerPhone?: string;
public dealerAddress?: string;
public activityDate?: Date;
public dealerAddress?: string | null;
public activityDate?: Date | null;
public location?: string;
public periodStartDate?: Date;
public periodEndDate?: Date;
@ -93,8 +93,8 @@ DealerClaimDetails.init(
},
dealerAddress: {
type: DataTypes.TEXT,
allowNull: true,
field: 'dealer_address'
field: 'dealer_address',
comment: 'Dealer address'
},
activityDate: {
type: DataTypes.DATEONLY,

View File

@ -31,6 +31,7 @@ export interface DealerInfo {
dealerPrincipalName?: string | null;
dealerPrincipalEmailId?: string | null;
gstin?: string | null;
pincode?: string | null;
}
/**
@ -108,6 +109,7 @@ export async function getAllDealers(searchTerm?: string, limit: number = 10): Pr
dealerPrincipalName: dealer.dealerPrincipalName || null,
dealerPrincipalEmailId: dealer.dealerPrincipalEmailId || null,
gstin: dealer.gst || null,
pincode: dealer.showroomPincode || null,
};
});
} catch (error) {
@ -169,6 +171,7 @@ export async function getDealerByCode(dealerCode: string): Promise<DealerInfo |
dealerPrincipalName: dealer.dealerPrincipalName || null,
dealerPrincipalEmailId: dealer.dealerPrincipalEmailId || null,
gstin: dealer.gst || null,
pincode: dealer.showroomPincode || null,
};
} catch (error) {
logger.error('[DealerService] Error fetching dealer by code:', error);
@ -229,6 +232,7 @@ export async function getDealerByEmail(email: string): Promise<DealerInfo | null
dealerPrincipalName: dealer.dealerPrincipalName || null,
dealerPrincipalEmailId: dealer.dealerPrincipalEmailId || null,
gstin: dealer.gst || null,
pincode: dealer.showroomPincode || null,
};
} catch (error) {
logger.error('[DealerService] Error fetching dealer by email:', error);

View File

@ -80,7 +80,7 @@ export class PdfService {
private getInvoiceHtmlTemplate(data: any): string {
const { request, invoice, dealer, claimDetails, completionExpenses = [], invoiceItems = [], taxationType } = data;
const qrImage = invoice.qrImage ? `data:image/png,base64,${invoice.qrImage}` : '';
const qrImage = invoice.qrImage ? `data:image/png;base64,${invoice.qrImage}` : '';
const logoUrl = `{{LOGO_URL}}`;
const isNonGst = taxationType === 'Non GST' || taxationType === 'Non-GST';

View File

@ -121,12 +121,15 @@ export class PWCIntegrationService {
const validQaGst = '24AAAPI3182M002'; // Registered in PWC QA
if (isQA && (!dealerGst || dealerGst === invalidTestGst)) {
logger.info(`[PWC] Using QA authorized GSTIN replacement: ${validQaGst} (Original: ${dealerGst || 'empty'})`);
dealerGst = validQaGst;
}
// Final fallback if still empty
dealerGst = dealerGst || validQaGst;
logger.info(`[PWC] Final GSTIN being used for authentication: ${dealerGst}`);
let dealerStateCode = "24"; // Default fallback (Gujarat for 24...)
// Try to extract from GSTIN (first 2 chars)
@ -398,27 +401,33 @@ export class PWCIntegrationService {
};
}
// Construct PWC Payload - Aligned with sample format provided by user
// Construct PWC Payload - Aligned with sample format provided by user EXACTLY
const payload = [
{
User_GSTIN: dealerGst, // Use Dealer GSTIN as User_GSTIN to ensure match
User_GSTIN: dealerGst, // Portal User ID (Dealer's own GST)
Version: "1.01",
IRN: "",
SourceSystem: "RE_WORKFLOW",
is_irn: "Y",
is_ewb: "N",
email: (request as any).initiator?.email || `system@${appDomain}`,
email: isQA ? "jayesh.jacob1@pwc.com" : ((request as any).initiator?.email || `system@${appDomain}`),
TranDtls: {
TaxSch: "GST",
OutwardInward: "",
SubType: "SUPPLY",
SubTypeDescription: "Others",
SupTyp: "B2B",
RegRev: "N",
Typ: "REG",
EcmGstin: "",
IgstOnIntra: "",
DiffPercentage: "0",
Taxability: (totalIgstAmt + totalCgstAmt + totalSgstAmt) > 0 ? "Taxable" : "Exempted",
InterIntra: isIGST ? "Inter" : "Intra",
CancelFlag: "N"
InterIntra: "",
CancelFlag: "N",
CnlRsn: "1",
CnlRem: "d"
},
DocDtls: {
Typ: "Inv",
@ -426,14 +435,12 @@ export class PWCIntegrationService {
Dt: new Date().toLocaleDateString('en-GB') // DD/MM/YYYY
},
SellerDtls: {
Gstin: dealerGst,
Gstin: dealerGst, // Actual dealer GST from local table
LglNm: dealer?.dealerName || 'Dealer',
TrdNm: dealer?.dealerName || 'Dealer',
Addr1: dealer?.city || "Address Line 1",
Loc: dealer?.city || "Location",
Pin: (dealerGst === validQaGst)
? 380001
: 600001,
Pin: Number(dealer?.pincode || (dealerGst === validQaGst ? 380001 : 600001)),
Stcd: dealerStateCode,
Ph: dealer?.phone || "9998887776",
Em: dealer?.email || "Supplier@inv.com"