awb_segregated_payload

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 21

creditcontrol/details-

{
"totalamount": 4800.36,
"customerid": 1,
"servicecenterid": 1
}

details-
{
"generatedfromid": 1,
"awbnumber": null,
"customerid": 1,
"companyid": 1,
"referenceno": null,
"frompickup": false,
"bookingdate": "2024-12-25T18:06",
"productid": 2,
"productcode": "DOX",
"vendorid": 13,
"vendorcode": "DHL",
"serviceid": 2,
"shipmentvalue": null,
"chargetypes": [
"Commercial"
],
"billingtype": "Credit",
"mode": "awb",
"details": [
{
"update": "Yes",
"status": true,
"info": {
"id": null,
"type": "Shipper",
"name": "DEV SHIPPERS",
"contactperson": "DEVESH KOLI",
"emailid": "DEV@SHIPPER.XPRESION.IN",
"iecno": "GHT5651",
"isactive": true,
"location": {
"country": "IND",
"countrycode": "IN",
"state": "IN-MH",
"statecode": "MH",
"city": "IN-MH-24",
"citycode": "ISK",
"address1": "KAMBI NAGAR",
"mobileno": "7878787878",
"tel": "5555555555"
},
"kyc": {
"type": "GSTIN (Normal)",
"no": "29AABCA7045H1ZO"
}
}
},
{
"update": "Yes",
"status": true,
"info": {
"id": 56,
"type": "Consignee",
"code": "ADDR-56",
"name": "VIKAS",
"contactperson": "VIKAS YADAV",
"emailid": "VIKAS@GMAIL.COM",
"iecno": "3KJI6767",
"isactive": true,
"location": {
"country": "IND",
"countrycode": "IN",
"state": "IN-MH",
"statecode": "MH",
"city": "IN-MH-24",
"address1": "KAMBI NAGAR",
"mobileno": "7878787878",
"tel": "5555555555"
},
"kyc": {
"type": "PAN Number",
"no": "BBWPW0151T"
}
}
}
]
}

awbpieces-
{
"generatedfromid": 1,
"awbnumber": "we3450",
"customerid": 1,
"companyid": 1,
"referenceno": null,
"frompickup": false,
"bookingdate": "2024-12-25T18:06",
"productid": 2,
"productcode": "DOX",
"vendorid": 13,
"vendorcode": "DHL",
"serviceid": 2,
"shipmentvalue": null,
"chargetypes": [
"Commercial"
],
"billingtype": "Credit",
"mode": "pieces",
"id": 22,
"pieces": {
"totalpieces": 2,
"totalactualweight": "8.000",
"totalvolumetricweight": "0.019",
"totalchargeableweight": 8,
"actualweightunit": "KGS",
"measurementunit": "Centimeter",
"containers": [
{
"piecescounter": 1,
"piecescount": 2,
"piecesactualweight": 4,
"pieceslength": 3,
"piecesbreadth": 4,
"piecesheight": 4,
"piecesvolumetricweight": 0.019,
"pieceschargeableweight": "8.000",
"containeritemsgroup": {
"containerid": "",
"editmode": false,
"editsubitemid": 0,
"description": null,
"hsncode": null,
"unit": "KGS",
"weight": null,
"quantity": null,
"rate": null,
"amount": "",
"subitems": []
}
}
]
},
"piecesupdates": true
}

awbproforma-
{
"generatedfromid": 1,
"awbnumber": "we3450",
"customerid": 1,
"companyid": 1,
"referenceno": null,
"frompickup": false,
"bookingdate": "2024-12-25T18:06",
"productid": 2,
"productcode": "DOX",
"vendorid": 13,
"vendorcode": "DHL",
"serviceid": 2,
"shipmentvalue": null,
"chargetypes": [
"Commercial"
],
"billingtype": "Credit",
"mode": "proforma",
"id": 22,
"proforma": {
"updates": true,
"awbnumber": null,
"csbtype": "csb4",
"termofinvoice": 1,
"isgstinvoice": false,
"commercialinvoiceno": "4543",
"invoicedate": "2024-12-25",
"exportreason": "BUYER (IF OTHER THAN CONSIGNEE)",
"departmentno": "CSB4/ASP/NGST/251224",
"awbbuyerdetails": {
"name": "SBI",
"contactperson": "suresh ",
"email": "suresh@gmail.com",
"iecno": "54545ffdg",
"address": "mahavir nagar, kandiwali, mumbai"
}
}
}

