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:
parent
3c8fed7d2f
commit
ba5cb952b9
@ -11,8 +11,8 @@ interface DealerClaimDetailsAttributes {
|
|||||||
dealerName: string;
|
dealerName: string;
|
||||||
dealerEmail?: string;
|
dealerEmail?: string;
|
||||||
dealerPhone?: string;
|
dealerPhone?: string;
|
||||||
dealerAddress?: string;
|
dealerAddress?: string | null;
|
||||||
activityDate?: Date;
|
activityDate?: Date | null;
|
||||||
location?: string;
|
location?: string;
|
||||||
periodStartDate?: Date;
|
periodStartDate?: Date;
|
||||||
periodEndDate?: Date;
|
periodEndDate?: Date;
|
||||||
@ -31,8 +31,8 @@ class DealerClaimDetails extends Model<DealerClaimDetailsAttributes, DealerClaim
|
|||||||
public dealerName!: string;
|
public dealerName!: string;
|
||||||
public dealerEmail?: string;
|
public dealerEmail?: string;
|
||||||
public dealerPhone?: string;
|
public dealerPhone?: string;
|
||||||
public dealerAddress?: string;
|
public dealerAddress?: string | null;
|
||||||
public activityDate?: Date;
|
public activityDate?: Date | null;
|
||||||
public location?: string;
|
public location?: string;
|
||||||
public periodStartDate?: Date;
|
public periodStartDate?: Date;
|
||||||
public periodEndDate?: Date;
|
public periodEndDate?: Date;
|
||||||
@ -93,8 +93,8 @@ DealerClaimDetails.init(
|
|||||||
},
|
},
|
||||||
dealerAddress: {
|
dealerAddress: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
allowNull: true,
|
field: 'dealer_address',
|
||||||
field: 'dealer_address'
|
comment: 'Dealer address'
|
||||||
},
|
},
|
||||||
activityDate: {
|
activityDate: {
|
||||||
type: DataTypes.DATEONLY,
|
type: DataTypes.DATEONLY,
|
||||||
|
|||||||
@ -31,6 +31,7 @@ export interface DealerInfo {
|
|||||||
dealerPrincipalName?: string | null;
|
dealerPrincipalName?: string | null;
|
||||||
dealerPrincipalEmailId?: string | null;
|
dealerPrincipalEmailId?: string | null;
|
||||||
gstin?: 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,
|
dealerPrincipalName: dealer.dealerPrincipalName || null,
|
||||||
dealerPrincipalEmailId: dealer.dealerPrincipalEmailId || null,
|
dealerPrincipalEmailId: dealer.dealerPrincipalEmailId || null,
|
||||||
gstin: dealer.gst || null,
|
gstin: dealer.gst || null,
|
||||||
|
pincode: dealer.showroomPincode || null,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -169,6 +171,7 @@ export async function getDealerByCode(dealerCode: string): Promise<DealerInfo |
|
|||||||
dealerPrincipalName: dealer.dealerPrincipalName || null,
|
dealerPrincipalName: dealer.dealerPrincipalName || null,
|
||||||
dealerPrincipalEmailId: dealer.dealerPrincipalEmailId || null,
|
dealerPrincipalEmailId: dealer.dealerPrincipalEmailId || null,
|
||||||
gstin: dealer.gst || null,
|
gstin: dealer.gst || null,
|
||||||
|
pincode: dealer.showroomPincode || null,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[DealerService] Error fetching dealer by code:', 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,
|
dealerPrincipalName: dealer.dealerPrincipalName || null,
|
||||||
dealerPrincipalEmailId: dealer.dealerPrincipalEmailId || null,
|
dealerPrincipalEmailId: dealer.dealerPrincipalEmailId || null,
|
||||||
gstin: dealer.gst || null,
|
gstin: dealer.gst || null,
|
||||||
|
pincode: dealer.showroomPincode || null,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[DealerService] Error fetching dealer by email:', error);
|
logger.error('[DealerService] Error fetching dealer by email:', error);
|
||||||
|
|||||||
@ -80,7 +80,7 @@ export class PdfService {
|
|||||||
|
|
||||||
private getInvoiceHtmlTemplate(data: any): string {
|
private getInvoiceHtmlTemplate(data: any): string {
|
||||||
const { request, invoice, dealer, claimDetails, completionExpenses = [], invoiceItems = [], taxationType } = data;
|
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 logoUrl = `{{LOGO_URL}}`;
|
||||||
const isNonGst = taxationType === 'Non GST' || taxationType === 'Non-GST';
|
const isNonGst = taxationType === 'Non GST' || taxationType === 'Non-GST';
|
||||||
|
|
||||||
|
|||||||
@ -121,12 +121,15 @@ export class PWCIntegrationService {
|
|||||||
const validQaGst = '24AAAPI3182M002'; // Registered in PWC QA
|
const validQaGst = '24AAAPI3182M002'; // Registered in PWC QA
|
||||||
|
|
||||||
if (isQA && (!dealerGst || dealerGst === invalidTestGst)) {
|
if (isQA && (!dealerGst || dealerGst === invalidTestGst)) {
|
||||||
|
logger.info(`[PWC] Using QA authorized GSTIN replacement: ${validQaGst} (Original: ${dealerGst || 'empty'})`);
|
||||||
dealerGst = validQaGst;
|
dealerGst = validQaGst;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Final fallback if still empty
|
// Final fallback if still empty
|
||||||
dealerGst = dealerGst || validQaGst;
|
dealerGst = dealerGst || validQaGst;
|
||||||
|
|
||||||
|
logger.info(`[PWC] Final GSTIN being used for authentication: ${dealerGst}`);
|
||||||
|
|
||||||
let dealerStateCode = "24"; // Default fallback (Gujarat for 24...)
|
let dealerStateCode = "24"; // Default fallback (Gujarat for 24...)
|
||||||
|
|
||||||
// Try to extract from GSTIN (first 2 chars)
|
// 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 = [
|
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",
|
Version: "1.01",
|
||||||
IRN: "",
|
IRN: "",
|
||||||
SourceSystem: "RE_WORKFLOW",
|
SourceSystem: "RE_WORKFLOW",
|
||||||
is_irn: "Y",
|
is_irn: "Y",
|
||||||
is_ewb: "N",
|
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: {
|
TranDtls: {
|
||||||
TaxSch: "GST",
|
TaxSch: "GST",
|
||||||
|
OutwardInward: "",
|
||||||
SubType: "SUPPLY",
|
SubType: "SUPPLY",
|
||||||
SubTypeDescription: "Others",
|
SubTypeDescription: "Others",
|
||||||
SupTyp: "B2B",
|
SupTyp: "B2B",
|
||||||
RegRev: "N",
|
RegRev: "N",
|
||||||
Typ: "REG",
|
Typ: "REG",
|
||||||
|
EcmGstin: "",
|
||||||
|
IgstOnIntra: "",
|
||||||
DiffPercentage: "0",
|
DiffPercentage: "0",
|
||||||
Taxability: (totalIgstAmt + totalCgstAmt + totalSgstAmt) > 0 ? "Taxable" : "Exempted",
|
Taxability: (totalIgstAmt + totalCgstAmt + totalSgstAmt) > 0 ? "Taxable" : "Exempted",
|
||||||
InterIntra: isIGST ? "Inter" : "Intra",
|
InterIntra: "",
|
||||||
CancelFlag: "N"
|
CancelFlag: "N",
|
||||||
|
CnlRsn: "1",
|
||||||
|
CnlRem: "d"
|
||||||
},
|
},
|
||||||
DocDtls: {
|
DocDtls: {
|
||||||
Typ: "Inv",
|
Typ: "Inv",
|
||||||
@ -426,14 +435,12 @@ export class PWCIntegrationService {
|
|||||||
Dt: new Date().toLocaleDateString('en-GB') // DD/MM/YYYY
|
Dt: new Date().toLocaleDateString('en-GB') // DD/MM/YYYY
|
||||||
},
|
},
|
||||||
SellerDtls: {
|
SellerDtls: {
|
||||||
Gstin: dealerGst,
|
Gstin: dealerGst, // Actual dealer GST from local table
|
||||||
LglNm: dealer?.dealerName || 'Dealer',
|
LglNm: dealer?.dealerName || 'Dealer',
|
||||||
TrdNm: dealer?.dealerName || 'Dealer',
|
TrdNm: dealer?.dealerName || 'Dealer',
|
||||||
Addr1: dealer?.city || "Address Line 1",
|
Addr1: dealer?.city || "Address Line 1",
|
||||||
Loc: dealer?.city || "Location",
|
Loc: dealer?.city || "Location",
|
||||||
Pin: (dealerGst === validQaGst)
|
Pin: Number(dealer?.pincode || (dealerGst === validQaGst ? 380001 : 600001)),
|
||||||
? 380001
|
|
||||||
: 600001,
|
|
||||||
Stcd: dealerStateCode,
|
Stcd: dealerStateCode,
|
||||||
Ph: dealer?.phone || "9998887776",
|
Ph: dealer?.phone || "9998887776",
|
||||||
Em: dealer?.email || "Supplier@inv.com"
|
Em: dealer?.email || "Supplier@inv.com"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user