Exemple #1
0
        public static Boolean ConvertApplicationsToPreviousExperience(ApplicationTDS AMainDS)
        {
            TDBTransaction Transaction  = null;
            bool           SubmissionOK = false;

            DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref Transaction, ref SubmissionOK,
                                                       delegate
            {
                PmPastExperienceTable PastExperienceTable = new PmPastExperienceTable();

                foreach (PmShortTermApplicationRow Row in AMainDS.PmShortTermApplication.Rows)
                {
                    // create the new past experience record
                    PmPastExperienceRow PastExperienceRow = PastExperienceTable.NewRowTyped(true);
                    PastExperienceRow.Key               = Convert.ToInt64(TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_past_experience));
                    PastExperienceRow.PartnerKey        = Row.PartnerKey;
                    PastExperienceRow.PrevLocation      = Row.ConfirmedOptionCode;
                    PastExperienceRow.StartDate         = Row.Arrival;
                    PastExperienceRow.EndDate           = Row.Departure;
                    PastExperienceRow.PrevWorkHere      = true;
                    PastExperienceRow.PrevWork          = true;
                    PastExperienceRow.PastExpComments   = "Created from Event Application";
                    PastExperienceRow.OtherOrganisation = "";
                    PastExperienceRow.PrevRole          = "";
                    PastExperienceTable.Rows.Add(PastExperienceRow);
                }

                PmPastExperienceAccess.SubmitChanges(PastExperienceTable, Transaction);

                SubmissionOK = true;
            });

            return(SubmissionOK);
        }
        /// create a new BankingDetails record and a new PartnerBankingDetails record
        public static PartnerEditTDSPBankingDetailsRow CreateNewBankingRecords(long APartnerKey, PartnerEditTDS AMainDS)
        {
            PartnerEditTDSPBankingDetailsRow BankingDetailsRow = AMainDS.PBankingDetails.NewRowTyped();

            BankingDetailsRow.BankingDetailsKey = Convert.ToInt32(TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_bank_details));
            BankingDetailsRow.BankingType       = MPartnerConstants.BANKINGTYPE_BANKACCOUNT;
            BankingDetailsRow.MainAccount       = true;
            AMainDS.PBankingDetails.Rows.Add(BankingDetailsRow);

            PPartnerBankingDetailsRow PartnerBankingDetailsRow = AMainDS.PPartnerBankingDetails.NewRowTyped();

            PartnerBankingDetailsRow.PartnerKey        = APartnerKey;
            PartnerBankingDetailsRow.BankingDetailsKey = BankingDetailsRow.BankingDetailsKey;
            AMainDS.PPartnerBankingDetails.Rows.Add(PartnerBankingDetailsRow);

            PBankingDetailsUsageRow BankingDetailsUsageRow = AMainDS.PBankingDetailsUsage.NewRowTyped();

            BankingDetailsUsageRow.PartnerKey        = APartnerKey;
            BankingDetailsUsageRow.BankingDetailsKey = BankingDetailsRow.BankingDetailsKey;
            BankingDetailsUsageRow.Type = MPartnerConstants.BANKINGUSAGETYPE_MAIN;
            AMainDS.PBankingDetailsUsage.Rows.Add(BankingDetailsUsageRow);

            return(BankingDetailsRow);
        }