awbcharges-
{
"generatedfromid": 1,
"awbnumber": "we3450",
"customerid": 1,
"companyid": 1,
"referenceno": null,
"frompickup": false,
"bookingdate": "2024-12-25T18:06",
"productid": 2,
"productcode": "DOX",
"vendorid": 13,
"vendorcode": "DHL",
"serviceid": 2,
"shipmentvalue": null,
"chargetypes": [
"Commercial"
],
"billingtype": "Credit",
"mode": "charges",
"id": 22,
"charges": {
"updates": true,
"chargetype": "Customer",
"contractchargesamount": 0,
"otherchargesamount": 4404,
"subtotal": 4404,
"totalfuel": 0,
"taxes": {
"type": "gst",
"tax": {
"igst": "396.360",
"cgst": "0.000",
"sgst": "0.000"
}
},
"totalamount": 4800.36,
"chargesdetails": [
{
"id": 1,
"chargetype": "Customer",
"chargesid": 4,
"chargesdescription": "PACKING CHARGE",
"itemamount": 4354,
"isitemfuel": false,
"fuelamount": 0,
"fueltax": true,
"fueltaxamount": 0,
"tax": true,
"taxamount": 391.86,
"itemtotal": 4745.86,
"igst": 391.86,
"sgst": 0,
"cgst": 0,
"taxtype": "gst",
"system": false
},
{
"id": 2,
"chargetype": "Customer",
"chargesid": 3,
"chargesdescription": "tox charges",
"itemamount": 50,
"isitemfuel": false,
"fuelamount": 0,
"fueltax": true,
"fueltaxamount": 0,
"tax": true,
"taxamount": 4.5,
"itemtotal": 54.5,
"igst": 4.5,
"sgst": 0,
"cgst": 0,
"taxtype": "gst",
"system": false
}
]
}
}

awbshipment-
{
"generatedfromid": 1,
"awbnumber": "we3450",
"customerid": 1,
"companyid": 1,
"referenceno": null,
"frompickup": false,
"bookingdate": "2024-12-25T18:06",
"productid": 2,
"productcode": "DOX",
"vendorid": 13,
"vendorcode": "DHL",
"serviceid": 2,
"shipmentvalue": null,
"chargetypes": [
"Commercial"
],
"billingtype": "Credit",
"mode": "shipment",
"id": 22,
"details": [
{
"update": "Yes",
"status": true,
"info": {
"id": null,
"type": "Shipper",
"name": "DEV SHIPPERS",
"contactperson": "DEVESH KOLI",
"emailid": "DEV@SHIPPER.XPRESION.IN",
"iecno": "GHT5651",
"isactive": true,
"location": {
"country": "IND",
"countrycode": "IN",
"state": "IN-MH",
"statecode": "MH",
"city": "IN-MH-24",
"citycode": "ISK",
"address1": "KAMBI NAGAR",
"mobileno": "7878787878",
"tel": "5555555555"
},
"kyc": {
"type": "GSTIN (Normal)",
"no": "29AABCA7045H1ZO"
}
}
},
{
"update": "Yes",
"status": true,
"info": {
"id": 56,
"type": "Consignee",
"code": "ADDR-56",
"name": "VIKAS",
"contactperson": "VIKAS YADAV",
"emailid": "VIKAS@GMAIL.COM",
"iecno": "3KJI6767",
"isactive": true,
"location": {
"country": "IND",
"countrycode": "IN",
"state": "IN-MH",
"statecode": "MH",
"city": "IN-MH-24",
"address1": "KAMBI NAGAR",
"mobileno": "7878787878",
"tel": "5555555555"
},
"kyc": {
"type": "PAN Number",
"no": "BBWPW0151T"
}
}
}
],
"shipmentdetails": {
"updates": true,
"awbnumber": null,
"fieldexecutive": null,
"salesexecutive": null,
"expecteddeliverydate": "2024-12-25T18:06",
"masterawbno": null,
"runno": "435454534",
"specialservicesdetail": {
"isdangerousgoods": false,
"goodstype": null,
"isdryice": false,
"dryiceweight": 0,
"bookingconfirmationno": "454654",
"isinsurancecovered": false,
"insurancecovervalue": 0,
"billshipmentto": {
"type": "Sender",
"accountno": null
},
"taxdutypaidby": {
"type": "Sender",
"accountno": null
},
"outputformat": "Paper 4x6 (PNG)",
"brokerdetails": {
"enabled": true,
"country": null,
"state": null,
"city": null,
"address1": null,
"address2": null,
"mobileno": null,
"tel": null
}
}
}
}

awbforwarding-
{
"generatedfromid": 1,
"awbnumber": "we3450",
"customerid": 1,
"companyid": 1,
"referenceno": null,
"frompickup": false,
"bookingdate": "2024-12-25T18:06",
"productid": 2,
"productcode": "DOX",
"vendorid": 13,
"vendorcode": "DHL",
"serviceid": 2,
"shipmentvalue": null,
"chargetypes": [
"Commercial"
],
"billingtype": "Credit",
"mode": "forwarding",
"id": 22,
"forwardingdetails": {
"updates": true,
"awbnumber": null,
"deliveryawbno": "4354",
"forwardingawbno": "6775675765",
"deliveryproduct": 2,
"deliveryvendor": 13,
"deliveryservice": 2,
"deliveryweight": "8.000",
"deliveryinvoice": "4545465775",
"charges": {
"chargetype": "Vendor",
"contractchargesamount": 0,
"otherchargesamount": 5645,
"subtotal": 5645,
"totalfuel": 0,
"igst": "0.000",
"cgst": "0.000",
"sgst": "0.000",
"totalamount": 5645,
"chargesdetails": [
{
"id": 1,
"chargetype": "Vendor",
"chargesid": 4,
"chargesdescription": "PACKING CHARGE",
"itemamount": 5645,
"isitemfuel": false,
"fuelamount": 0,
"fueltax": true,
"fueltaxamount": 0,
"tax": true,
"taxamount": 0,
"itemtotal": 5645,
"igst": 0,
"sgst": 0,
"cgst": 0,
"taxtype": "gst",
"system": false
}
]
}
}
}

