public void CreateAndUpdateThenDeleteSalaryTransactionTest()
        {
            var request  = new FortnoxApiRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var response = SalaryTransactionService.CreateSalaryTransactionAsync(request,
                                                                                 new SalaryTransaction
            {
                EmployeeId = "1593082874",
                SalaryCode = "1321",
                Date       = DateTime.UtcNow,
                Number     = "10",
                Amount     = "200",
            }).GetAwaiter().GetResult();

            Assert.AreEqual("1593082874", response.EmployeeId);

            var salaryTransaction = new SalaryTransaction {
                SalaryRow = response.SalaryRow, Number = "20"
            };
            var updatedSalaryTransaction = SalaryTransactionService.UpdateSalaryTransactionAsync(request, salaryTransaction).GetAwaiter().GetResult();

            Assert.AreEqual("1593082874", updatedSalaryTransaction.EmployeeId);
            Assert.AreEqual("20", updatedSalaryTransaction.Number);

            SalaryTransactionService.DeleteSalaryTransactionAsync(request, response.SalaryRow.ToString()).GetAwaiter().GetResult();
        }
    public async Task Test_SalaryTransaction_CRUD()
    {
        #region Arrange
        var tmpEmployee = await FortnoxClient.EmployeeConnector.CreateAsync(new Employee()
        {
            EmployeeId = TestUtils.RandomString()
        });

        #endregion Arrange

        var connector = FortnoxClient.SalaryTransactionConnector;

        #region CREATE
        var newSalaryTransaction = new SalaryTransaction()
        {
            EmployeeId = tmpEmployee.EmployeeId,
            SalaryCode = "11", //Arbetstid
            Date       = new DateTime(2020, 1, 1),
            Number     = 10,
            TextRow    = "TestSalaryRow"
        };

        var createdSalaryTransaction = await connector.CreateAsync(newSalaryTransaction);

        Assert.AreEqual("TestSalaryRow", createdSalaryTransaction.TextRow);

        #endregion CREATE

        #region UPDATE

        createdSalaryTransaction.TextRow = "UpdatedTestSalaryRow";

        var updatedSalaryTransaction = await connector.UpdateAsync(createdSalaryTransaction);

        Assert.AreEqual("UpdatedTestSalaryRow", updatedSalaryTransaction.TextRow);

        #endregion UPDATE

        #region READ / GET

        var retrievedSalaryTransaction = await connector.GetAsync(createdSalaryTransaction.SalaryRow);

        Assert.AreEqual("UpdatedTestSalaryRow", retrievedSalaryTransaction.TextRow);

        #endregion READ / GET

        #region DELETE

        await connector.DeleteAsync(createdSalaryTransaction.SalaryRow);

        await Assert.ThrowsExceptionAsync <FortnoxApiException>(
            async() => await connector.GetAsync(createdSalaryTransaction.SalaryRow),
            "Entity still exists after Delete!");

        #endregion DELETE

        #region Delete arranged resources
        #endregion Delete arranged resources
    }