Exemple #3
0
        public void TestDeleteBank()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          BankPartnerRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            BankPartnerRow = TCreateTestPartnerData.CreateNewBankPartner(MainDS);
            result         = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create bank record");

            // check if Bank partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(BankPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // set up details (e.g. bank account) for this Bank so deletion is not allowed
            PBankingDetailsTable BankingDetailsTable = new PBankingDetailsTable();
            PBankingDetailsRow   BankingDetailsRow   = BankingDetailsTable.NewRowTyped();

            BankingDetailsRow.BankKey           = BankPartnerRow.PartnerKey;
            BankingDetailsRow.BankingType       = 0;
            BankingDetailsRow.BankingDetailsKey = Convert.ToInt32(TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_bank_details));
            BankingDetailsTable.Rows.Add(BankingDetailsRow);

            PBankingDetailsAccess.SubmitChanges(BankingDetailsTable, DBAccess.GDBAccessObj.Transaction);

            // now deletion must not be possible since a bank account is set up for the bank
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(BankPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of venue partner
            BankPartnerRow = TCreateTestPartnerData.CreateNewBankPartner(MainDS);
            PartnerKey     = BankPartnerRow.PartnerKey;
            result         = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create bank partner for deletion");

            // check if Venue record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Bank record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Exemple #4
0
        public void TestDeletePerson()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          FamilyPartnerRow;
            PPartnerRow          UnitPartnerRow;
            PPersonRow           PersonRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            // create new family, location and person
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
            PersonRow = TCreateTestPartnerData.CreateNewPerson(MainDS,
                                                               FamilyPartnerRow.PartnerKey,
                                                               MainDS.PLocation[0].LocationKey,
                                                               "Mike",
                                                               "Mr",
                                                               0);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family and person record");

            // check if Family partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(PersonRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // add a commitment for the person which means the person is not allowed to be deleted any longer
            UnitPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS);
            PmStaffDataTable CommitmentTable = new PmStaffDataTable();
            PmStaffDataRow   CommitmentRow   = CommitmentTable.NewRowTyped();

            CommitmentRow.Key               = Convert.ToInt32(TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_staff_data));
            CommitmentRow.PartnerKey        = PersonRow.PartnerKey;
            CommitmentRow.StartOfCommitment = DateTime.Today.Date;
            CommitmentRow.EndOfCommitment   = DateTime.Today.AddDays(90).Date;
            CommitmentRow.OfficeRecruitedBy = UnitPartnerRow.PartnerKey;
            CommitmentRow.HomeOffice        = UnitPartnerRow.PartnerKey;
            CommitmentRow.ReceivingField    = UnitPartnerRow.PartnerKey;
            CommitmentTable.Rows.Add(CommitmentRow);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create unit to be used in commitment");
            PmStaffDataAccess.SubmitChanges(CommitmentTable, DBAccess.GDBAccessObj.Transaction);

            // this should now not be allowed since person record has a commitment linked to it
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(PersonRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of Person partner
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
            PersonRow = TCreateTestPartnerData.CreateNewPerson(MainDS,
                                                               FamilyPartnerRow.PartnerKey,
                                                               MainDS.PLocation[0].LocationKey,
                                                               "Mary",
                                                               "Mrs",
                                                               0);
            PartnerKey = PersonRow.PartnerKey;

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family and person record to be deleted");

            // check if Family record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Family record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
        /// <summary>
        /// generate the invoices from a text file that was generated with Benerator
        /// </summary>
        /// <param name="AInputBeneratorFile"></param>
        /// <param name="AYear">eg. 2013</param>
        /// <param name="ASmallNumber">boolean to keep the size of the demo database down</param>
        public static void GenerateInvoices(string AInputBeneratorFile, int AYear, bool ASmallNumber)
        {
            MaxInvoicesPerYear = (ASmallNumber ? 25 : 200);

            XmlDocument doc = TCsv2Xml.ParseCSVFile2Xml(AInputBeneratorFile, ",");

            XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild;

            AccountsPayableTDS MainDS = new AccountsPayableTDS();

            // get a list of potential suppliers
            string sqlGetSupplierPartnerKeys =
                "SELECT PUB_a_ap_supplier.p_partner_key_n, PUB_a_ap_supplier.a_currency_code_c " +
                "FROM PUB_p_organisation, PUB_a_ap_supplier WHERE PUB_a_ap_supplier.p_partner_key_n = PUB_p_organisation.p_partner_key_n";
            DataTable SupplierKeys = DBAccess.GDBAccessObj.SelectDT(sqlGetSupplierPartnerKeys, "keys", null);

            // get a list of potential expense account codes
            string sqlGetExpenseAccountCodes = "SELECT a_account_code_c FROM PUB_a_account WHERE a_ledger_number_i = " +
                                               FLedgerNumber.ToString() +
                                               " AND a_account_type_c = 'Expense' AND a_account_active_flag_l = true AND a_posting_status_l = true";
            DataTable AccountCodes = DBAccess.GDBAccessObj.SelectDT(sqlGetExpenseAccountCodes, "codes", null);

            while (RecordNode != null)
            {
                int            supplierID   = Convert.ToInt32(TXMLParser.GetAttribute(RecordNode, "Supplier")) % SupplierKeys.Rows.Count;
                Int64          SupplierKey  = Convert.ToInt64(SupplierKeys.Rows[supplierID].ItemArray[0]);
                String         CurrencyCode = Convert.ToString(SupplierKeys.Rows[supplierID].ItemArray[1]);
                AApDocumentRow invoiceRow   = MainDS.AApDocument.NewRowTyped(true);

                invoiceRow.LedgerNumber     = FLedgerNumber;
                invoiceRow.ApDocumentId     = (Int32)TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_ap_document);
                invoiceRow.ApNumber         = invoiceRow.ApDocumentId;
                invoiceRow.DocumentCode     = invoiceRow.ApDocumentId.ToString();
                invoiceRow.PartnerKey       = SupplierKey;
                invoiceRow.Reference        = "something";
                invoiceRow.DateIssued       = Convert.ToDateTime(TXMLParser.GetAttribute(RecordNode, "DateIssued"));
                invoiceRow.DateIssued       = new DateTime(AYear, invoiceRow.DateIssued.Month, invoiceRow.DateIssued.Day);
                invoiceRow.DateEntered      = invoiceRow.DateIssued;
                invoiceRow.TotalAmount      = Convert.ToDecimal(TXMLParser.GetAttribute(RecordNode, "Amount")) / 100.0m;
                invoiceRow.CurrencyCode     = CurrencyCode;
                invoiceRow.ApAccount        = "9100";
                invoiceRow.DocumentStatus   = MFinanceConstants.AP_DOCUMENT_APPROVED;
                invoiceRow.LastDetailNumber = 1;

                // TODO reasonable exchange rate for non base currency. need to check currency of supplier
                invoiceRow.ExchangeRateToBase = 1.0m;

                MainDS.AApDocument.Rows.Add(invoiceRow);

                AApDocumentDetailRow detailRow = MainDS.AApDocumentDetail.NewRowTyped(true);
                detailRow.ApDocumentId   = invoiceRow.ApDocumentId;
                detailRow.DetailNumber   = 1;
                detailRow.LedgerNumber   = invoiceRow.LedgerNumber;
                detailRow.CostCentreCode = (FLedgerNumber * 100).ToString("0000");
                int accountID = Convert.ToInt32(TXMLParser.GetAttribute(RecordNode, "ExpenseAccount")) % AccountCodes.Rows.Count;
                detailRow.AccountCode = AccountCodes.Rows[accountID].ItemArray[0].ToString();
                detailRow.Amount      = invoiceRow.TotalAmount;

                MainDS.AApDocumentDetail.Rows.Add(detailRow);

                if (MainDS.AApDocument.Rows.Count > MaxInvoicesPerYear)
                {
                    break;
                }

                RecordNode = RecordNode.NextSibling;
            }

            AccountsPayableTDSAccess.SubmitChanges(MainDS);
        }