awbkyc-
{
"generatedfromid": 1,
"awbnumber": "we3450",
"customerid": 1,
"companyid": 1,
"referenceno": null,
"frompickup": false,
"bookingdate": "2024-12-25T18:06",
"productid": 2,
"productcode": "DOX",
"vendorid": 13,
"vendorcode": "DHL",
"serviceid": 2,
"shipmentvalue": null,
"chargetypes": [
"Commercial"
],
"billingtype": "Credit",
"mode": "kyc",
"id": 22,
"kyc": [
{
"type": "GSTIN (Normal)",
"no": "454454544545",
"filepath": "https://xpresion-files-development.s3.ap-south-
1.amazonaws.com/uploads/dev/kyc/adharphoto-1735130360093.png",
"fileid": 225,
"entitytype": "AWB"
}
]
}

awbreceipt-
{
"generatedfromid": 1,
"awbnumber": "we3450",
"customerid": 1,
"companyid": 1,
"referenceno": null,
"frompickup": false,
"bookingdate": "2024-12-25T18:06",
"productid": 2,
"productcode": "DOX",
"vendorid": 13,
"vendorcode": "DHL",
"serviceid": 2,
"shipmentvalue": null,
"chargetypes": [
"Commercial"
],
"billingtype": "Credit",
"mode": "receipt",
"id": 22,
"receipt": {
"updates": true,
"receiptItems": [
{
"paymentmode": 1,
"paymentmodetype": "COD",
"amountreceived": 765,
"balanceamount": 4800.36,
"cashreceiptno": 56656,
"cashreceiptdate": "2024-12-25T18:06"
}
]
}
}

