From b7c8aef9e58698662ba86467c7118660f96c63a8 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 30 Jan 2020 15:34:28 -0800 Subject: [PATCH] Added missing fields for CIECA import. --- .../Utils/Decoder/EstimateDecoder.cs | 99 ++++++++++--------- 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs b/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs index 3146187..5ce3693 100644 --- a/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs +++ b/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs @@ -21,7 +21,7 @@ namespace BodyshopUploader.Utils.Decoder /// /// Full path to the envelope file that was created/updated. /// - public static dynamic DecodeEstimate(string FilePath) + public static dynamic DecodeEstimate(string FilePath, SourceSystem _source = SourceSystem.Mitchell) { dynamic ret = new JObject(); @@ -33,7 +33,7 @@ namespace BodyshopUploader.Utils.Decoder ParseAd2File(ref ret, _dir); ParseVehFile(ref ret, _dir); ParsePfhFile(ref ret, _dir); - ParsePflFile(ref ret, _dir); + ParsePflFile(ref ret, _dir, _source); ParsePfmFile(ref ret, _dir); //ParseStlFile(ref ret, _dir); //Contains information about the total amounts of the estimate. //ParseTtlFile(ref ret, _dir); @@ -403,24 +403,28 @@ namespace BodyshopUploader.Utils.Decoder //Values divided by 100 to make consistent. //j.id_pro_nam = readValues[0];//ID_PRO_NAM - //TODO: ADD //j.tax_prethr = readValues[1];//TAX_PRETHR Parts tax for pre-threshold - //TODO: ADD //j.tax_thramt = readValues[2];//TAX_THRAMT Parts threshold amount - //TODO: ADD //j.tax_pstthr = float.Parse(readValues[3].ToString())/100;//TAX_PSTTHR //PST for Parts + j.tax_prethr = readValues[1];//TAX_PRETHR Parts tax for pre-threshold + j.tax_thramt = readValues[2];//TAX_THRAMT Parts threshold amount + j.tax_pstthr = float.Parse(readValues[3].ToString()) / 100;//TAX_PSTTHR //PST for Parts //j.tax_tow_in = readValues[4];//TAX_TOW_IN j.tax_tow_rt = (bool)readValues[4] ? float.Parse(readValues[5].ToString()) / 100 : 0;//TAX_TOW_RT + //j.tax_str_in = readValues[6];//TAX_STR_IN - //TODO: ADD //j.tax_str_rt = readValues[7];//TAX_STR_RT + j.tax_str_rt = (bool)readValues[6] ? float.Parse(readValues[7].ToString()) / 100 : 0;//TAX_STR_RT + //j.tax_sub_in = readValues[8];//TAX_SUB_IN - //TODO: ADD //j.tax_sub_rt = (bool)readValues[8] ? float.Parse(readValues[9].ToString()) / 100 : 0;//TAX_SUB_RT + j.tax_sub_rt = (bool)readValues[8] ? float.Parse(readValues[9].ToString()) / 100 : 0;//TAX_SUB_RT + //j.tax_btr_in = readValues[10];//TAX_BTR_IN - //TODO: ADD //j.tax_lbr_rt = readValues[11];//TAX_LBR_RT + j.tax_lbr_rt = readValues[11];//TAX_LBR_RT j.federal_tax_rate = float.Parse(readValues[12].ToString()) / 100;//TAX_GST_RT //j.tax_gst_in = readValues[13];//TAX_GST_IN - //TODO: ADD //j.adj_g_disc = readValues[14];//ADJ_G_DISC - //TODO: ADD //j.adj_towdis = readValues[15];//ADJ_TOWDIS - //TODO: ADD //j.adj_strdis = readValues[16];//ADJ_STRDIS + j.adj_g_disc = readValues[14];//ADJ_G_DISC + j.adj_towdis = readValues[15];//ADJ_TOWDIS + j.adj_strdis = readValues[16];//ADJ_STRDIS + //j.adj_btr_in = readValues[17];//ADJ_BTR_IN - //TODO: ADD //j.tax_predis = readValues[18];//TAX_PREDIS + j.tax_predis = readValues[18];//TAX_PREDIS reader.Dispose(); return; } @@ -434,7 +438,7 @@ namespace BodyshopUploader.Utils.Decoder } } - public static void ParsePflFile(ref dynamic j, string RootFilePath) + public static void ParsePflFile(ref dynamic j, string RootFilePath, SourceSystem _source = SourceSystem.Mitchell) { if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) { @@ -470,7 +474,6 @@ namespace BodyshopUploader.Utils.Decoder for (int i = 0; i < reader.RecordCount; i++) { var readValues = reader.NextRecord(); - //TODO: Add in switch case for Audatex/CCC/Mitchell for Aluminum switch (readValues[0].ToString())//Case switch on LBR_TYPE to assign correctly. { case "LAB": @@ -501,13 +504,19 @@ namespace BodyshopUploader.Utils.Decoder j.rate_lau = readValues[2]; break; case "LA1": - j.rate_la1 = readValues[2]; + if (_source == SourceSystem.Audatex) + { j.rate_laa = readValues[2]; } + else + { j.rate_la1 = readValues[2]; } break; case "LA2": j.rate_la2 = readValues[2]; break; case "LA3": - j.rate_la3 = readValues[2]; + if (_source == SourceSystem.Mitchell) + { j.rate_laa = readValues[2]; } + else + { j.rate_la3 = readValues[2]; } break; case "LA4": j.rate_la4 = readValues[2]; @@ -896,7 +905,7 @@ namespace BodyshopUploader.Utils.Decoder #endregion - + for (int i = 0; i < reader.RecordCount; i++) { @@ -915,47 +924,45 @@ namespace BodyshopUploader.Utils.Decoder lin.line_desc = readValues[7];//LINE_DESC lin.part_type = readValues[8];//PART_TYPE //lin.part_descj = readValues[9];//PART_DESCJ - //TODO: ADD NEW //lin.glass_flag = readValues[10];//GLASS_FLAG + lin.glass_flag = readValues[10];//GLASS_FLAG lin.oem_partno = readValues[11];//OEM_PARTNO - //TODO: ADD NEW //lin.price_inc = readValues[12];//PRICE_INC - //TODO: ADD NEW //lin.alt_part_i = readValues[13];//ALT_PART_I + lin.price_inc = readValues[12];//PRICE_INC + lin.alt_part_i = readValues[13];//ALT_PART_I lin.tax_part = readValues[14];//TAX_PART lin.db_price = readValues[15];//DB_PRICE lin.act_price = readValues[16];//ACT_PRICE - //TODO: ADD NEW //lin.price_j = readValues[17];//PRICE_J - //TODO: ADD NEW //lin.cert_part = readValues[18];//CERT_PART + lin.price_j = readValues[17];//PRICE_J + lin.cert_part = readValues[18];//CERT_PART lin.part_qty = readValues[19];//PART_QTY - //TODO: ADD NEW //lin.alt_co_id = readValues[20];//ALT_CO_ID + lin.alt_co_id = readValues[20];//ALT_CO_ID lin.alt_partno = readValues[21];//ALT_PARTNO - //TODO: ADD NEW //lin.alt_overrd = readValues[22];//ALT_OVERRD - //TODO: ADD NEW //lin.alt_partm = readValues[23];//ALT_PARTM - //TODO: ADD NEW //lin.prt_dsmk_p = readValues[24];//PRT_DSMK_P - //TODO: ADD NEW //lin.prt_dsmk_m = readValues[25];//PRT_DSMK_M + lin.alt_overrd = readValues[22];//ALT_OVERRD + lin.alt_partm = readValues[23];//ALT_PARTM + lin.prt_dsmk_p = readValues[24];//PRT_DSMK_P + lin.prt_dsmk_m = readValues[25];//PRT_DSMK_M lin.mod_lbr_ty = readValues[26];//MOD_LBR_TY - //TODO: Add logic - //TODO: Create LAA for aluminum - //Mitchell uses LA3 for alum, audatex uses LA1 - //Otherwise put in whatever the standard value is. + lin.db_hrs = readValues[27];//DB_HRS lin.mod_lb_hrs = readValues[28];//MOD_LB_HRS - //TODO: ADD NEW //lin.lbr_inc = readValues[29];//LBR_INC + lin.lbr_inc = readValues[29];//LBR_INC lin.lbr_op = readValues[30];//LBR_OP - //TODO: ADD NEW //lin.lbr_hrs_j = readValues[31];//LBR_HRS_J - //TODO: ADD NEW //lin.lbr_typ_j = readValues[32];//LBR_TYP_J - //TODO: ADD NEW//lin.lbr_op_j = readValues[33];//LBR_OP_J - //TODO: ADD NEW//lin.paint_stg = readValues[34];//PAINT_STG - //TODO: ADD NEW//lin.paint_tone = readValues[35];//PAINT_TONE - //TODO: ADD NEW//lin.lbr_tax = readValues[36];//LBR_TAX + + lin.lbr_hrs_j = readValues[31];//LBR_HRS_J + lin.lbr_typ_j = readValues[32];//LBR_TYP_J + lin.lbr_op_j = readValues[33];//LBR_OP_J + lin.paint_stg = readValues[34];//PAINT_STG + lin.paint_tone = readValues[35];//PAINT_TONE + lin.lbr_tax = readValues[36];//LBR_TAX lin.lbr_amt = readValues[37];//LBR_AMT - //TODO: ADD NEW//lin.misc_amt = readValues[38];//MISC_AMT - //TODO: ADD NEW//lin.misc_sublt = readValues[39];//MISC_SUBLT - //TODO: ADD NEW//lin.misc_tax = readValues[40];//MISC_TAX - //TODO: ADD NEW/lin.bett_type = readValues[41];//BETT_TYPE - //TODO: ADD NEW//lin.bett_pctg = readValues[42];//BETT_PCTG - //TODO: ADD NEW//lin.bett_amt = readValues[43];//BETT_AMT - //TODO: ADD NEW//lin.bett_tax = readValues[44];//BETT_TAX + lin.misc_amt = readValues[38];//MISC_AMT + lin.misc_sublt = readValues[39];//MISC_SUBLT + lin.misc_tax = readValues[40];//MISC_TAX + lin.bett_type = readValues[41];//BETT_TYPE + lin.bett_pctg = readValues[42];//BETT_PCTG + lin.bett_amt = readValues[43];//BETT_AMT + lin.bett_tax = readValues[44];//BETT_TAX allLines.Add(lin); } @@ -1050,7 +1057,7 @@ namespace BodyshopUploader.Utils.Decoder } } - public static void ParseLinFile_OLD(ref dynamic j, string RootFilePath) + public static void ParseLinFile_OLD(ref dynamic j, string RootFilePath, SourceSystem _source = SourceSystem.Mitchell) { if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) { return; }