public string ExportCompensation(bool updateAsExported) { //Export this driver compensation to file StringBuilder export = null; try { //Setup export = new StringBuilder(); PayPeriod payPeriod = FinanceGateway.GetPayPeriod(this.mEndDate); //Export driver compensations and admin charges foreach (DriverCompDataset.DriverCompTableRow comp in this.mCompensation.DriverCompTable.Rows) { if (comp.Select && comp.TotalAmount > 0) { //Export driver compensation export.AppendLine(formatDriverRecord(payPeriod, comp)); //Export Admin fees if applicable DriverCompDataset.DriverRouteTableRow[] routes = (DriverCompDataset.DriverRouteTableRow[]) this.mCompensation.DriverRouteTable.Select("AgentNumber=" + this.mAgentNumber + " AND Operator='" + comp.Operator + "'"); decimal adminFee = 0.0M; for (int i = 0; i < routes.Length; i++) { adminFee += routes[i].AdminCharge; } if (adminFee != 0) { export.AppendLine(formatAdminRecord(payPeriod, comp, adminFee)); } if (updateAsExported) { //Update all routes as exported for (int i = 0; i < routes.Length; i++) { routes[i].Exported = DateTime.Today; routes[i].LastUpdated = DateTime.Now; routes[i].UserID = Environment.UserName; FinanceGateway.UpdateDriverRoute(routes[i]); } } } } //Refresh routes if they were updated (otherwise, don't change export selections) if (updateAsExported) { ViewCompensation(); } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } return(export.ToString()); }
public PayPeriod GetPayPeriod(DateTime date) { PayPeriod pp = new PayPeriod(); try { DataSet ds = new DriverCompGateway().ReadPayPeriod(date); if (ds.Tables["PayPeriodTable"] != null && ds.Tables["PayPeriodTable"].Rows.Count > 0) { pp.Month = ds.Tables["PayPeriodTable"].Rows[0]["Month"].ToString().PadLeft(2, '0'); pp.Year = ds.Tables["PayPeriodTable"].Rows[0]["Year"].ToString(); } } catch (Exception ex) { throw new FaultException <DriverRatingFault>(new DriverRatingFault(ex.Message), "Service Error"); } return(pp); }
public static PayPeriod GetPayPeriod(DateTime effectiveDate) { // PayPeriod payPeriod = new PayPeriod(); DriverCompServiceClient client = null; try { client = new DriverCompServiceClient(); payPeriod = client.GetPayPeriod(effectiveDate); client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <DriverCompensationFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(payPeriod); }
public static PayPeriod GetPayPeriod(DateTime date) { //Get the Argix pay period for the specified date PayPeriod pp = new PayPeriod(); try { DataSet ds = Mediator.FillDataset(USP_PAYPERIOD, TBL_PAYPERIOD, new object[] { date }); if (ds.Tables[TBL_PAYPERIOD].Rows.Count > 0) { pp.Month = ds.Tables[TBL_PAYPERIOD].Rows[0]["Month"].ToString().PadLeft(2, '0'); pp.Year = ds.Tables[TBL_PAYPERIOD].Rows[0]["Year"].ToString(); } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } return(pp); }
public PayPeriod GetPayPeriod(DateTime date) { //Get the Argix pay period for the specified date PayPeriod pp = new PayPeriod(); try { DataSet ds = new DataService().FillDataset(this.mConnectionID, USP_PAYPERIOD, TBL_PAYPERIOD, new object[] { date }); if (ds.Tables[TBL_PAYPERIOD].Rows.Count > 0) { pp.Month = ds.Tables[TBL_PAYPERIOD].Rows[0]["Month"].ToString().PadLeft(2, '0'); pp.Year = ds.Tables[TBL_PAYPERIOD].Rows[0]["Year"].ToString(); } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Unexpected error while reading Argix pay periods.", ex); } return(pp); }
private string formatAdminRecord(PayPeriod payPeriod, DriverCompDS.DriverCompTableRow comp, decimal adminFee) { // #region Admin record //All fields fixed 12 position and left justified //022 13418 09/13/08 AD091308 Ad 012 08 -10.00 18516000 N //------------============------------============------------============------------============------------============------------============------------ //| | | | | | | | | | | | | //a b c d e f g h i j k l m //a) Company Code [12]; always 022 //b) VendorFinanceID [12]; //c) Date [12, MM/dd/yyyy]; //d) Invoice# [12, AD + Date(MMddyy)]; //e) Desc1 [12]; always blank //f) Desc2 [12]; always blank //g) Desc3 [12]; always blank //h) Desc4 [12]; always blank //i) Pay period month [12, mm]; //j) Pay period year [12, yy]; //k) Admin amount [12]; //l) General LG# [12]; //m) TaxID [12]; always N #endregion string s = ""; try { s = "022".PadRight(12, ' ') + comp.FinanceVendorID.PadRight(12, ' ').Substring(0, 12) + this.EndDate.ToString("MM/dd/yy").PadRight(12, ' ').Substring(0, 12) + "AD" + this.EndDate.ToString("MMddyy").PadRight(10, ' ').Substring(0, 10) + "".PadRight(12, ' ').Substring(0, 12) + "".PadRight(12, ' ').Substring(0, 12) + "".PadRight(12, ' ').Substring(0, 12) + "".PadRight(12, ' ').Substring(0, 12) + payPeriod.Month.PadLeft(3, '0').PadRight(12, ' ').Substring(0, 12) + payPeriod.Year.Substring(2, 2).PadRight(12, ' ').Substring(0, 12) + adminFee.ToString("#0.00").PadRight(12, ' ').Substring(0, 12) + this.mTerminalConfig.AdminGLNumber.PadRight(12, ' ').Substring(0, 12) + "N".PadRight(12, ' ').Substring(0, 12); } catch (Exception ex) { throw new ApplicationException("Unexpected error while formatting trailer export string.", ex); } return(s); }
private string formatDriverRecord(PayPeriod payPeriod, DriverCompDataset.DriverCompTableRow comp) { // #region Driver record //All fields fixed 12 position and left justified //022 13418 09/13/08 WE091308 Mi 484 012 08 1424.23 18505000 N //------------============------------============------------============------------============------------============------------============------------ //| | | | | | | | | | | | | //a b c d e f g h i j k l m //a) Company Code [12]; always 022 //b) VendorFinanceID [12]; //c) Date [12, MM/dd/yyyy]; //d) Invoice# [12, WE + Date(MMddyy)]; //e) Desc1 [12]; always blank //f) Desc2 [12]; always blank //g) Desc3 [12]; always blank //h) Desc4 [12]; always blank //i) Pay period month [12, MM]; //j) Pay period year [12, yy]; //k) Total amount [12]; //l) General LG# [12]; //m) TaxID [12]; always N #endregion string s = ""; try { s = "022".PadRight(12, ' ') + comp.FinanceVendorID.PadRight(12, ' ').Substring(0, 12) + this.EndDate.ToString("MM/dd/yy").PadRight(12, ' ').Substring(0, 12) + "WE" + this.EndDate.ToString("MMddyy").PadRight(10, ' ').Substring(0, 10) + "".PadRight(12, ' ').Substring(0, 12) + "".PadRight(12, ' ').Substring(0, 12) + "".PadRight(12, ' ').Substring(0, 12) + "".PadRight(12, ' ').Substring(0, 12) + payPeriod.Month.PadLeft(3, '0').PadRight(12, ' ').Substring(0, 12) + payPeriod.Year.Substring(2, 2).PadRight(12, ' ').Substring(0, 12) + comp.TotalAmount.ToString("#0.00").PadRight(12, ' ').Substring(0, 12) + this.mTerminalConfig.GLNumber.PadRight(12, ' ').Substring(0, 12) + "N".PadRight(12, ' ').Substring(0, 12); } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } return(s); }