if (awbForm.valid) {
if (Number(this.piecesForm.get('totalactualweight').value) === 0) {
return this.openWarningDialog('Actual weight cannot be 0 or empty.');
}
this.loadDefaultsForm();
let details = [], csbDetails: any, buyerDetails: any;
let performaForm = this.performaForm;
// let chargeForm = this.chargeForm;
let shipmentinfo = awbForm.get('shipmentinfo');
let forwardinginfo = awbForm.get('forwardinginfo');
let shipperlocation = awbForm.get('shipperlocationdetails');
let consigneelocation = awbForm.get('consigneelocationdetails');
this.piecesForm.get('measurementunit').setValue(awbForm.get('ddlPiecesUnit')?.value
);

let shipper = shipperlocation.get('txtName').value;


shipper = (typeof shipper === 'string') ? shipper : shipper?.name;

let consignee = consigneelocation.get('txtName').value;


consignee = (typeof consignee === 'string') ? consignee : consignee?.name;

// const shipper = shipperlocation.get('txtName')?.value?.trim();


// const shipper = awbForm.get('txtShipperName').value;
// const consignee = consigneelocation.get('txtName')?.value?.trim();
// const consignee = awbForm.get('txtConsigneeName').value;
// console.log("shipper : ",shipper,"\nchonsignee : ",consignee);
let shipperArea = shipperlocation.get('txtArea').value;
shipperArea = (typeof shipperArea === 'string') ? shipperArea :
shipperArea?.area;
let consigneeArea = consigneelocation.get('txtArea').value;
consigneeArea = (typeof consigneeArea === 'string') ? consigneeArea :
consigneeArea?.area;

let shipperPincode = shipperlocation.get('txtPincode').value;


shipperPincode = (typeof shipperPincode === 'string') ? shipperPincode :
shipperPincode?.pincode;
let consigneePincode = consigneelocation.get('txtPincode').value;
consigneePincode = (typeof consigneePincode === 'string') ?
consigneePincode : consigneePincode?.pincode;

this.insertIntoFinalList();
const { isShipperNew, isConsigneeNew, shipperName, consigneeName } =
this.checkIsEntryNew();
// console.log('isShipperNew, isConsigneeNew',isShipperNew, isConsigneeNew);

if (isShipperNew) {
// console.log("shipper NO");
details.push({
update: 'No',
status: true,
info: {
name: shipperName?.toUpperCase(),
type: 'Shipper',
contactperson:
shipperlocation.get('txtContactPerson')?.value?.trim()?.toUpperCase(),
emailid: shipperlocation.get('txtEmail')?.value?.trim()?.toUpperCase(),
iecno:
this.awbForm.get('txtShipperIecIoeNo')?.value?.trim()?.toUpperCase(),
isactive: true,
location: {
country: shipperlocation.get('ddlCountry')?.value,
countrycode: this.originCountryList.find(x => x.isocode ===
shipperlocation.get('ddlCountry')?.value)?.code,
state: shipperlocation.get('ddlState')?.value,
statecode: this.originStateList.find(x => x.isocode ===
shipperlocation.get('ddlState')?.value)?.code,
city: shipperlocation.get('ddlCity')?.value,
citycode: this.originCityList.find(x => x.isocode ===
shipperlocation.get('ddlCity')?.value)?.code,
pincode: shipperPincode,
address1:
shipperlocation.get('txtAddress1')?.value?.trim()?.toUpperCase(),
address2:
shipperlocation.get('txtAddress2')?.value?.trim()?.toUpperCase(),
mobileno: shipperlocation.get('txtMobileNo')?.value,
tel: shipperlocation.get('txtTelephoneNo')?.value,
area: shipperArea?.trim()?.toUpperCase()
},
kyc: {
type: this.awbForm.get('ddlShipperDocumentType')?.value,
no: this.awbForm.get('txtShipperDocumentNo')?.value
},
generatedby: this.appCoreService.GetUserData().accessType,
generatedfromid:
this.appCoreService.GetUserData().selectedServiceCenter,
customerid: this.appCoreService.GetUserData().metaInfo.customerid
},
});
} else {
// console.log("shipper YES", this.shipperAddressBookId);
details.push({
update: "Yes",
status: true,
info: {
id: this.matchedShipper?.id ||
this.shipmentDetails.shipperAddressBookId || null,
type: 'Shipper',
code: this.matchedShipper?.code,
name: this.matchedShipper?.name?.toUpperCase(),
contactperson:
shipperlocation.get('txtContactPerson')?.value?.trim()?.toUpperCase(),
emailid: shipperlocation.get('txtEmail')?.value?.trim()?.toUpperCase(),
iecno: awbForm.get('txtShipperIecIoeNo')?.value?.trim()?.toUpperCase(),
isactive: true,
location: {
country: shipperlocation.get('ddlCountry')?.value,
countrycode: this.originCountryList.find(x => x.isocode ===
shipperlocation.get('ddlCountry')?.value)?.code,
state: shipperlocation.get('ddlState')?.value,
statecode: this.originStateList.find(x => x.isocode ===
shipperlocation.get('ddlState')?.value)?.code,
city: shipperlocation.get('ddlCity')?.value,
citycode: this.originCityList.find(x => x.isocode ===
shipperlocation.get('ddlCity')?.value)?.code,
pincode: shipperPincode,
address1:
shipperlocation.get('txtAddress1')?.value?.trim()?.toUpperCase(),
address2:
shipperlocation.get('txtAddress2')?.value?.trim()?.toUpperCase(),
mobileno: shipperlocation.get('txtMobileNo')?.value,
tel: shipperlocation.get('txtTelephoneNo')?.value,
area: shipperArea?.trim()?.toUpperCase()
},
kyc: {
type: this.awbForm.get('ddlShipperDocumentType')?.value,
no: this.awbForm.get('txtShipperDocumentNo')?.value
}
},

});
}

if (isConsigneeNew) {
// console.log("consignee NO");
details.push({
update: "No",
status: true,
info: {
type: 'Consignee',
name: consigneeName?.toUpperCase(),
contactperson:
consigneelocation.get('txtContactPerson')?.value?.trim()?.toUpperCase(),
emailid:
consigneelocation.get('txtEmail')?.value?.trim()?.toUpperCase(),
iecno:
awbForm.get('txtConsigneeIecIoeNo')?.value?.trim()?.toUpperCase(),
isactive: true,
location: {
country: consigneelocation.get('ddlCountry')?.value,
countrycode: this.destinationCountryList.find(x => x.isocode ===
consigneelocation.get('ddlCountry')?.value)?.code,
state: consigneelocation.get('ddlState')?.value,
statecode: this.destinationStateList.find(x => x.isocode ===
consigneelocation.get('ddlState')?.value)?.code,
city: consigneelocation.get('ddlCity')?.value,
citycode: this.destinationCityList.find(x => x.isocode ===
consigneelocation.get('ddlCity')?.value)?.code,
pincode: consigneePincode,
address1:
consigneelocation.get('txtAddress1')?.value?.trim()?.toUpperCase(),
address2:
consigneelocation.get('txtAddress2')?.value?.trim()?.toUpperCase(),
mobileno: consigneelocation.get('txtMobileNo')?.value,
tel: consigneelocation.get('txtTelephoneNo')?.value,
area: consigneeArea?.trim()?.toUpperCase()
},
kyc: {
type: this.awbForm.get('ddlConsigneeDocumentType')?.value,
no: this.awbForm.get('txtConsigneeDocumentNo')?.value
},
generatedby: this.appCoreService.GetUserData().accessType,
generatedfromid:
this.appCoreService.GetUserData().selectedServiceCenter,
customerid: this.appCoreService.GetUserData().metaInfo.customerid
},

});
} else {
// console.log("consignee YES", this.consigneeAddressBookId);
details.push({
update: "Yes",
status: true,
info: {
id: this.matchedConsignee?.id ||
this.shipmentDetails.consigneeAddressBookId || null,
type: 'Consignee',
code: this.matchedConsignee?.code,
name: this.matchedConsignee?.name?.toUpperCase(),
contactperson:
consigneelocation.get('txtContactPerson')?.value?.trim()?.toUpperCase(),
emailid:
consigneelocation.get('txtEmail')?.value?.trim()?.toUpperCase(),
iecno:
awbForm.get('txtConsigneeIecIoeNo')?.value?.trim()?.toUpperCase(),
isactive: true,
location: {
country: consigneelocation.get('ddlCountry')?.value,
countrycode: this.destinationCountryList.find(x => x.isocode ===
consigneelocation.get('ddlCountry')?.value)?.code,
state: consigneelocation.get('ddlState')?.value,
statecode: this.destinationStateList.find(x => x.isocode ===
consigneelocation.get('ddlState')?.value)?.code,
city: consigneelocation.get('ddlCity')?.value,
citycode: this.destinationCityList.find(x => x.isocode ===
consigneelocation.get('ddlCity')?.value)?.code,
pincode: consigneePincode,
address1:
consigneelocation.get('txtAddress1')?.value?.trim()?.toUpperCase(),
address2:
consigneelocation.get('txtAddress2')?.value?.trim()?.toUpperCase(),
mobileno: consigneelocation.get('txtMobileNo')?.value,
tel: consigneelocation.get('txtTelephoneNo')?.value,
area: consigneeArea?.trim()?.toUpperCase()
},
kyc: {
type: this.awbForm.get('ddlConsigneeDocumentType')?.value,
no: this.awbForm.get('txtConsigneeDocumentNo')?.value
}
},
});
}

if (this.isCsbType) {
csbDetails = {
lut: performaForm.get('csbDetails.ddlLutIgst')?.value,
totalisgt: performaForm.get('csbDetails.txtTotalIgst')?.value,
bankadcode: performaForm.get('csbDetails.txtBankAdCode')?.value,
bankaccount: performaForm.get('csbDetails.txtBankAccount')?.value,
bankifsc: performaForm.get('csbDetails.txtBankIfsc')?.value,
lutbondno: performaForm.get('csbDetails.txtLutBondNo')?.value,
exchangerate: performaForm.get('csbDetails.txtExchangeRate')?.value,
firm: performaForm.get('csbDetails.ddlFirm')?.value,
nfei: performaForm.get('csbDetails.nfeiCheck')?.value,
payofigst: performaForm.get('csbDetails.payOfIgstCheck')?.value,
ecommerce: performaForm.get('csbDetails.eCommerceCheck')?.value,
meisschema: performaForm.get('csbDetails.meisSchemaCheck')?.value,
}
}

if (Number(this.customerData?.igst) && (Number(this.customerData?.sgst) ||


Number(this.customerData?.sgst))) {
this.openWarningDialog(`Entry cannot contains [IGST] or [CGST/SGST] at a
time.`);
return;
}

if (this.isAwbBuyerDetailsChk) {
buyerDetails = {
name: performaForm.get('buyerDetails.txtName')?.value,
contactperson: performaForm.get('buyerDetails.txtPerson')?.value,
email: performaForm.get('buyerDetails.txtEmail')?.value,
iecno: performaForm.get('buyerDetails.txtIECNo')?.value,
address: performaForm.get('buyerDetails.txtAddress')?.value,
}
}

const shipperlocationdetails = this.awbForm.get('shipperlocationdetails');


const consigneelocationdetails =
this.awbForm.get('consigneelocationdetails');

const brockerPincode =
this.specialServicesForm.get('bsoBrokerlocationdetails.txtPincode')?.value;
const brockerArea =
this.specialServicesForm.get('bsoBrokerlocationdetails.txtArea')?.value;
const reqObj = {
mode: 'awb',
generatedfromid: this.selectedSCId,
awbnumber: awbForm.get('txtAwbNo')?.value,
customerid: awbForm.get('ddlCustomer')?.value,
companyid: awbForm.get('ddlCompanies')?.value,
referenceno: awbForm.get('txtReferenceNo')?.value,
frompickup: awbForm.get('usedPickup')?.value,
bookingdate: awbForm.get('txtDateTime')?.value,
productid: awbForm.get('ddlProduct')?.value,
vendorid: awbForm.get('ddlVendor')?.value,
serviceid: awbForm.get('ddlService')?.value,
shipmentvalue: awbForm.get('txtShipmentValue')?.value,

chargetypes: awbForm.get('ddlChargeType')?.value,
billingtype: awbForm.get('ddlBillingType')?.value,

details: details,
pieces: this.piecesForm.getRawValue(),
piecesupdates: this.piecesForm.dirty,
proforma: {
updates: this.performaForm.dirty,
awbnumber: awbForm.get('txtAwbNo')?.value,
csbtype: performaForm.get('ddlCSBType')?.value,
termofinvoice: performaForm.get('ddlInvoiceTerm')?.value,
isgstinvoice: performaForm.get('ddlGSTInvoice')?.value === 'Yes' ? true :
false,
commercialinvoiceno: performaForm.get('txtCommercialInvoiceNo')?.value,
invoicedate: performaForm.get('ddlInvoiceDate')?.value,
exportreason: performaForm.get('ddlExportReason')?.value,
departmentno: performaForm.get('txtDepartmentNo')?.value,
csbdetails: csbDetails,
awbbuyerdetails: buyerDetails
},
charges: {
//updates: this.chargeForm.dirty,
updates: true,
chargetype: this.customerRowData[0]?.chargetype || 'Customer',
contractchargesamount: this.customerData?.contractcharges,
otherchargesamount: this.customerData?.othercharges,
subtotal: this.customerData?.subtotal,
totalfuel: this.customerData?.totalfuel,
taxes: {
type: 'gst',
tax: {
igst: this.customerData?.igst,
cgst: this.customerData?.cgst,
sgst: this.customerData?.sgst,
}
},
totalamount: this.customerData?.totalamount,
chargesdetails: this.customerRowData,
},
shipmentdetails: {
updates: shipmentinfo.dirty || this.specialServicesForm.dirty,
awbnumber: awbForm.get('txtAwbNo')?.value,
fieldexecutive: shipmentinfo.get('ddlFieldExecutive')?.value,
salesexecutive: shipmentinfo.get('ddlSalesExecutive')?.value,
expecteddeliverydate: shipmentinfo.get('txtExpectedDeliveryDate')?.value,
masterawbno: shipmentinfo.get('txtMasterAwbNo')?.value,
runno: shipmentinfo.get('txtRunNo')?.value,
specialservicesdetail: {
isdangerousgoods:
this.specialServicesForm.get('dangerousGoodsCheck')?.value === 'No' ? false : true,
goodstype: this.specialServicesForm.get('ddldangerousGoods')?.value,
isdryice: this.specialServicesForm.get('dryIceCheck')?.value === 'No' ?
false : true,
dryiceweight: this.specialServicesForm.get('txtDryIceWeight')?.value ||
0,
bookingconfirmationno:
this.specialServicesForm.get('txtBookingConfirmationNo')?.value,
isinsurancecovered:
this.specialServicesForm.get('insuranceCoverCheck')?.value === 'No' ? false : true,
insurancecovervalue:
this.specialServicesForm.get('txtInsuranceCoverValue')?.value || 0,
billshipmentto: {
type: this.specialServicesForm.get('ddlbillShipmentTo')?.value,
accountno:
this.specialServicesForm.get('txtBillShipmentToAccNo')?.value
},
taxdutypaidby: {
type: this.specialServicesForm.get('ddlTaxAndDutiesPaidBy')?.value,
accountno:
this.specialServicesForm.get('txtTaxAndDutiesAccNo')?.value
},
outputformat: this.specialServicesForm.get('ddlOutputFormat')?.value,
brokerdetails: {
enabled: this.specialServicesForm.get('bsoBrokerCheck')?.value,
country:
this.specialServicesForm.get('bsoBrokerlocationdetails.ddlCountry')?.value,
state:
this.specialServicesForm.get('bsoBrokerlocationdetails.ddlState')?.value,
city:
this.specialServicesForm.get('bsoBrokerlocationdetails.ddlCity')?.value,
pincode: typeof brockerPincode === 'string' ? brockerPincode :
brockerPincode?.pincode,
address1:
this.specialServicesForm.get('bsoBrokerlocationdetails.txtAddress1')?.value,
address2:
this.specialServicesForm.get('bsoBrokerlocationdetails.txtAddress2')?.value,
area: typeof brockerArea === 'string' ? brockerArea :
brockerArea?.area,
mobileno:
this.specialServicesForm.get('bsoBrokerlocationdetails.txtMobileNo')?.value,
tel:
this.specialServicesForm.get('bsoBrokerlocationdetails.txtTelephoneNo')?.value
}
},
},
forwardingdetails: {
updates: forwardinginfo.dirty,
awbnumber: awbForm.get('txtAwbNo')?.value,
deliveryawbno: forwardinginfo.get('txtDeliveryAwb')?.value,
forwardingawbno: forwardinginfo.get('txtForwardingAwb')?.value,
deliveryproduct: forwardinginfo.get('ddlDeliveryProduct')?.value,
deliveryvendor: forwardinginfo.get('ddlDeliveryVendor')?.value,
deliveryservice: forwardinginfo.get('ddlDeliveryService')?.value,
deliveryweight: forwardinginfo.get('txtVendorWeight')?.value,
deliveryinvoice: forwardinginfo.get('txtVendorInvoiceNo')?.value,
charges: {
chargetype: this.vendorRowData[0]?.chargetype,
contractchargesamount: this.vendorData?.contractcharges,
otherchargesamount: this.vendorData?.othercharges,
subtotal: this.vendorData?.subtotal,
totalfuel: this.vendorData?.totalfuel,
igst: this.vendorData?.igst,
cgst: this.vendorData?.cgst,
sgst: this.vendorData?.sgst,
totalamount: this.vendorData?.totalamount,
chargesdetails: this.vendorRowData
}
},
kyc: this.kycList,
receipt: {
updates: this.receiptForm.dirty,
receiptItems: this.receiptList
},
productcode: this.productOptions.find(x => x.id ===
awbForm.get('ddlProduct')?.value).code,
vendorcode: this.vendorOptions.find(x => x.id ===
awbForm.get('ddlVendor')?.value).code,

//origincontrycode: this.originCountryList.find(x=>x.isocode ===


details.find(x=>x.type === 'Shipper')?.info?.location?.country)?.code,
origincountrycode: this.originCountryList.filter(x => x.isocode ===
shipperlocationdetails.get('ddlCountry').value)[0]?.code,
originstatecode: this.originStateList.filter(x => x.isocode ===
shipperlocationdetails.get('ddlState').value)[0]?.code,
origincitycode: this.originCityList.filter(x => x.isocode ===
shipperlocationdetails.get('ddlCity').value)[0]?.code,
//originstatecode: this.originStateList.find(x=>x.isocode ===
details.find(x=>x.type === 'Shipper')?.info?.location?.state)?.code,
//origincitycode: this.originCityList.find(x=>x.isocode ===
details.find(x=>x.type === 'Shipper')?.info?.location?.city)?.code,
originpincode: shipperPincode || null,

