ARMS Uploader

This commit is contained in:
Patrick Fic
2022-02-07 13:31:51 -08:00
parent 1221f35162
commit c936d354b2
16 changed files with 440 additions and 175 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
@@ -30,6 +31,7 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!, $start: timestamptz!, $end: timestampt
actual_completion
actual_delivery
date_exported
actual_in
ins_co_nm
ins_addr1
ins_addr2
@@ -163,9 +165,9 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!, $start: timestamptz!, $end: timestampt
logger.Debug(RoNumber);
RepairOrders.Add(new ARMSRoDataModel()
{
ShopShortName = int.Parse(data.bodyshops_by_pk.entegral_id?.Value),
ShopShortName = data.bodyshops_by_pk.entegral_id?.Value,
RO = int.Parse(RoNumber),
TransType = "Z", //TODO*** Finish this status mapping.
TransType = job.actual_completion?.Value == null ? "Z" : "C", //TODO*** Finish this status mapping.
ShopLongName = data.bodyshops_by_pk.shopname?.Value,
EstimatorID = job.est_ct_ln,
EstimatorName = $"{job.est_ct_fn} {job.est_ct_ln}",
@@ -175,8 +177,10 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!, $start: timestamptz!, $end: timestampt
CustomerStreet = job.ownr_addr1?.Value,
CustomerCity = job.ownr_city?.Value,
CustomerState = job.ownr_st?.Value,
CustomerZip = job.ownr_ph1?.Value,
RetWhslCustomer = "R",
CustomerZip = job.ownr_zip?.Value,
CustomerPhone1 = job.ownr_ph1?.Value,
CustomerPhone2 = job.ownr_ph2?.Value,
//RetWhslCustomer = "R",
Year = int.Parse(job.v_model_yr?.Value ?? 0), //TODO STRIP TO 2 NUMBERS
Make = job.v_make_desc?.Value,
Model = job.v_model_desc?.Value,
@@ -191,8 +195,11 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!, $start: timestamptz!, $end: timestampt
ClaimType = "N/A",
Claim = job.clm_no?.Value,
DateOpened = job.date_open?.Value,// ? job.date_open : null,
EstComplete = job.date_open?.Value,
//DateofLoss = job.loss_date?.Value,// ? job.loss_date : null,
PromiseDate = job.scheduled_completion,
CarComplete = job.actual_completion,
CarinShop = job.actual_in,
CustPickup = job.actual_delivery,
DateClosed = job.date_invoiced,
BodyRate = job.rate_lab,
@@ -201,33 +208,35 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!, $start: timestamptz!, $end: timestampt
StructuralRate = job.rate_las,
PMRate = job.rate_mapa,
BMRate = job.rate_mash,
RevisedTotalsBodyHours = job.job_totals?.rates?.lab?.hours?.Value,
RevisedTotalsRefinishHours = job.job_totals?.rates?.lar?.hours?.Value,
RevisedTotalsMechanicalHours = job.job_totals?.rates?.lam?.hours?.Value,
RevisedTotalsStructuralHours = job.job_totals?.rates?.las?.hours?.Value,
RevisedTotalsPartsTotal = job.job_totals?.pars?.parts?.total?.amount?.Value/100,
RevisedTotalsSubletTotal = job.job_totals?.pars?.sublets?.total?.amount?.Value / 100,
RevisedTotalsBodyLaborTotal = job.job_totals?.rates?.lab?.total?.amount?.Value/100,
RevisedTotalsRefinishLaborTotal = job.job_totals?.rates?.lar?.total?.amount?.Value / 100,
RevisedTotalsMechanicalLaborTotal = job.job_totals?.rates?.lam?.total?.amount?.Value / 100,
RevisedTotalsStructuralLaborTotal = job.job_totals?.rates?.las?.total?.amount?.Value / 100,
RevisedTotalsPMTotal = job.job_totals?.rates?.mapa?.total?.amount?.Value / 100,
RevisedTotalsBMTotal = job.job_totals?.rates?.mash?.total?.amount?.Value / 100,
RevisedTotalsSalesTaxTotal = (job.job_totals?.totals?.federal_tax?.amount?.Value + job.job_totals?.totals?.state_tax?.amount?.Value) /100,
RevisedTotalsGrossTotal = job.job_totals?.totals?.total_repairs?.amount?.Value /100,
RevisedTotalsDeductibleTotal = job.ded_amt?.Value,
// RevisedTotalsDepreciationTotal = job.job_totals?.rates?.lab?.hours?.Value,
RevisedTotalsBodyHours = (Decimal?)job.job_totals?.rates?.lab?.hours?.Value,
RevisedTotalsRefinishHours = (Decimal?)job.job_totals?.rates?.lar?.hours?.Value,
RevisedTotalsMechanicalHours = (Decimal?)job.job_totals?.rates?.lam?.hours?.Value,
RevisedTotalsStructuralHours = (Decimal?)job.job_totals?.rates?.las?.hours?.Value,
RevisedTotalsPartsTotal = ((Decimal?)job.job_totals?.parts?.parts?.total?.amount?.Value) / 100,
RevisedTotalsSubletTotal = ((Decimal?)job.job_totals?.parts?.sublets?.total?.amount?.Value) / 100,
RevisedTotalsBodyLaborTotal = ((Decimal?)job.job_totals?.rates?.lab?.total?.amount?.Value) / 100,
RevisedTotalsRefinishLaborTotal = ((Decimal?)job.job_totals?.rates?.lar?.total?.amount?.Value) / 100,
RevisedTotalsMechanicalLaborTotal = ((Decimal?)job.job_totals?.rates?.lam?.total?.amount?.Value) / 100,
RevisedTotalsStructuralLaborTotal = ((Decimal?)job.job_totals?.rates?.las?.total?.amount?.Value) / 100,
RevisedTotalsPMTotal = ((Decimal?)job.job_totals?.rates?.mapa?.total?.amount?.Value) / 100,
RevisedTotalsBMTotal = ((Decimal?)job.job_totals?.rates?.mash?.total?.amount?.Value) / 100,
RevisedTotalsSalesTaxTotal = ((Decimal?)(job.job_totals?.totals?.federal_tax?.amount?.Value + job.job_totals?.totals?.state_tax?.amount?.Value)) / 100,
RevisedTotalsGrossTotal = ((Decimal?)job.job_totals?.totals?.total_repairs?.amount?.Value) / 100,
RevisedTotalsDeductibleTotal = (Decimal?)job.ded_amt?.Value,
// RevisedTotalsDepreciationTotal = job.job_totals?.rates?.lab?.hours?.Value,
TotalLossYN = job.tlos_ind,
BodyTechName = job.employee_body_rel?.Value == null ? "" : $"{job.employee_body_rel?.first_name?.Value} {job.employee_body_rel?.last_name?.Value}",
Vehiclecolor = job.v_color?.Value,
PaintTechID = job.employee_refinish_rel?.Value == null ? "" : job.employee_refinish_rel?.employee_number?.Value,
PaintTechName = job.employee_refinish_rel?.Value == null ? "" : $"{job.employee_refinish_rel?.first_name?.Value} {job.employee_refinish_rel?.last_name?.Value}",
ProductionStageCode = "33" //TODO ADD THE REST OF THE CODE
ProductionStageCode = (job.actual_delivery?.Value != null || job.date_invoiced != null) ? "8D" : "33",
Vehiclescheduledindate = job.scheduled_in?.Value
});
}
Directory.CreateDirectory(Properties.Settings.Default.ArmsExportPath);
engine.WriteFile("Output.Txt", RepairOrders);
engine.WriteFile($"{Properties.Settings.Default.ArmsExportPath}\\{DateTime.Now.ToString("MMdd")}{data.bodyshops_by_pk.entegral_id?.Value}.txt", RepairOrders);
}
catch (Exception ex)
{