Protractor tests for payroll.
diff --git a/Pages/Accounting b/Pages/Accounting
index 325774f..0d2d0c8 100644
--- a/Pages/Accounting
+++ b/Pages/Accounting
@@ -189,6 +189,14 @@
         $$("fims-layout-card-over md-nav-list a").get(1).click();
         browser.sleep(500);
     },
+    clickThirdJournalEntry: function(){
+        $$("fims-layout-card-over md-nav-list a").get(2).click();
+        browser.sleep(500);
+    },
+    clickJournalEntry: function(number){
+        $$("fims-layout-card-over md-nav-list a").get(number-1).click();
+        browser.sleep(500);
+    },
     verifyThirdJournalEntry: function(transactionType, transactionAmount){
         expect($$("fims-layout-card-over .mat-list-item .mat-list-text p").get(4).getText().then(function(text){
             return text === transactionType;
diff --git a/Pages/Customers.js b/Pages/Customers.js
index 1f89a6f..37ce250 100644
--- a/Pages/Customers.js
+++ b/Pages/Customers.js
@@ -225,6 +225,7 @@
     },
 
     verifyDepositAccountBalanceIs: function (expectedBalance) {
+        browser.sleep(1000);
         $$("fims-layout-card-over .mat-list-item .mat-list-text").filter(function (elem, index) {
             return elem.$("h3").getText().then(function (text) {
                 return text === "Balance";
diff --git a/Pages/Payroll.js b/Pages/Payroll.js
index 5509a4a..e0f257a 100644
--- a/Pages/Payroll.js
+++ b/Pages/Payroll.js
@@ -15,6 +15,7 @@
 var salaryInput = $$("fims-number-input[controlname='salary'] input");
 
 var primaryButtons = $$(".mat-raised-button.mat-primary");
+var buttons = $$(".mat-button");
 var removeAllocationButtons = $$("fims-customer-payroll-form .mat-button");
 var removePaymentButtons = $$("fims-payroll-form .mat-button");
 
@@ -67,11 +68,9 @@
        checkboxProportional.get(allocationNumber-1).click();
     },
     selectAllocationAccountForAllocation: function(accountIdentifier, allocationNumber){
-        browser.executeScript("arguments[0].scrollIntoView();", allocationAccountSelect.get(allocationNumber-1).getWebElement());
-        browser.wait(EC.elementToBeClickable(allocationAccountSelect).get(allocationNumber-1), 3000);
+        browser.wait(EC.elementToBeClickable(allocationAccountSelect.get(allocationNumber-1)), 3000);
         allocationAccountSelect.get(allocationNumber-1).click();
         browser.wait(EC.visibilityOf($(".mat-option")), 5000);
-        //browser.executeScript("arguments[0].scrollIntoView();", element(by.cssContainingText('.mat-option', accountIdentifier)).getWebElement());
         element(by.cssContainingText('.mat-option', accountIdentifier)).click();
     },
     selectMainAccount: function(accountIdentifier){
diff --git a/Specs/payrolls.js b/Specs/payrolls.js
index f4a4eff..e8ccebf 100644
--- a/Specs/payrolls.js
+++ b/Specs/payrolls.js
@@ -235,20 +235,130 @@
         Accounting.goToJournalEntries();
         Accounting.enterTextIntoSearchAccountInputField(customerAccount + ".9100.00001");
         Accounting.clickSearchButton();
-        browser.pause();
-        Accounting.verifyFirstJournalEntry("Payroll/Salary Payment", "Amount: 5,000.00");
+        Accounting.verifySecondJournalEntry("Payroll/Salary Payment", "Amount: 5,000.00");
+        Accounting.clickSecondJournalEntry();
         Accounting.verifyClerkForJournalEntryIs(employeeIdentifier);
         Accounting.verifyNoteForJournalEntryIs("Payroll Distribution");
+        Accounting.verifyAccountHasBeenDebitedWithAmountInRow("1101", "5,000.00", 1);
+        Accounting.verifyAccountHasBeenCreditedWithAmountInRow(customerAccount + ".9100.00001", "5,000.00", 2);
         //customer has received payment
         Customers.goToManageCustomersViaSidePanel();
         Common.clickLinkShowForRowWithId(customerAccount);
         Customers.clickManageDepositAccountsForMember(customerAccount);
         Common.clickLinkShowForFirstRowInTable();
-        Customers.verifyDepositAccountBalanceIs("5,100");
-        browser.pause();
+        Customers.verifyDepositAccountBalanceIs("5,100.00");
     });
-    //allocation - not proportional
-    //allocation - proportional
+    it('should update payroll allocation for member - one additional allocation (not proportional) ', function () {
+        Common.clickBackButtonInTitleBar();
+        Common.clickBackButtonInTitleBar();
+        Customers.clickPayrollForMember(customerAccount);
+        Payroll.clickButtonEditPayrollDistribution(customerAccount);
+        Payroll.clickButtonAddAllocations();
+        Payroll.selectAllocationAccountForAllocation(customerAccount + ".9100.00001", 1);
+        Payroll.enterTextIntoAmountInputFieldForAllocation("1200", 1);
+        //not possible, error
+        Payroll.verifyButtonUpdateAllocationsDisabled();
+        Payroll.selectAllocationAccountForAllocation(customerAccount + ".9100.00002", 1);
+        Payroll.verifyButtonUpdateAllocationsEnabled();
+        Payroll.clickButtonUpdateAllocations("Payroll is going to be saved");
+    });
+    it('should pay salary - main account & allocation (not proportional)', function () {
+        Accounting.goToAccountingViaSidePanel();
+        Accounting.goToPayrolls();
+        Payroll.clickButtonCreatePayroll();
+        Payroll.enterTextIntoFromAccountInputFieldForPayment("1101");
+        Payroll.enterTextIntoMemberInputFieldForPayment(customerAccount, 1);
+        Payroll.enterTextIntoEmployerInputFieldForPayment("SweetWater Brewing Company", 1);
+        Payroll.enterTextIntoSalaryInputFieldForPayment("2000", 1);
+        Payroll.clickCreatePaymentsButton();
+        Common.verifyMessagePopupIsDisplayed("Payroll is going to be created");
+        //verify details
+        Payroll.verifyCreatedByForPayrollInRow(employeeIdentifier, 1);
+        Payroll.verifyAccountNumberForPayrollInRow("1101", 1);
+        //created by
+        Common.clickLinkShowForFirstRowInTable();
+        //verify details
+        Payroll.verifyMemberIDForPaymentInRow(customerAccount, 1);
+        Payroll.verifyEmployerForPaymentInRow("SweetWater Brewing Company", 1);
+        Payroll.verifySalaryForPaymentInRow("2000", 1);
+    });
+    it('verify transaction has been booked as expected', function () {
+        //journal entry
+        Accounting.goToAccountingViaSidePanel();
+        Accounting.goToJournalEntries();
+        Accounting.enterTextIntoSearchAccountInputField(customerAccount + ".9100.00002");
+        Accounting.clickSearchButton();
+        Accounting.verifySecondJournalEntry("Payroll/Salary Payment", "Amount: 2,000.00");
+        Accounting.clickSecondJournalEntry();
+        Accounting.verifyClerkForJournalEntryIs(employeeIdentifier);
+        Accounting.verifyNoteForJournalEntryIs("Payroll Distribution");
+        Accounting.verifyAccountHasBeenDebitedWithAmountInRow("1101", "2,000.00", 1);
+        Accounting.verifyAccountHasBeenCreditedWithAmountInRow(customerAccount + ".9100.00002", "1,200.00", 2);
+        Accounting.verifyAccountHasBeenCreditedWithAmountInRow(customerAccount + ".9100.00001", "800.00", 3);
+    });
+    it('should update payroll allocation for member to proportional', function () {
+        Customers.goToManageCustomersViaSidePanel();
+        Common.clickSearchButtonToMakeSearchInputFieldAppear();
+        Common.enterTextInSearchInputFieldAndApplySearch(customerAccount);
+        Common.verifyFirstRowOfSearchResultHasTextAsId(customerAccount);
+        Common.clickLinkShowForRowWithId(customerAccount);
+        Customers.clickPayrollForMember(customerAccount);
+        Payroll.clickButtonEditPayrollDistribution(customerAccount);
+        Payroll.checkCheckboxProportionalForAllocation(1);
+        Payroll.enterTextIntoAmountInputFieldForAllocation("40.9", 1);
+        Payroll.verifyButtonUpdateAllocationsEnabled();
+        Payroll.clickButtonUpdateAllocations("Payroll is going to be saved");
+    });
+    it('should pay salary - main account & allocation (proportional)', function () {
+        Accounting.goToAccountingViaSidePanel();
+        Accounting.goToPayrolls();
+        Payroll.clickButtonCreatePayroll();
+        Payroll.enterTextIntoFromAccountInputFieldForPayment("1101");
+        Payroll.enterTextIntoMemberInputFieldForPayment(customerAccount, 1);
+        Payroll.enterTextIntoEmployerInputFieldForPayment("SweetWater Brewing Company", 1);
+        Payroll.enterTextIntoSalaryInputFieldForPayment("1000", 1);
+        Payroll.clickButtonAddPayment();
+        Payroll.enterTextIntoMemberInputFieldForPayment(customerAccount, 2);
+        Payroll.enterTextIntoEmployerInputFieldForPayment("Ballast Point", 2);
+        Payroll.enterTextIntoSalaryInputFieldForPayment("450", 2);
+        Payroll.clickCreatePaymentsButton();
+        Common.verifyMessagePopupIsDisplayed("Payroll is going to be created");
+        //verify details
+        Payroll.verifyCreatedByForPayrollInRow(employeeIdentifier, 1);
+        Payroll.verifyAccountNumberForPayrollInRow("1101", 1);
+        //created by
+        Common.clickLinkShowForFirstRowInTable();
+        //verify details
+        Payroll.verifyMemberIDForPaymentInRow(customerAccount, 1);
+        Payroll.verifyEmployerForPaymentInRow("SweetWater Brewing Company", 1);
+        Payroll.verifySalaryForPaymentInRow("1000", 1);
+        Payroll.verifyMemberIDForPaymentInRow(customerAccount, 2);
+        Payroll.verifyEmployerForPaymentInRow("Ballast Point", 2);
+        Payroll.verifySalaryForPaymentInRow("450", 2);
+    });
+    it('verify transaction has been booked as expected', function () {
+        //journal entry
+        Accounting.goToAccountingViaSidePanel();
+        Accounting.goToJournalEntries();
+        Accounting.enterTextIntoSearchAccountInputField(customerAccount + ".9100.00002");
+        Accounting.clickSearchButton();
+        Accounting.clickJournalEntry(3);
+        Accounting.verifyThirdJournalEntry("Payroll/Salary Payment", "Amount: 1,000.00");
+        Accounting.verifyClerkForJournalEntryIs(employeeIdentifier);
+        Accounting.verifyNoteForJournalEntryIs("Payroll Distribution");
+        Accounting.verifyAccountHasBeenDebitedWithAmountInRow("1101",  "1,000.00", 1);
+        browser.pause();
+        Accounting.verifyAccountHasBeenCreditedWithAmountInRow(customerAccount + ".9100.00001", "591.00", 2);
+        Accounting.verifyAccountHasBeenCreditedWithAmountInRow(customerAccount + ".9100.00001", "409.00", 3);
+        Accounting.clickJournalEntry(4);
+        Accounting.verifyFourthJournalEntry("Payroll/Salary Payment", "Amount: 450.00");
+        Accounting.verifyClerkForJournalEntryIs(employeeIdentifier);
+        Accounting.verifyNoteForJournalEntryIs("Payroll Distribution");
+        Accounting.verifyAccountHasBeenDebitedWithAmountInRow("1101",  "450.00", 1);
+        Accounting.verifyAccountHasBeenCreditedWithAmountInRow(customerAccount + ".9100.00001", "265.95", 2);
+        Accounting.verifyAccountHasBeenCreditedWithAmountInRow(customerAccount + ".9100.00001", "184.05", 3);
+
+    });
     //allocation - three accounts, proportional
     //allocations - three accounts, mixed
     //same deposit account selected twice, not possible