// destinationcontrycode: this.originCountryList.find(x=>x.isocode ===


details.find(x=>x.type === 'Consignee')?.info?.location?.country)?.code,
// destinationstatecode: this.originStateList.find(x=>x.isocode ===
details.find(x=>x.type === 'Consignee')?.info?.location?.state)?.code,
// destinationcitycode: this.originCityList.find(x=>x.isocode ===
details.find(x=>x.type === 'Consignee')?.info?.location?.city)?.code,
destinationcontrycode: this.destinationCountryList.filter(x => x.isocode
=== consigneelocationdetails.get('ddlCountry').value)[0]?.code,
destinationstatecode: this.destinationStateList.filter(x => x.isocode ===
consigneelocationdetails.get('ddlState').value)[0]?.code,
destinationcitycode: this.destinationCityList.filter(x => x.isocode ===
consigneelocationdetails.get('ddlCity').value)[0]?.code,
consigneepincode: consigneePincode || null,
};

let requestObject = {
generatedfromid: this.selectedSCId,
awbnumber: awbForm.get('txtAwbNo')?.value,
customerid: awbForm.get('ddlCustomer')?.value,
companyid: awbForm.get('ddlCompanies')?.value,
referenceno: awbForm.get('txtReferenceNo')?.value,
frompickup: awbForm.get('usedPickup')?.value,
bookingdate: awbForm.get('txtDateTime')?.value,
productid: awbForm.get('ddlProduct')?.value,
productcode: this.productOptions.find(x => x.id ===
awbForm.get('ddlProduct')?.value).code,
vendorid: awbForm.get('ddlVendor')?.value,
vendorcode: this.vendorOptions.find(x => x.id ===
awbForm.get('ddlVendor')?.value).code,
serviceid: awbForm.get('ddlService')?.value,
shipmentvalue: awbForm.get('txtShipmentValue')?.value,

chargetypes: awbForm.get('ddlChargeType')?.value,
billingtype: awbForm.get('ddlBillingType')?.value,
};