예제 #3
0
        public void Test_SalaryTransaction_CRUD()
        {
            #region Arrange
            var tmpEmployee = new EmployeeConnector().Get("TEST_EMP") ?? new EmployeeConnector().Create(new Employee()
            {
                EmployeeId = "TEST_EMP"
            });
            #endregion Arrange

            ISalaryTransactionConnector connector = new SalaryTransactionConnector();

            #region CREATE
            var newSalaryTransaction = new SalaryTransaction()
            {
                EmployeeId = tmpEmployee.EmployeeId,
                SalaryCode = "11", //Arbetstid
                Date       = new DateTime(2020, 1, 1),
                Number     = 10,
                TextRow    = "TestSalaryRow"
            };

            var createdSalaryTransaction = connector.Create(newSalaryTransaction);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestSalaryRow", createdSalaryTransaction.TextRow);

            #endregion CREATE

            #region UPDATE

            createdSalaryTransaction.TextRow = "UpdatedTestSalaryRow";

            var updatedSalaryTransaction = connector.Update(createdSalaryTransaction);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestSalaryRow", updatedSalaryTransaction.TextRow);

            #endregion UPDATE

            #region READ / GET

            var retrievedSalaryTransaction = connector.Get(createdSalaryTransaction.SalaryRow);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestSalaryRow", retrievedSalaryTransaction.TextRow);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdSalaryTransaction.SalaryRow);
            MyAssert.HasNoError(connector);

            retrievedSalaryTransaction = connector.Get(createdSalaryTransaction.SalaryRow);
            Assert.AreEqual(null, retrievedSalaryTransaction, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            #endregion Delete arranged resources
        }
예제 #4
0
        public void CreateSalaryTransaction(SalaryTransaction salaryTransaction)
        {
            if (salaryTransaction == null)
            {
                throw new AggregateException(nameof(SalaryTransaction));
            }

            _context.SalaryTransaction.Add(salaryTransaction);
            this.SaveChanges();
        }
예제 #5
0
파일: EmployeeDAO.cs 프로젝트: Jusharra/RMS
 public void InsertPaidAmountReport(SalaryTransaction aSalaryTransaction, string month, string year)
 {
     try
     {
         DateTime aDateTime = DateTime.Now.Date;
         this.OpenConnection();
         string sqlComm = string.Format(SqlQueries.GetQuery(Query.InsertPaidAmountReport), aSalaryTransaction.EmployeeId,
                                        aSalaryTransaction.WorkingDay, aSalaryTransaction.AttendingDay, aSalaryTransaction.Salary, aSalaryTransaction.DeductedSalary,
                                        aSalaryTransaction.PayableSalary, aSalaryTransaction.ServiceCharge, aSalaryTransaction.FoodAndRoomAllowance, aSalaryTransaction.TotalPayableSalary,
                                        aDateTime, aSalaryTransaction.Remarks, month, year);
         this.ExecuteNonQuery(sqlComm);
     }
     catch (Exception ex)
     {
         //throw new Exception(ex.ToString());
     }
     finally
     {
         this.CloseConnection();
     }
 }
예제 #6
0
        public void CreateShouldCreateASalaryTransaction()
        {
            var employeeId = GetEmployeeId();

            var transaction = new SalaryTransaction
            {
                EmployeeId = employeeId,
                SalaryCode = "115",
                Date       = "2018-10-16"
            };

            var result = _connector.Create(transaction);

            CheckForError(_connector);

            Assert.AreEqual(transaction.EmployeeId, result.EmployeeId);
            Assert.AreEqual(transaction.SalaryCode, result.SalaryCode);
            Assert.AreEqual(transaction.Date, result.Date);
            Assert.IsNotNull(result.SalaryRow);

            _connector.Delete(result.SalaryRow.Value);
        }
예제 #7
0
 private void paidbutton_Click(object sender, EventArgs e)
 {
     if (totalPayableSalarytextBox.Text.Length != 0)
     {
         try
         {
             Employee aEmployee = new Employee();
             aEmployee.EmployeeId     = EmployeeId;
             aEmployee.LastPaidAmount = Convert.ToDouble(totalPayableSalarytextBox.Text);
             EmployeeDAO aDao = new EmployeeDAO();
             string      sr   = aDao.UpdateAmount(aEmployee);
             if (sr == "Update Sucessfully")
             {
                 SalaryTransaction aSalaryTransaction = new SalaryTransaction();
                 aSalaryTransaction.EmployeeId           = EmployeeId;
                 aSalaryTransaction.WorkingDay           = Convert.ToInt32("0" + workingdaystextBox.Text);
                 aSalaryTransaction.AttendingDay         = Convert.ToInt32("0" + attendingtextBox.Text);
                 aSalaryTransaction.Salary               = Convert.ToDouble("0" + salarystructuretextBox.Text);
                 aSalaryTransaction.DeductedSalary       = Convert.ToDouble("0" + deductedsalarytextBox.Text);
                 aSalaryTransaction.PayableSalary        = Convert.ToDouble("0" + payablesalarytextBox.Text);
                 aSalaryTransaction.ServiceCharge        = Convert.ToDouble("0" + servicechargetextBox.Text);
                 aSalaryTransaction.FoodAndRoomAllowance = Convert.ToDouble("0" + foodAndRoomtextBox.Text);
                 aSalaryTransaction.TotalPayableSalary   = Convert.ToDouble("0" + totalPayableSalarytextBox.Text);
                 aSalaryTransaction.Remarks              = remarkstextBox.Text;
                 aDao.InsertPaidAmountReport(aSalaryTransaction, monthcomboBox.Text, yearcomboBox.Text);
                 this.Close();
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Please Check Your Input");
         }
     }
     else
     {
         MessageBox.Show("Please Check Your Input");
     }
 }
예제 #8
0
        public void UpdateShouldUpdateASalaryTransaction()
        {
            //Arrange
            var employeeId = GetEmployeeId();

            var create = new SalaryTransaction
            {
                EmployeeId = employeeId,
                SalaryCode = "115",
                Date       = "2018-10-16"
            };

            var createResult = _connector.Create(create);

            CheckForError(_connector);

            //Act
            var update = new SalaryTransaction
            {
                SalaryRow = createResult.SalaryRow,
                Amount    = 50,
                Date      = "2018-10-16"
            };

            var updateResult = _connector.Update(update);

            CheckForError(_connector);

            //Assert
            Assert.AreEqual(create.EmployeeId, updateResult.EmployeeId);
            Assert.AreEqual(create.SalaryCode, updateResult.SalaryCode);
            Assert.AreEqual(update.Amount, updateResult.Amount);
            Assert.IsNotNull(createResult.SalaryRow);

            //Cleanup
            _connector.Delete(createResult.SalaryRow.Value);
        }
예제 #9
0
 public async Task <SalaryTransaction> CreateAsync(SalaryTransaction salaryTransaction)
 {
     return(await BaseCreate(salaryTransaction));
 }
예제 #10
0
 /// <summary>
 /// Creates a new salaryTransaction
 /// </summary>
 /// <param name="salaryTransaction">The salaryTransaction to create</param>
 /// <returns>The created salaryTransaction</returns>
 public SalaryTransaction Create(SalaryTransaction salaryTransaction)
 {
     return(CreateAsync(salaryTransaction).Result);
 }
예제 #11
0
 /// <summary>
 /// Updates a salaryTransaction
 /// </summary>
 /// <param name="salaryTransaction">The salaryTransaction to update</param>
 /// <returns>The updated salaryTransaction</returns>
 public SalaryTransaction Update(SalaryTransaction salaryTransaction)
 {
     return(UpdateAsync(salaryTransaction).Result);
 }
예제 #12
0
 public async Task <SalaryTransaction> UpdateAsync(SalaryTransaction salaryTransaction)
 {
     return(await BaseUpdate(salaryTransaction, salaryTransaction.SalaryRow.ToString()));
 }
        public static async Task <SalaryTransaction> UpdateSalaryTransactionAsync(FortnoxApiRequest request, SalaryTransaction salaryTransaction)
        {
            var apiRequest =
                new FortnoxApiClientRequest <SingleResource <SalaryTransaction> >(HttpMethod.Put, request.AccessToken, request.ClientSecret,
                                                                                  $"{ApiEndpoints.SalaryTransactions}/{salaryTransaction.SalaryRow}/")
            {
                Data = new SingleResource <SalaryTransaction> {
                    Data = salaryTransaction
                }
            };

            return((await FortnoxAPIClient.CallAsync(apiRequest)).Data);
        }
 public async Task <SalaryTransaction> CreateAsync(SalaryTransaction salaryTransaction)
 {
     return(await BaseCreate(salaryTransaction).ConfigureAwait(false));
 }