/// <summary> /// called from APMain when adding new supplier; /// initialises a new dataset /// </summary> /// <param name="APartnerKey"></param> public void CreateNewSupplier(Int64 APartnerKey) { // TODO: let the server do that? what about messages on failure? // check for existing supplier record if (FUIConnector.CanFindSupplier(APartnerKey)) { MessageBox.Show(Catalog.GetString("There is already a supplier record for this partner!")); EditSupplier(APartnerKey); return; } FPetraUtilsObject.SetChangedFlag(); AApSupplierRow row = FMainDS.AApSupplier.NewRowTyped(); row.PartnerKey = APartnerKey; row.CurrencyCode = FLedgerRow.BaseCurrency; row.DefaultApAccount = "9100"; // If the user doesn't want this, she should have a good reason.. row.DefaultCreditTerms = 28; // 28 credit might not be universal, but it's better than 0. row.PreferredScreenDisplay = 36; // show my invoices for 36 months FMainDS.AApSupplier.Rows.Add(row); ShowData(row); // Make PartnerKey Readonly again - // ShowData makes it writeable because it is the Primary Key of the Table and we are adding a record! txtPartnerKey.ReadOnly = true; }
/// create new AP info public static AApDocumentRow CreateNewAPInfo(Int64 APartnerKey, ref AccountsPayableTDS AMainDS) { ALedgerTable LedgerTable = ALedgerAccess.LoadAll(DBAccess.GDBAccessObj.Transaction); AMainDS = TAPTransactionWebConnector.CreateAApDocument(((ALedgerRow)LedgerTable.Rows[0]).LedgerNumber, APartnerKey, true); // Create a new RecurringGiftBatch AApDocumentRow Document = AMainDS.AApDocument[0]; Document.DocumentCode = "TEST"; Document.CreditNoteFlag = false; Document.DateIssued = DateTime.Today; Document.DateEntered = DateTime.Today; Document.TotalAmount = 0; Document.CurrencyCode = "EUR"; Document.LastDetailNumber = 0; // Create a new RecurringGift record AApSupplierRow ApSupplierRow = AMainDS.AApSupplier.NewRowTyped(); ApSupplierRow.PartnerKey = APartnerKey; ApSupplierRow.CurrencyCode = "EUR"; AMainDS.AApSupplier.Rows.Add(ApSupplierRow); return(Document); }
/// create new AP info public static AApDocumentRow CreateNewAPInfo(Int64 APartnerKey, ref AccountsPayableTDS AMainDS, TDataBase ADataBase = null) { TDataBase db = DBAccess.Connect("CreateNewAPInfo", ADataBase); TDBTransaction Transaction = db.BeginTransaction(IsolationLevel.Serializable); ALedgerTable LedgerTable = ALedgerAccess.LoadAll(Transaction); AMainDS = TAPTransactionWebConnector.CreateAApDocument(((ALedgerRow)LedgerTable.Rows[0]).LedgerNumber, APartnerKey, true, db); // Create a new RecurringGiftBatch AApDocumentRow Document = AMainDS.AApDocument[0]; Document.DocumentCode = "TEST"; Document.CreditNoteFlag = false; Document.DateIssued = DateTime.Today; Document.DateEntered = DateTime.Today; Document.TotalAmount = 0; Document.CurrencyCode = "EUR"; Document.LastDetailNumber = 0; // Create a new RecurringGift record AApSupplierRow ApSupplierRow = AMainDS.AApSupplier.NewRowTyped(); ApSupplierRow.PartnerKey = APartnerKey; ApSupplierRow.CurrencyCode = "EUR"; AMainDS.AApSupplier.Rows.Add(ApSupplierRow); Transaction.Commit(); return(Document); }
private void FocusedRowChanged(System.Object sender, SourceGrid.RowEventArgs e) { DataRowView[] SelectedGridRow = grdPayments.SelectedDataRowsAsDataRowView; if (SelectedGridRow.Length >= 1) { FSelectedPaymentRow = (AccountsPayableTDSAApPaymentRow)SelectedGridRow[0].Row; if (!FSelectedPaymentRow.IsSupplierKeyNull()) { AApSupplierRow supplier = TFrmAPMain.GetSupplier(FMainDS.AApSupplier, FSelectedPaymentRow.SupplierKey); txtCurrency.Text = supplier.CurrencyCode; if (FCurrencyTable != null) { ACurrencyRow row = (ACurrencyRow)FCurrencyTable.Rows.Find(supplier.CurrencyCode); txtTotalAmount.CurrencyCode = row.CurrencyCode; txtAmountToPay.CurrencyCode = row.CurrencyCode; } /* * decimal CurrentRate = TExchangeRateCache.GetDailyExchangeRate(supplier.CurrencyCode, * FLedgerRow.BaseCurrency, * DateTime.Today, * false); */ txtExchangeRate.NumberValueDecimal = FSelectedPaymentRow.ExchangeRateToBase; cmbPaymentType.SetSelectedString(supplier.PaymentType); if (txtCurrency.Text == FLedgerRow.BaseCurrency) { txtExchangeRate.Enabled = false; btnLookupExchangeRate.Enabled = false; } else { txtExchangeRate.Enabled = true; btnLookupExchangeRate.Enabled = true; } } cmbBankAccount.SetSelectedString(FSelectedPaymentRow.BankAccount, -1); FMainDS.AApDocumentPayment.DefaultView.RowFilter = AccountsPayableTDSAApDocumentPaymentTable.GetPaymentNumberDBName() + " = " + FSelectedPaymentRow.PaymentNumber.ToString(); grdDocuments.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.AApDocumentPayment.DefaultView); grdDocuments.Refresh(); grdDocuments.Selection.SelectRow(1, true); FocusedRowChangedDetails(null, null); } }
private void ShowDataManual(AApSupplierRow ARow) { // // Correct these bad assignments made by the auto-generated code: // if (ARow.SupplierType == "") { cmbSupplierType.SetSelectedString("NORMAL"); } if (ARow.PaymentType == "") { cmbDefaultPaymentType.SetSelectedString("Cheque"); } }
/// <summary> /// Load the supplier and all the transactions (invoices and payments) that relate to it. /// </summary> /// <param name="ALedgerNumber"></param> /// <param name="APartnerKey"></param> public void LoadSupplier(Int32 ALedgerNumber, Int64 APartnerKey) { this.Cursor = Cursors.WaitCursor; FLedgerNumber = ALedgerNumber; FPartnerKey = APartnerKey; FMainDS = TRemote.MFinance.AP.WebConnectors.LoadAApSupplier(ALedgerNumber, APartnerKey); FSupplierRow = FMainDS.AApSupplier[0]; txtFilteredBalance.CurrencyCode = FSupplierRow.CurrencyCode; txtSupplierBalance.CurrencyCode = FSupplierRow.CurrencyCode; txtTaggedBalance.CurrencyCode = FSupplierRow.CurrencyCode; lblExcludedItems.Text = string.Format(lblExcludedItems.Text, FSupplierRow.CurrencyCode); // Get our AP ledger settings and enable/disable the corresponding search option on the filter panel TFrmLedgerSettingsDialog settings = new TFrmLedgerSettingsDialog(this, ALedgerNumber); FRequireApprovalBeforePosting = settings.APRequiresApprovalBeforePosting; Control rbtForApproval = FFilterAndFindObject.FilterPanelControls.FindControlByName("rbtForApproval"); rbtForApproval.Enabled = FRequireApprovalBeforePosting; // // Transactions older than DateTime AgedOlderThan = DateTime.Now; if (!FSupplierRow.IsPreferredScreenDisplayNull()) { AgedOlderThan = AgedOlderThan.AddMonths(0 - FSupplierRow.PreferredScreenDisplay); } FAgedOlderThan = AgedOlderThan.ToString("u"); txtSupplierName.Text = FMainDS.PPartner[0].PartnerShortName; txtSupplierCurrency.Text = FSupplierRow.CurrencyCode; FFindObject = TRemote.MFinance.AP.UIConnectors.Find(); FFindObject.FindSupplierTransactions(FLedgerNumber, FPartnerKey); // Start thread that checks for the end of the search operation on the PetraServer FKeepUpSearchFinishedCheck = true; Thread FinishedCheckThread = new Thread(new ThreadStart(SearchFinishedCheckThread)); FinishedCheckThread.Start(); this.Text = Catalog.GetString("Supplier Transactions") + " - " + TFinanceControls.GetLedgerNumberAndName(FLedgerNumber); }
/// <summary> /// generate the partners from a text file that was generated with Benerator /// </summary> /// <param name="AInputBeneratorFile"></param> public static void GenerateOrganisationPartners(string AInputBeneratorFile) { PartnerEditTDS MainDS = new PartnerEditTDS(); AApSupplierTable supplierTable = new AApSupplierTable(); XmlDocument doc = TCsv2Xml.ParseCSV2Xml(AInputBeneratorFile, ",", Encoding.UTF8); XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild; Int32 NumberOfPartnerKeysReserved = 100; Int64 NextPartnerKey = TNewPartnerKey.ReservePartnerKeys(-1, ref NumberOfPartnerKeysReserved); while (RecordNode != null) { if (NumberOfPartnerKeysReserved == 0) { NumberOfPartnerKeysReserved = 100; NextPartnerKey = TNewPartnerKey.ReservePartnerKeys(-1, ref NumberOfPartnerKeysReserved); } long OrgPartnerKey = NextPartnerKey; NextPartnerKey++; NumberOfPartnerKeysReserved--; POrganisationRow organisationRecord = MainDS.POrganisation.NewRowTyped(); organisationRecord.PartnerKey = OrgPartnerKey; organisationRecord.OrganisationName = TXMLParser.GetAttribute(RecordNode, "OrganisationName"); MainDS.POrganisation.Rows.Add(organisationRecord); PPartnerRow PartnerRow = MainDS.PPartner.NewRowTyped(); PartnerRow.PartnerKey = organisationRecord.PartnerKey; PartnerRow.PartnerClass = MPartnerConstants.PARTNERCLASS_ORGANISATION; PartnerRow.StatusCode = MPartnerConstants.PARTNERSTATUS_ACTIVE; PartnerRow.PartnerShortName = organisationRecord.OrganisationName; PartnerRow.AddresseeTypeCode = MPartnerConstants.ADDRESSEETYPE_ORGANISATION; MainDS.PPartner.Rows.Add(PartnerRow); PLocationRow locationRow = MainDS.PLocation.NewRowTyped(); locationRow.SiteKey = 0; // DomainManager.GSiteKey; locationRow.LocationKey = (MainDS.PLocation.Count + 1) * -1; locationRow.StreetName = TXMLParser.GetAttribute(RecordNode, "Addr2"); locationRow.PostalCode = TXMLParser.GetAttribute(RecordNode, "PostCode"); locationRow.City = TXMLParser.GetAttribute(RecordNode, "City"); locationRow.County = TXMLParser.GetAttribute(RecordNode, "Province"); locationRow.CountryCode = TXMLParser.GetAttribute(RecordNode, "CountryCode"); MainDS.PLocation.Rows.Add(locationRow); PPartnerLocationRow organisationLocationRow = MainDS.PPartnerLocation.NewRowTyped(); organisationLocationRow.PartnerKey = PartnerRow.PartnerKey; organisationLocationRow.LocationKey = locationRow.LocationKey; organisationLocationRow.SiteKey = locationRow.SiteKey; organisationLocationRow.LocationType = MPartnerConstants.LOCATIONTYPE_BUSINESS; organisationLocationRow.SendMail = true; if (TXMLParser.GetAttribute(RecordNode, "IsSupplier") == "yes") { AApSupplierRow supplierRow = supplierTable.NewRowTyped(true); supplierRow.PartnerKey = organisationRecord.PartnerKey; supplierRow.CurrencyCode = TXMLParser.GetAttribute(RecordNode, "Currency"); if (supplierRow.CurrencyCode == "GBP") { supplierRow.DefaultBankAccount = "6210"; } else { supplierRow.DefaultBankAccount = "6200"; } supplierRow.DefaultApAccount = "9100"; supplierRow.DefaultCostCentre = (FLedgerNumber * 100).ToString("0000"); supplierRow.DefaultExpAccount = "4200"; supplierTable.Rows.Add(supplierRow); } MainDS.PPartnerLocation.Rows.Add(organisationLocationRow); RecordNode = RecordNode.NextSibling; } PartnerEditTDSAccess.SubmitChanges(MainDS); AApSupplierAccess.SubmitChanges(supplierTable, null); }
/// <summary> /// Load the supplier and all the transactions (invoices and payments) that relate to it. /// </summary> /// <param name="ALedgerNumber"></param> /// <param name="APartnerKey"></param> public void LoadSupplier(Int32 ALedgerNumber, Int64 APartnerKey) { this.Cursor = Cursors.WaitCursor; FLedgerNumber = ALedgerNumber; FPartnerKey = APartnerKey; FMainDS = TRemote.MFinance.AP.WebConnectors.LoadAApSupplier(ALedgerNumber, APartnerKey); FSupplierRow = FMainDS.AApSupplier[0]; // Get our AP ledger settings and enable/disable the corresponding search option on the filter panel TFrmLedgerSettingsDialog settings = new TFrmLedgerSettingsDialog(this, ALedgerNumber); FRequireApprovalBeforePosting = settings.APRequiresApprovalBeforePosting; Control rbtForApproval = FFilterAndFindObject.FilterPanelControls.FindControlByName("rbtForApproval"); rbtForApproval.Enabled = FRequireApprovalBeforePosting; // // Transactions older than DateTime AgedOlderThan = DateTime.Now; if (!FSupplierRow.IsPreferredScreenDisplayNull()) { AgedOlderThan = AgedOlderThan.AddMonths(0 - FSupplierRow.PreferredScreenDisplay); } FAgedOlderThan = AgedOlderThan.ToString("u"); txtSupplierName.Text = FMainDS.PPartner[0].PartnerShortName; txtSupplierCurrency.Text = FSupplierRow.CurrencyCode; FFindObject = TRemote.MFinance.AP.UIConnectors.Find(); FFindObject.FindSupplierTransactions(FLedgerNumber, FPartnerKey); // Start thread that checks for the end of the search operation on the PetraServer FKeepUpSearchFinishedCheck = true; Thread FinishedCheckThread = new Thread(new ThreadStart(SearchFinishedCheckThread)); FinishedCheckThread.Start(); this.Text = Catalog.GetString("Supplier Transactions") + " - " + TFinanceControls.GetLedgerNumberAndName(FLedgerNumber); }
/// <summary> /// generate the partners from a text file that was generated with Benerator /// </summary> /// <param name="AInputBeneratorFile"></param> public static void GenerateOrganisationPartners(string AInputBeneratorFile) { PartnerEditTDS MainDS = new PartnerEditTDS(); AApSupplierTable supplierTable = new AApSupplierTable(); // AlanP: May 2016 - We may no longer need the UTF8 because the method now automatically discovers the encoding even with no BOM XmlDocument doc = TCsv2Xml.ParseCSVFile2Xml(AInputBeneratorFile, ",", Encoding.UTF8); XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild; Int32 NumberOfPartnerKeysReserved = 100; Int64 NextPartnerKey = TNewPartnerKey.ReservePartnerKeys(-1, ref NumberOfPartnerKeysReserved); while (RecordNode != null) { if (NumberOfPartnerKeysReserved == 0) { NumberOfPartnerKeysReserved = 100; NextPartnerKey = TNewPartnerKey.ReservePartnerKeys(-1, ref NumberOfPartnerKeysReserved); } long OrgPartnerKey = NextPartnerKey; NextPartnerKey++; NumberOfPartnerKeysReserved--; POrganisationRow organisationRecord = MainDS.POrganisation.NewRowTyped(); organisationRecord.PartnerKey = OrgPartnerKey; organisationRecord.OrganisationName = TXMLParser.GetAttribute(RecordNode, "OrganisationName"); MainDS.POrganisation.Rows.Add(organisationRecord); PPartnerRow PartnerRow = MainDS.PPartner.NewRowTyped(); PartnerRow.PartnerKey = organisationRecord.PartnerKey; PartnerRow.PartnerClass = MPartnerConstants.PARTNERCLASS_ORGANISATION; PartnerRow.StatusCode = MPartnerConstants.PARTNERSTATUS_ACTIVE; PartnerRow.PartnerShortName = organisationRecord.OrganisationName; PartnerRow.AddresseeTypeCode = MPartnerConstants.ADDRESSEETYPE_ORGANISATION; MainDS.PPartner.Rows.Add(PartnerRow); PLocationRow locationRow = MainDS.PLocation.NewRowTyped(); locationRow.SiteKey = 0; // DomainManager.GSiteKey; locationRow.LocationKey = (MainDS.PLocation.Count + 1) * -1; locationRow.StreetName = TXMLParser.GetAttribute(RecordNode, "Addr2"); locationRow.PostalCode = TXMLParser.GetAttribute(RecordNode, "PostCode"); locationRow.City = TXMLParser.GetAttribute(RecordNode, "City"); locationRow.County = TXMLParser.GetAttribute(RecordNode, "Province"); locationRow.CountryCode = TXMLParser.GetAttribute(RecordNode, "CountryCode"); MainDS.PLocation.Rows.Add(locationRow); PPartnerLocationRow organisationLocationRow = MainDS.PPartnerLocation.NewRowTyped(); organisationLocationRow.PartnerKey = PartnerRow.PartnerKey; organisationLocationRow.LocationKey = locationRow.LocationKey; organisationLocationRow.SiteKey = locationRow.SiteKey; organisationLocationRow.LocationType = MPartnerConstants.LOCATIONTYPE_BUSINESS; organisationLocationRow.SendMail = true; if (TXMLParser.GetAttribute(RecordNode, "IsSupplier") == "yes") { AApSupplierRow supplierRow = supplierTable.NewRowTyped(true); supplierRow.PartnerKey = organisationRecord.PartnerKey; supplierRow.CurrencyCode = TXMLParser.GetAttribute(RecordNode, "Currency"); if (supplierRow.CurrencyCode == "GBP") { supplierRow.DefaultBankAccount = "6210"; } else { supplierRow.DefaultBankAccount = "6200"; } supplierRow.DefaultApAccount = "9100"; supplierRow.DefaultCostCentre = (FLedgerNumber * 100).ToString("0000"); supplierRow.DefaultExpAccount = "4200"; supplierTable.Rows.Add(supplierRow); } MainDS.PPartnerLocation.Rows.Add(organisationLocationRow); RecordNode = RecordNode.NextSibling; } TDataBase db = DBAccess.Connect("GenerateOrganisationPartners"); TDBTransaction Transaction = new TDBTransaction(); bool SubmitOK = false; db.WriteTransaction( ref Transaction, ref SubmitOK, delegate { PartnerEditTDSAccess.SubmitChanges(MainDS, db); AApSupplierAccess.SubmitChanges(supplierTable, Transaction); SubmitOK = true; }); db.CloseDBConnection(); }