let awbRequestObject = {
mode: 'awb',
details: details,
};

let piecesRequestObject = {
mode: 'pieces',
id: null,
pieces: this.piecesForm.getRawValue(),
piecesupdates: this.piecesForm.dirty,
};

let proformaRequestObject = {
mode: 'proforma',
id: null,
proforma: {
updates: this.performaForm.dirty,
awbnumber: awbForm.get('txtAwbNo')?.value,
csbtype: performaForm.get('ddlCSBType')?.value,
termofinvoice: performaForm.get('ddlInvoiceTerm')?.value,
isgstinvoice: performaForm.get('ddlGSTInvoice')?.value === 'Yes' ? true :
false,
commercialinvoiceno: performaForm.get('txtCommercialInvoiceNo')?.value,
invoicedate: performaForm.get('ddlInvoiceDate')?.value,
exportreason: performaForm.get('ddlExportReason')?.value,
departmentno: performaForm.get('txtDepartmentNo')?.value,
csbdetails: csbDetails,
awbbuyerdetails: buyerDetails
}
};

let chargesRequestObject = {
mode: 'charges',
id: null,
charges: {
updates: true,
chargetype: this.customerRowData[0]?.chargetype || 'Customer',
contractchargesamount: this.customerData?.contractcharges,
otherchargesamount: this.customerData?.othercharges,
subtotal: this.customerData?.subtotal,
totalfuel: this.customerData?.totalfuel,
taxes: {
type: 'gst',
tax: {
igst: this.customerData?.igst,
cgst: this.customerData?.cgst,
sgst: this.customerData?.sgst,
}
},
totalamount: this.customerData?.totalamount,
chargesdetails: this.customerRowData,
},
};

