import com.adaequare.mapro.model.data.*; import com.adaequare.mapro.model.detail.*; import com.adaequare.usermgmt.model.*; import java.util.InputMismatchException; import java.util.List; import com.adaequare.library.*; import com.adaequare.mapro.vo.common.*; import com.adaequare.common.utils.SpringBeanFinder; import org.json.JSONArray; import org.json.JSONObject; import java.text.SimpleDateFormat; import groovy.json.StreamingJsonBuilder; import org.apache.commons.io.*; import java.io.InputStream; import java.util.Date; import java.util.UUID; import java.math.*; import java.util.Date; import com.adaequare.mapro.model.detail.AssetDetail; import java.text.DecimalFormat; import java.util.StringTokenizer; import java.sql.Timestamp; import com.adaequare.mapro.library.AssetDevelopmentLibrary; import com.adaequare.mapro.model.detail.EntityRecordDetail; import java.math.BigDecimal; import java.math.RoundingMode; import org.apache.http.*; import org.apache.http.util.EntityUtils; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import com.adaequare.mapro.library.HttpCallLibrary; import org.apache.http.client.methods.HttpGet; import org.apache.http.entity.ContentType; import java.sql.Timestamp; String transactionSubtype = ''; String transactionType = ""; String supplierState = ''; String supplierGstin = ''; String reverseCharge = ""; String dispatcher_phone_number, dispatcher_emailid, dispatch_pincode, dispatch_state, dispatch_city, dispatch_address2, dispatch_address1, dispatchname, dispatchcode, dispatchGstin, organisation_Gstin, ecommerceGstin, gstRate, portCode, goodsServices, supplierPan, supplyType, placeOfSupply, flag_for_supply_covered_undersec7_of_igst_act1, buyerGstin, shipToGstin, preceINVNumber, preceINVDate, othRefNumber, receiptAdviceNumber, receiptAdviceDate, lotbatchRefNumber, contactRefNumber, externalRefNumber, projectRefNumber, poDate, invoicePeriodStartDate, invoicePeriodEndDate, shiptoLegalname, buyerPincode,buyerState,uqc,invoiceValue; Double igstamount, cgstamount, sgstamount, totalamount, quantity, dicountBeforegst, grossVal,ratePerQuantity; Double tot_Taxable_val = 0; Double taxableValue = 0.0; Double totalTaxableValue = 0.0; Double totalIgstAmount = 0.0; Double totalCgstAmount = 0.0; Double totalSgstAmount = 0.0; Double totalStateCessAmount=0.0; Double totalIgstAmt = 0.0; Double totalCgstAmt = 0.0; Double totalSgstAmt = 0.0; Double totalStateCessAmt = 0.0; Double igstAmt = 0.0; Double cgstAmt = 0.0; Double sgstAmt = 0.0; Double stateCessAmt = 0.0; Double totalItemvalue=0.0; Double igstamt=0; Double sgstamt=0; Double cgstamt=0; IAssetData assetData = assetData; IEntityData invoiceHeaders = Entities.getEntityById(assetData, 'header'); IEntityData Details = Entities.getEntityById(assetData, 'details'); if (invoiceHeaders != null) { Iterator < IEntityRecordData > invoiceHeadersRecords = invoiceHeaders.recordIterator(); while (invoiceHeadersRecords.hasNext()) { IEntityRecordData entityRowData1 = invoiceHeadersRecords.next(); supplyType = Fields.isNull(Fields.getFieldById(entityRowData1, "supplytype")) ? null : Fields.getFieldById(entityRowData1, "supplytype").getValue(); transactionType = Fields.isNull(Fields.getFieldById(entityRowData1, "transactiontype")) ? null : Fields.getFieldById(entityRowData1, "transactiontype").getValue(); transactionSubType = Fields.isNull(Fields.getFieldById(entityRowData1, "transactionsubtype")) ? null : Fields.getFieldById(entityRowData1, "transactionsubtype").getValue(); supplierPan = Fields.isNull(Fields.getFieldById(entityRowData1, "supplierpan")) ? null : Fields.getFieldById(entityRowData1, "supplierpan").getValue(); reverseCharge = Fields.isNull(Fields.getFieldById(entityRowData1, "reversecharge")) ? null : Fields.getFieldById(entityRowData1, "reversecharge").getValue(); organisation_Gstin = Fields.isNull(Fields.getFieldById(entityRowData1, "organisationgstinoruin")) ? null : Fields.getFieldById(entityRowData1, "organisationgstinoruin").getValue(); invoiceValue = Fields.isNull(Fields.getFieldById(entityRowData1, "invoice_value")) ? null : Fields.getFieldById(entityRowData1, "invoice_value").getValue(); /* if ("Outward".equals(supplyType) && !("Tax Invoice".equals(transactionType) || "Debit Note for Sales".equals(transactionType) || "Credit Note for Sales".equals(transactionType) || "Delivery Challan".equals(transactionType) || "Bill Of Supply".equals(transactionType) || "Other Document".equals(transactionType))) { Assets.addError(assetData, "INV-001 : If supply Type is Outward then 'Transaction Type' should be 'Tax Invoice/ Debit Note for Sales/ Credit Note for Sales/ Delivery Challan/ Bill Of Supply/ Other Document'. "); } if ("Inward".equals(supplyType) && !("Tax Invoice".equals(transactionType) || "Debit Note for Purchases".equals(transactionType) || "Credit Note for Purchases".equals(transactionType) || "B2C RCM Purchase Invoice".equals(transactionType) || "Bill Of Entry".equals(transactionType) || "Other Document".equals(transactionType))) { Assets.addError(assetData, "INV-002 : If supply type is Inward then 'Transaction Type' should be 'Tax Invoice/ Debit Note for Purchases/ Credit Note for Purchases/ B2C RCM Purchase Invoice/ Bill Of Entry/ Other Document'."); } if ("Outward".equals(supplyType) && !("Regular".equals(transactionSubType) || "SEZ With Payment".equals(transactionSubType) || "SEZ Without Payment".equals(transactionSubType) || "Export With Payment".equals(transactionSubType) || "Export Without Payment".equals(transactionSubType) || "Deemed Exports".equals(transactionSubType))) { Assets.addError(assetData, "INV-003 : If Supply Type is Outward then 'Transaction SubType' should be 'Regular/ SEZ With Payment/ SEZ Without Payment/ Export With Payment/ Export Without Payment/ Deemed Exports. "); } if ("Inward".equals(supplyType) && !("Regular".equals(transactionSubType) || "Purchase from SEZ".equals(transactionSubType) || "Imports".equals(transactionSubType))) { Assets.addError(assetData, "INV-004 : If Supply Type is Inward then 'Transaction SubType' should be 'Regular/ Purchase from SEZ/ Imports "); } if ("B2C RCM Purchase Invoice".equals(transactionType)) { if (supplierPan == null) { Assets.addError(assetData, "INV-026 : Supplier PAN' is mandatory in case of 'Transaction Subtype' is 'B2C RCM Purchase Invoice' "); } } if ("B2C RCM Purchase Invoice".equals(transactionType) || "Imports".equalsIgnoreCase(transactionSubtype)) { if (!("Yes".equalsIgnoreCase(reverseCharge))) { Assets.addError(assetData, "INV-027,INV-028 : Reverse Charge'should be 'Yes' in case of 'Transaction Subtype' is 'B2C RCM Purchase Invoice' or Reverse Charge'should be 'Yes' in case of 'Transaction Subtype' is 'Imports"); } } if ("Exports".equalsIgnoreCase(transactionSubtype)) { if (!("No".equalsIgnoreCase(reverseCharge))) { Assets.addError(assetData, "INV-029 : Reverse Charge'should be 'No' in case of 'Transaction Subtype' is 'Exports'"); } }*/ } } if (Details != null) { Iterator < IEntityRecordData > DetailsRecords = Details.recordIterator(); while (DetailsRecords.hasNext()) { IEntityRecordData entityRowData2 = DetailsRecords.next(); supplierState = Fields.isNull(Fields.getFieldById(entityRowData2, "supplierstate")) ? null : Fields.getFieldById(entityRowData2, "supplierstate").getValue(); placeOfSupply = Fields.isNull(Fields.getFieldById(entityRowData2, "placeofsupply")) ? null : Fields.getFieldById(entityRowData2, "placeofsupply").getValue(); flag_for_supply_covered_undersec7_of_igst_act1 = Fields.isNull(Fields.getFieldById(entityRowData2, "flagforsupplycoveredundersec7ofigstact")) ? null : Fields.getFieldById(entityRowData2, "flagforsupplycoveredundersec7ofigstact").getValue(); buyerGstin = Fields.isNull(Fields.getFieldById(entityRowData2, "buyergstin")) ? null : Fields.getFieldById(entityRowData2, "buyergstin").getValue(); shipToGstin = Fields.isNull(Fields.getFieldById(entityRowData2, "shiptogstin")) ? null : Fields.getFieldById(entityRowData2, "shiptogstin").getValue(); supplierGstin = Fields.isNull(Fields.getFieldById(entityRowData2, "suppliergstin")) ? null : Fields.getFieldById(entityRowData2, "suppliergstin").getValue(); portCode = Fields.isNull(Fields.getFieldById(entityRowData2, "portcode")) ? null : Fields.getFieldById(entityRowData2, "portcode").getValue(); ecommerceGstin = Fields.isNull(Fields.getFieldById(entityRowData2, "ecommercegstin")) ? null : Fields.getFieldById(entityRowData2, "ecommercegstin").getValue(); dispatchGstin = Fields.isNull(Fields.getFieldById(entityRowData2, "dispatchgstin")) ? null : Fields.getFieldById(entityRowData2, "dispatchgstin").getValue(); dispatchcode = Fields.isNull(Fields.getFieldById(entityRowData2, "dispatchcode")) ? null : Fields.getFieldById(entityRowData2, "dispatchcode").getValue(); dispatchname = Fields.isNull(Fields.getFieldById(entityRowData2, "dispatchname")) ? null : Fields.getFieldById(entityRowData2, "dispatchname").getValue(); dispatch_address1 = Fields.isNull(Fields.getFieldById(entityRowData2, "dispatchaddress1")) ? null : Fields.getFieldById(entityRowData2, "dispatchaddress1").getValue(); dispatch_address2 = Fields.isNull(Fields.getFieldById(entityRowData2, "dispatchaddress2")) ? null : Fields.getFieldById(entityRowData2, "dispatchaddress2").getValue(); dispatch_city = Fields.isNull(Fields.getFieldById(entityRowData2, "dispatchcity")) ? null : Fields.getFieldById(entityRowData2, "dispatchcity").getValue(); dispatch_state = Fields.isNull(Fields.getFieldById(entityRowData2, "dispatchstate")) ? null : Fields.getFieldById(entityRowData2, "dispatchstate").getValue(); dispatch_pincode = Fields.isNull(Fields.getFieldById(entityRowData2, "dispatchpincode")) ? null : Fields.getFieldById(entityRowData2, "dispatchpincode").getValue(); dispatcher_emailid = Fields.isNull(Fields.getFieldById(entityRowData2, "dispatcheremailid")) ? null : Fields.getFieldById(entityRowData2, "dispatcheremailid").getValue(); dispatcher_phone_number = Fields.isNull(Fields.getFieldById(entityRowData2, "dispatcherphonenumber")) ? null : Fields.getFieldById(entityRowData2, "dispatcherphonenumber").getValue(); preceINVNumber = Fields.isNull(Fields.getFieldById(entityRowData2, "precedinginvoicenumber")) ? null : Fields.getFieldById(entityRowData2, "precedinginvoicenumber").getValue(); preceINVDate = Fields.isNull(Fields.getFieldById(entityRowData2, "precedinginvoicedate")) ? null : Fields.getFieldById(entityRowData2, "precedinginvoicedate").getValue(); othRefNumber = Fields.isNull(Fields.getFieldById(entityRowData2, "otherreferencenumber")) ? null : Fields.getFieldById(entityRowData2, "otherreferencenumber").getValue(); receiptAdviceNumber = Fields.isNull(Fields.getFieldById(entityRowData2, "receiptadvicenumber")) ? null : Fields.getFieldById(entityRowData2, "receiptadvicenumber").getValue(); receiptAdviceDate = Fields.isNull(Fields.getFieldById(entityRowData2, "receiptadvicedate")) ? null : Fields.getFieldById(entityRowData2, "receiptadvicedate").getValue(); lotbatchRefNumber = Fields.isNull(Fields.getFieldById(entityRowData2, "lotorbatchreferencenumber")) ? null : Fields.getFieldById(entityRowData2, "lotorbatchreferencenumber").getValue(); contactRefNumber = Fields.isNull(Fields.getFieldById(entityRowData2, "contractreferencenumber")) ? null : Fields.getFieldById(entityRowData2, "contractreferencenumber").getValue(); externalRefNumber = Fields.isNull(Fields.getFieldById(entityRowData2, "externalreferencenumber")) ? null : Fields.getFieldById(entityRowData2, "externalreferencenumber").getValue(); projectRefNumber = Fields.isNull(Fields.getFieldById(entityRowData2, "projectreferencenumber")) ? null : Fields.getFieldById(entityRowData2, "projectreferencenumber").getValue(); poDate = Fields.isNull(Fields.getFieldById(entityRowData2, "podate")) ? null : Fields.getFieldById(entityRowData2, "podate").getValue(); invoicePeriodStartDate = Fields.isNull(Fields.getFieldById(entityRowData2, "invoiceperiodstartdate")) ? null : Fields.getFieldById(entityRowData2, "invoiceperiodstartdate").getValue(); invoicePeriodEndDate = Fields.isNull(Fields.getFieldById(entityRowData2, "invoiceperiodenddate")) ? null : Fields.getFieldById(entityRowData2, "invoiceperiodenddate").getValue(); shiptoLegalname = Fields.isNull(Fields.getFieldById(entityRowData2, "shiptolegalname")) ? null : Fields.getFieldById(entityRowData2, "shiptolegalname").getValue(); buyerPincode = Fields.isNull(Fields.getFieldById(entityRowData2, "buyerpincode")) ? null : Fields.getFieldById(entityRowData2, "buyerpincode").getValue(); buyerState=Fields.isNull(Fields.getFieldById(entityRowData2, "buyerstate")) ? null : Fields.getFieldById(entityRowData2, "buyerstate").getValue(); //totalamount = igstamount + cgstamount + sgstamount + compensation_cess_amount + state_cess_amount + state_cess_non_advol_amount + cess_non_advol_value; /* if ("SEZ Without Payment".equals(transactionSubType) || "Export Without Payment".equals(transactionSubType)) { if (totalamount > 0) { Assets.addError(assetData, "INV-018,INV-019 : If 'Transaction Subtype' is 'SEZ Without Payment' or ' Export Without Payment ', then 'Total GST amount + Total Cess amount' should be zero"); } } if ("Export With Payment".equals(transactionSubType) || "Export Without Payment".equals(transactionSubType)) { if (!("URP".equals(buyerGstin) || !"URP".equals(shipToGstin))) { Assets.addError(assetData, " INV-022 : If 'Transaction Sub Type ' is 'Export With Payment/Export Without Payment' then 'Buyer GSTIN/Ship to GSTIN' should be URP"); } } if ("SEZ Without Payment".equals(transactionSubType) || "SEZ With Payment".equals(transactionSubType) || "Deemed Exports".equals(transactionSubType)) { if ((buyerGstin != null) || "URP".equals(buyerGstin)) { Assets.addError(assetData, " INV-023 :If 'Transaction Sub Type ' is 'SEZ With Payment/SEZ Without Payment/Deemed Exports' then 'Buyer GSTIN should not be URP and a Valid GSTIN is Required"); } } if ("Imports".equals(transactionSubType)) { if (!("URP".equals(supplierGstin))) { Assets.addError(assetData, "INV-024 :If 'Transaction Sub Type ' is 'Imports' then 'Supplier GSTIN/UIN' should be URP"); } } if ("Purchase from SEZ".equals(transactionSubType)) { if ((supplierGstin != null) || "URP".equals(supplierGstin)) { Assets.addError(assetData, "INV-025 :If 'Transaction Sub Type ' is 'Purchase from SEZ' then 'Supplier GSTIN/UIN' should not be URP and a Valid GSTIN is Required"); } } if ("Export With Payment".equals(transactionSubType) || "Export Without Payment".equals(transactionSubType)) { if (!("OTH".equalsIgnoreCase(placeOfSupply))) { Assets.addError(assetData, "INV-034 : Place of supply' should be OTH in case of 'Exports' ") } } if (!("Export With Payment".equals(transactionSubType) || "Export Without Payment".equals(transactionSubType) || "SEZ With Payment".equals(transactionSubType) || ("SEZ Without Payment".equals(transactionSubType)))) { if (!("OTH".equalsIgnoreCase(placeOfSupply))) { Assets.addError(assetData, "INV-035 : Place of Supply' should not be 'OTH' in case of 'Transaction Subtype' is not " + "Exports With Payment or " + "SEZ With Payment or " + "Export Without Payment or " + "SEZ Without Payment " ); } } if ("Imports".equals(transactionSubType)) { if (!("OTH".equals(supplierState))) { Assets.addError(assetData, "INV-036 :Supplier State should be OTH in case of Transaction subtype is Imports" ); } } if ("Imports".equals(transactionSubType)) { if (("OTH".equals(supplierState))) { Assets.addError(assetData, "INV-037 : Supplier State should not be OTH in case of Transaction Subtype is not" + "Imports " ); } } if ("Tax Invoice".equals(transactionType) || "Debit Note for Sales".equals(transactionType) || "Credit Note for Sales".equals(transactionType)) { if ((organisation_Gstin).equals(shipToGstin) || (organisation_Gstin).equals(buyerGstin) || (organisation_Gstin).equals(ecommerceGstin)) { Assets.addError(assetData, "INV-050 : If Transaction Type is Tax Invoice/Debit Note for Sales/Credit Note for Sales then Organisation GSTIN/UIN should not be equal to " + "Customer GSTIN / UIN, Ship to GSTIN / E Commerce GSTIN "); } } if ((ecommerceGstin).equals(shipToGstin) || (ecommerceGstin).equals(buyerGstin) || (ecommerceGstin).equals(dispatchGstin)) { Assets.addError(assetData, "INV-051 : " + "Customer GSTIN / UIN / Dispatch GSTIN / Ship to GSTIN should not be equal to E Commerce GSTIN"); } if ((dispatchGstin != null || dispatchName != null || dispatch_address1 != null || dispatch_address2 != null || dispatch_city != null dispatch_state != null dispatch_pincode != null) && (dispatchLegalName == null || dispatch_address1 != null || dispatch_city == null || dispatch_state == null || dispatch_pincode == null)) { Assets.addError(assetData, "INV-052: Dispatch GSTIN, Dispatch Name, Dispatch Address 1 ,Dispatch Address 2,Dispatch City, Dispatch State, Dispatch PIN Code if the data is present in any one of the mentioned fields then Dispatch Name , Dispatch Address 1 ,Dispatch City, Dispatch State, Dispatch PIN Code are Mandatory"); }*/ // if ((shiptoLegalname != null || shiptoTradename != null || shipToGstin != null || shiptoAdd1 != null || shiptoAdd2 != null || shiptoCity != null || shiptoState != null || shiptoPincode != null) && (shiptoLegalname == null || shiptoAdd1 == null || shiptoCity == null || shiptoState == null || shiptoPincode == null)) { // Assets.addError(assetData, "INV-053: Ship to Legal Name,Ship to Trade Name, Ship to GSTIN,Ship to Address 1 ,Ship to Address 2, Ship to City, Ship to State, Ship to PIN Code if the data is present in any one of the mentioned fields then Ship to Legal Name,Ship to Address 1 , Ship to City, Ship to State, Ship to PIN Code are Mandatory"); // } // if ((preceINVNumber != null || preceINVDate != null || othRefNumber != null) && (preceINVNumber == null || preceINVDate == null)) { // Assets.addError(assetData, "INV-054: Preceding Invoice Number, Preceding Invoice Date, Other Reference Number If the data is present in any one the mentioned fields then Preceding Invoice Number, Preceding Invoice Date are Mandatory "); //} // if ((receiptAdviceNumber != null || receiptAdviceDate != null || lotbatchRefNumber != null || contactRefNumber != null || externalRefNumber != null || projectRefNumber != null || poDate != null || poNumber != null) && (invoicePeriodStartDate == null || invoicePeriodEndDate == null) { // Assets.addError(assetData, "INV-055: Receipt Advice Number, Receipt Advice Date,Lot/Batch Reference Number,Contract Reference Number,External Reference Number,Project Reference Number,PO Number,PO Date if the data is present in any one of the mentioned fields then Invoice Period Start Date ,Invoice Period End Date is Mandatory"); // } // if ((invoicePeriodStartDate != null || invoicePeriodEndDate != null) && (invoicePeriodStartDate == null || invoicePeriodEndDate == null)) { // Assets.addError(assetData, "INV-056: Invoice Period Start Date, Invoice Period End Date if data is present in any one of the mentioned fields then Invoice Period Start Date , Invoice Period End Date are Mandatory"); // } // if ("B2C RCM Purchase Invoice".equals(transactionType) && !"URP".equals(supplierGSTIN)) { // Assets.addError(assetData, "INV-058: Supplier GSTIN' should be 'URP' or'Blank' in case of 'Transaction Subtype' is 'B2C RCM Purchase Invoice'"); // } /* if ("Outward".equals(supplyType) && (orgGstin != null)) { if (orgState != null) { String orgStatecode = stateCodes.get(orgState.toUpperCase()); String orgGSTN = orgGstin.substring(0, 2); if (orgStatecode != orgGSTN) { Assets.addError(assetData, "INV-060: Supplier State doesn’t belong to GSTIN provided"); } } } if (("Export With Payment".equals(transactionSubType) || "Export Without Payment".equals(transactionSubType)) && (shiptoLegalname == null || dispatch_address1 == null || dispatch_city == null || dispatch_state == null || dispatch_pincode == null)) { Assets.addError(assetData, "INV-065: In case of export transactions, the ‘Ship-To’ address should be of the place or port from where the goods are being exported"); } if ("SEZ With Payment".equals(transactionSubType) || "SEZ Without Payment".equals(transactionSubType)) { if (!("Others".equals(placeOfSupply))) { Assets.addError(assetData, "INV-067 : Place of supply should be 'OTH" in case SEZ transactions ") } } if (("Regular".equals(transactionSubType) && (buyerGstin != null))) { if (buyerPincode == null) { Assets.addError(assetData, "INV-069 :Buyer PIN Code is Mandatory for Domestic B2B transactions"); } }*/ if (("SEZ With Payment".equalsIgnoreCase(transactionSubtype) || "SEZ Without Payment".equalsIgnoreCase(transactionSubtype)) && !"Others".equalsIgnoreCase(buyerState)) { Assets.addError(assetData, "INV-082: Buyer State should be 'OTH' in case SEZ Transactions"); } /* if (("Export With Payment".equalsIgnoreCase(transactionSubtype) || "Export Without Payment".equalsIgnoreCase(transactionSubtype)) && !"Others".equalsIgnoreCase(buyerState)) { Assets.addError(assetData, "INV-083: Buyer State should be 'OTH' in case Export Transactions"); }*/ /*if ("Regular".equals(transactionSubType)) { if ("URP".equals(buyerGstin)) { Assets.addError(assetData, "INV-089 : If Transaction Subtype is Regular then Customer GSTIN/UIN should be Valid GSTIN/UIN"); } } if ("Unregistered".equals(transactionSubType)) { if (!("URP".equals(buyerGstin))) { Assets.addError(assetData, "INV-090 : If Transaction Subtype is Unregistered then Customer GSTIN/UIN should be blank or URP"); } }*/ IEntityData itemdetails = Entities.getEntityById(entityRowData2.entityIterator(), "lineitemdetails"); if (itemdetails != null) { Iterator < IEntityRecordData > itemDetailsRecords = itemdetails.recordIterator(); while (itemDetailsRecords.hasNext()) { IEntityRecordData itementityRowData = itemDetailsRecords.next(); igstamount = Fields.isNull(Fields.getFieldById(itementityRowData, "igstamount")) ? 0 : Fields.getFieldById(itementityRowData, "igstamount").getValue(); cgstamount = Fields.isNull(Fields.getFieldById(itementityRowData, "cgstamount")) ? 0 : Fields.getFieldById(itementityRowData, "cgstamount").getValue(); sgstamount = Fields.isNull(Fields.getFieldById(itementityRowData, "sgstorutgstamount")) ? 0 : Fields.getFieldById(itementityRowData, "sgstorutgstamount").getValue(); taxableValue = Fields.isNull(Fields.getFieldById(itementityRowData, "taxablevalue")) ? 0 : Fields.getFieldById(itementityRowData, "taxablevalue").getValue(); hsnCode = Fields.isNull(Fields.getFieldById(itementityRowData, "hsncode")) ? null : Fields.getFieldById(itementityRowData, "hsncode").getValue(); goodsServices = Fields.isNull(Fields.getFieldById(itementityRowData, "goodsorservices")) ? null : Fields.getFieldById(itementityRowData, "goodsorservices").getValue(); gstRate = Fields.isNull(Fields.getFieldById(itementityRowData, "gstrate")) ? 0 : Fields.getFieldById(itementityRowData, "gstrate").getValue(); uqc = Fields.isNull(Fields.getFieldById(itementityRowData, "uqc")) ? 0 : Fields.getFieldById(itementityRowData, "uqc").getValue(); quantity = Fields.isNull(Fields.getFieldById(itementityRowData, "quantity")) ? 0 : Fields.getFieldById(itementityRowData, "quantity").getValue(); grossVal = Fields.isNull(Fields.getFieldById(itementityRowData, "grossvalue")) ? 0 : Fields.getFieldById(itementityRowData, "grossvalue").getValue(); dicountBeforegst = Fields.isNull(Fields.getFieldById(itementityRowData, "discountbeforegst")) ? 0 : Fields.getFieldById(itementityRowData, "discountbeforegst").getValue(); ratePerQuantity=Fields.isNull(Fields.getFieldById(itementityRowData, "rateperquantity")) ? 0 : Fields.getFieldById(itementityRowData, "rateperquantity").getValue(); igstamt = igstamt + igstamount; sgstamt = sgstamt + sgstamount; cgstamt = cgstamt + cgstamount; /* if ("Regular".equals(transactionSubType) || "Deemed Exports".equals(transactionSubType)) { if (!"supplierState".equals(placeOfSupply) && (cgstamount > 0 && sgstamount > 0)) { Assets.addError(assetData, "INV-005 and INV-010 : CGST / SGST is not applicable to inter-state transactions."); } } if (("Others".equals(supplierState) || "97".equals(supplierState)) && (cgstamount > 0 && sgstamount > 0)) { Assets.addError(assetData, "INV-006 : CGST / SGST is not applicable when supplier state is Others"); } if ("97".equals(organisation_Gstin) && (cgstamount > 0 && sgstamount > 0)) { Assets.addError(assetData, "INV-007 : CGST / SGST is not applicable when ORG GSTIN starts with 97"); } if (("Others".equals(placeOfSupply) || "97".equals(placeOfSupply)) && (cgstamount > 0 && sgstamount > 0)) { Assets.addError(assetData, "INV-008 : CGST / SGST is not applicable when place Of Supply is Others"); } if ("yes".equals(flag_for_supply_covered_undersec7_of_igst_act1) && (cgstamount > 0 && sgstamount > 0)) { Assets.addError(assetData, "INV-009:CGST / SGST is not applicable when IGST is applicable under section 7 of IGST"); } if ("Regular".equals(transactionSubType) || "Deemed Exports".equals(transactionSubType)) { if ("supplierState".equals(placeOfSupply) && (igstamount > 0)) { Assets.addError(assetData, "INV-011 and INV-012 : IGST is not applicable to intra-state transactions."); } } if (("97".equals(supplierGstin)) && igstAmt < 0) { Assets.addError(assetData, "INV-013 : If Supplier GSTIN starts with 97 then only IGST is only allowed"); } if ("SEZ With Payment".equalsIgnoreCase(transactionSubtype) || "Imports".equalsIgnoreCase(transactionSubtype) || "Purchase from SEZ".equalsIgnoreCase(transactionSubtype) || "Export With Payment".equalsIgnoreCase(transactionSubtype)) { if (sgstAmt > 0 && cgstAmt > 0) { Assets.addError(assetData, "INV-014,INV-015,INV-016,INV-017: CGST/SGST is not allowed if 'Transaction Subtype' is ' [${transactionSubtype}]'"); } } if (hsnCode != "null" && "Services".equalsIgnoreCase(goodsServices)) { if (!(hsnCode.substring(0, 2) == '99')) { Assets.addError(assetData, "INV-039 : For 'Services' HSN code should start with '99'"); } } if (hsnCode != "null" && "Goods".equalsIgnoreCase(goodsServices)) { if ((hsnCode.substring(0, 2) == '99')) { Assets.addError(assetData, "INV-040 : For 'Services' HSN code should not start with '99'"); } } if ("Imports".equals(transactionSubType) && "Goods".equalsIgnoreCase(goodsServices)) { if (!("Bill of Entry".equals(transactionType))) { Assets.addError(assetData, "INV-041 :If 'Transaction Subtype' is 'Imports' and 'Goods/Services' is 'Goods', then 'Transaction Type' should be 'Bill of Entry'"); } } if ("Purchase from SEZ".equals(transactionSubType) && !("Goods".equalsIgnoreCase(goodsServices))) { if (!("Bill of Entry".equals(transactionType))) { Assets.addError(assetData, "INV-042 :If 'Transaction Subtype' is 'Imports' and 'Goods/Services' is 'Goods', then 'Transaction Type' should be 'Bill of Entry'"); } } if (!("Imports".equals(transactionSubType) && "Goods".equalsIgnoreCase(goodsServices))) { if (("Bill of Entry".equals(transactionType))) { Assets.addError(assetData, "INV-043 :If 'Transaction Subtype' is 'Imports' and 'Goods/Services' is 'Goods', then 'Transaction Type' should be 'Bill of Entry'"); } } if (!("Purchase from SEZ".equals(transactionSubType) && "Goods".equalsIgnoreCase(goodsServices))) { if (("Bill of Entry".equals(transactionType))) { Assets.addError(assetData, "INV-044 :If 'Transaction Subtype' is 'Imports' and 'Goods/Services' is 'Goods', then 'Transaction Type' should be 'Bill of Entry'"); } } if ("Imports".equals(transactionSubType) || "Purchase from SEZ".equals(transactionSubType) && "Goods".equalsIgnoreCase(goodsServices)) { if (portCode == null) { Assets.addError(assetData, "INV-045 :Port Code' is Mandatory in case 'Transaction Sub Type' is 'Imports' or 'Purchase from SEZ' & 'Goods/Services' is 'Goods'"); } } if ("Deemed Exports".equals(transactionSubType) && "Goods".equalsIgnoreCase(goodsServices)) { Assets.addError(assetData, "INV-046 : If 'Transaction SubType' is 'Deemed Exports' then 'Goods/Service' should be 'Goods'"); } if ("Bill of Supply".equals(transactionType) || "Delivery Challan".equals(transactionType)) { if (gstRate != 0) { Assets.addError(assetData, "INV-047 , INV-048 :If Transaction Type is Bill of Supply or Delivery Challan then GST rate should be zero"); } } if ("Goods".equals(goodsServices)) { if (uqc == null && quantity == null) { Assets.addError(assetData, "INV-070 For Goods UQC & Qunatity are required"); } } if (taxableValue != (grossVal - dicountBeforegst)) { Assets.addError(assetData, "INV-071 : Taxable Value should be equal to [Gross Value -Discount]"); }*/ if ("Goods".equals(goodsServices)) { if (grossVal != (quantity) * (ratePerQuantity)) { Assets.addError(assetData, "INV-072 Gross Value should be equal to [Unitprice* Quantity]"); } } totalItemvalue = igstamt + sgstamt + cgstamt; if (invoicValue != totalItemvalue) { Assets.addError(assetData, "INV-079: [Invoice Value] should be equal to Sum of all [Total Item Values] of Line Items"); } } } } } if (Details != null) { Iterator < IEntityRecordData > DetailsRecords = Details.recordIterator(); while (DetailsRecords.hasNext()) { IEntityRecordData entityRowData2 = DetailsRecords.next(); totalTaxableValue = Fields.isNull(Fields.getFieldById(entityRowData2, "totaltaxablevalue")) ? null : Fields.getFieldById(entityRowData2, "totaltaxablevalue").getValue(); totalIgstAmt=Fields.isNull(Fields.getFieldById(entityRowData2, "totaligstamount")) ? null : Fields.getFieldById(entityRowData2, "totaligstamount").getValue(); totalCgstAmt=Fields.isNull(Fields.getFieldById(entityRowData2, "totalcgstamount")) ? null : Fields.getFieldById(entityRowData2, "totalcgstamount").getValue(); totalSgstAmt=Fields.isNull(Fields.getFieldById(entityRowData2, "totalsgstorutgstamount")) ? null : Fields.getFieldById(entityRowData2, "totalsgstorutgstamount").getValue(); totalStateCessAmt=Fields.isNull(Fields.getFieldById(entityRowData2, "totalstatecessamount")) ? null : Fields.getFieldById(entityRowData2, "totalstatecessamount").getValue(); IEntityData itemdetails = Entities.getEntityById(entityRowData2.entityIterator(), "lineitemdetails"); if (itemdetails != null) { Iterator < IEntityRecordData > itemDetailsRecords = itemdetails.recordIterator(); while (itemDetailsRecords.hasNext()) { IEntityRecordData itementityRowData = itemDetailsRecords.next(); taxableValue = Fields.isNull(Fields.getFieldById(itementityRowData, "taxablevalue")) ? 0 : Fields.getFieldById(itementityRowData, "taxablevalue").getValue(); igstAmt=Fields.isNull(Fields.getFieldById(itementityRowData, "igstamount")) ? 0 : Fields.getFieldById(itementityRowData, "igstamount").getValue(); cgstAmt=Fields.isNull(Fields.getFieldById(itementityRowData, "cgstamount")) ? 0 : Fields.getFieldById(itementityRowData, "cgstamount").getValue(); sgstAmt= Fields.isNull(Fields.getFieldById(itementityRowData, "sgstorutgstamount")) ? 0 : Fields.getFieldById(itementityRowData, "sgstorutgstamount").getValue(); stateCessAmt=Fields.isNull(Fields.getFieldById(itementityRowData, "statecessamount")) ? 0 : Fields.getFieldById(itementityRowData, "statecessamount").getValue(); tot_Taxable_val = tot_Taxable_val + taxableValue; if (tot_Taxable_val != totalTaxableValue) { Assets.addError(assetData, "INV-073: [Total Taxable Value] should be equal to Sum of all [Taxable Values] of Line Items"); } totalIgstAmt = totalIgstAmt + igstAmt; if(totalIgstAmount != totalIgstAmt) { Assets.addError(assetData, "INV-074: [Total IGST Value] should be equal to Sum of all [IGST Values] of Line Items"); } totalCgstAmt = totalCgstAmt + cgstAmt; if(totalCgstAmount != totalCgstAmt) { Assets.addError(assetData, "INV-075: [Total CGST Value] should be equal to Sum of all [CGST Values] of Line Items"); } totalSgstAmt = totalSgstAmt + sgstAmt; if(totalSgstAmount != totalSgstAmt) { Assets.addError(assetData, "INV-076: [Total SGST Value] should be equal to Sum of all [SGST Values] of Line Items"); } totalStateCessAmt = totalStateCessAmt + stateCessAmt; if(totalStateCessAmount != totalStateCessAmt) { Assets.addError(assetData, "INV-078: [Total State Cess Value] should be equal to Sum of all [State Cess Values] of Line Items"); } } } } }
Write, Run & Share Groovy code online using OneCompiler's Groovy online compiler for free. It's one of the robust, feature-rich online compilers for Groovy language, running the latest Groovy version 2.6. Getting started with the OneCompiler's Groovy editor is easy and fast. The editor shows sample boilerplate code when you choose language as Groovy and start coding.
OneCompiler's Groovy online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Groovy program which takes name as input and prints hello message with your name.
def name = System.in.newReader().readLine()
println "Hello " + name
Groovy is an object-oriented programming language based on java. Apache Groovy is a dynamic and agile language which is similar to Python, Ruby, Smalltalk etc.
Data type | Description | Range |
---|---|---|
String | To represent text literals | NA |
char | To represent single character literal | NA |
int | To represent whole numbers | -2,147,483,648 to 2,147,483,647 |
short | To represent short numbers | -32,768 to 32,767 |
long | To represent long numbers | -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 |
double | To represent 64 bit floating point numbers | 4.94065645841246544e-324d to 1.79769313486231570e+308d |
float | To represent 32 bit floating point numbers | 1.40129846432481707e-45 to 3.40282346638528860e+38 |
byte | To represent byte value | -128 to 127 |
boolean | To represent boolean values either true or false | True or False |
You can define variables in two ways
data-type variable-name;
[or]
def variable-name;
0.upto(n) {println "$it"}
or
n.times{println "$it"}
where n is the number of loops and 0 specifies the starting index
When ever you want to perform a set of operations based on a condition or set of conditions, then If / Nested-If / If-Else is used.
if(conditional-expression) {
// code
} else {
// code
}
Switch is an alternative to If-Else-If ladder and to select one among many blocks of code.
switch(conditional-expression) {
case value1:
// code
break; // optional
case value2:
// code
break; // optional
...
default:
//code to be executed when all the above cases are not matched;
}
List allows you to store ordered collection of data values.
def mylist = [1,2,3,4,5];
List Methods | Description |
---|---|
size() | To find size of elements |
sort() | To sort the elements |
add() | To append new value at the end |
contains() | Returns true if this List contains requested value. |
get() | Returns the element of the list at the definite position |
pop() | To remove the last item from the List |
isEmpty() | Returns true if List contains no elements |
minus() | This allows you to exclude few specified elements from the elements of the original |
plus() | This allows you to add few specified elements to the elements of the original |
remove() | To remove the element present at the specific position |
reverse() | To reverse the elements of the original List and creates new list |