let shipmentRequestObject = {
mode: 'shipment',
id: null,
details: details,
shipmentdetails: {
updates: shipmentinfo.dirty || this.specialServicesForm.dirty,
awbnumber: awbForm.get('txtAwbNo')?.value,
fieldexecutive: shipmentinfo.get('ddlFieldExecutive')?.value,
salesexecutive: shipmentinfo.get('ddlSalesExecutive')?.value,
expecteddeliverydate: shipmentinfo.get('txtExpectedDeliveryDate')?.value,
masterawbno: shipmentinfo.get('txtMasterAwbNo')?.value,
runno: shipmentinfo.get('txtRunNo')?.value,
specialservicesdetail: {
isdangerousgoods:
this.specialServicesForm.get('dangerousGoodsCheck')?.value === 'No' ? false : true,
goodstype: this.specialServicesForm.get('ddldangerousGoods')?.value,
isdryice: this.specialServicesForm.get('dryIceCheck')?.value === 'No' ?
false : true,
dryiceweight: this.specialServicesForm.get('txtDryIceWeight')?.value ||
0,
bookingconfirmationno:
this.specialServicesForm.get('txtBookingConfirmationNo')?.value,
isinsurancecovered:
this.specialServicesForm.get('insuranceCoverCheck')?.value === 'No' ? false : true,
insurancecovervalue:
this.specialServicesForm.get('txtInsuranceCoverValue')?.value || 0,
billshipmentto: {
type: this.specialServicesForm.get('ddlbillShipmentTo')?.value,
accountno:
this.specialServicesForm.get('txtBillShipmentToAccNo')?.value
},
taxdutypaidby: {
type: this.specialServicesForm.get('ddlTaxAndDutiesPaidBy')?.value,
accountno:
this.specialServicesForm.get('txtTaxAndDutiesAccNo')?.value
},
outputformat: this.specialServicesForm.get('ddlOutputFormat')?.value,
brokerdetails: {
enabled: this.specialServicesForm.get('bsoBrokerCheck')?.value,
country:
this.specialServicesForm.get('bsoBrokerlocationdetails.ddlCountry')?.value,
state:
this.specialServicesForm.get('bsoBrokerlocationdetails.ddlState')?.value,
city:
this.specialServicesForm.get('bsoBrokerlocationdetails.ddlCity')?.value,
pincode: typeof brockerPincode === 'string' ? brockerPincode :
brockerPincode?.pincode,
address1:
this.specialServicesForm.get('bsoBrokerlocationdetails.txtAddress1')?.value,
address2:
this.specialServicesForm.get('bsoBrokerlocationdetails.txtAddress2')?.value,
area: typeof brockerArea === 'string' ? brockerArea :
brockerArea?.area,
mobileno:
this.specialServicesForm.get('bsoBrokerlocationdetails.txtMobileNo')?.value,
tel:
this.specialServicesForm.get('bsoBrokerlocationdetails.txtTelephoneNo')?.value
}
},
},
};

let forwardingRequestObject = {
mode: 'forwarding',
id: null,
forwardingdetails: {
updates: forwardinginfo.dirty,
awbnumber: awbForm.get('txtAwbNo')?.value,
deliveryawbno: forwardinginfo.get('txtDeliveryAwb')?.value,
forwardingawbno: forwardinginfo.get('txtForwardingAwb')?.value,
deliveryproduct: forwardinginfo.get('ddlDeliveryProduct')?.value,
deliveryvendor: forwardinginfo.get('ddlDeliveryVendor')?.value,
deliveryservice: forwardinginfo.get('ddlDeliveryService')?.value,
deliveryweight: forwardinginfo.get('txtVendorWeight')?.value,
deliveryinvoice: forwardinginfo.get('txtVendorInvoiceNo')?.value,
charges: {
chargetype: this.vendorRowData[0]?.chargetype,
contractchargesamount: this.vendorData?.contractcharges,
otherchargesamount: this.vendorData?.othercharges,
subtotal: this.vendorData?.subtotal,
totalfuel: this.vendorData?.totalfuel,
igst: this.vendorData?.igst,
cgst: this.vendorData?.cgst,
sgst: this.vendorData?.sgst,
totalamount: this.vendorData?.totalamount,
chargesdetails: this.vendorRowData
}
},
};

let kycRequestObject = {
mode: 'kyc',
id: null,
kyc: this.kycList,
};

let receiptRequestObject = {
mode: 'receipt',
id: null,
receipt: {
updates: this.receiptForm.dirty,
receiptItems: this.receiptList
},
};

//check credit limit


// console.log("req", reqObj);
if (this.isCreditControlChecked) {
const isCreditLimitRemain = await this.checkCreditLimit(reqObj);
if (!isCreditLimitRemain) return;
}
if (this.permConfig.isAddAllowed && awbForm.valid) {
this.ngxLoaderService.start();
// console.log("reqobj : ", reqObj.details);

this.awbService.AddAWB({ ...requestObject, ...awbRequestObject }).subscribe(async


(res) => {
if (res && res.success) {
this.resetForm();
this.ngxLoaderService.stop();
// console.log(res);

let awbNumber = res?.data[0].awbnumber;


let awbId = res?.data[0].id;
// update request objects
requestObject.awbnumber = awbNumber;
piecesRequestObject.id = awbId;
proformaRequestObject.id = awbId;
chargesRequestObject.id = awbId;
shipmentRequestObject.id = awbId;
forwardingRequestObject.id = awbId;
kycRequestObject.id = awbId;
receiptRequestObject.id = awbId;

let errorMsg: string = '', msg: string = '';

if (res?.data[0].apiResponse) {
errorMsg = res?.data[0].apiResponse.message;
}

if (awbNumber) {
const stringValue = this.getOptionsHtml();

msg = `AWB no. <b> ${awbNumber} </b> Created Successfully <br><br> $


{errorMsg && errorMsg != '' ? `Api Error : ${errorMsg}` : ''}<br>
<select id="pickedByWhom" class="swal2-select" style="margin: 0px
0px 0px 5px !important;width: 78%;">
<option value="" selected>Select to assign field
executive</option>
${stringValue}
</select>
<button id="pickedBy" class="swal2-confirm
swal2-styled">Save</button>
`;

this.inscanAWB = awbNumber;
this.openConfirmationDialog(msg, awbNumber);

forkJoin({
awbpieces:
this.awbService.AddAWB({...requestObject, ...piecesRequestObject}),
awbproforma:
this.awbService.AddAWB({...requestObject, ...proformaRequestObject}),
awbcharges:
this.awbService.AddAWB({...requestObject, ...chargesRequestObject}),
awbshipment:
this.awbService.AddAWB({...requestObject, ...shipmentRequestObject}),
awbforwarding:
this.awbService.AddAWB({...requestObject, ...forwardingRequestObject}),
awbkyc:
this.awbService.AddAWB({...requestObject, ...kycRequestObject}),
awbreceipt:
this.awbService.AddAWB({...requestObject, ...receiptRequestObject})
}).subscribe({
next(value) {
// console.log('valuee', value);
},
error(err) {
console.log('service error', err);
},
})
}

}
if (res && !res.success) {
this.ngxLoaderService.stop();
this.openWarningDialog(res.message);
}
});
}
}

You might also like