Пример #1
0
        /// <summary>
        /// Converts the unit to a string.
        /// </summary>
        /// <param name="IncludePrefix">If the prefix should be included in the string or not.</param>
        public string ToString(bool IncludePrefix)
        {
            StringBuilder Numerator      = null;
            StringBuilder Denominator    = null;
            int           NrDenominators = 0;

            foreach (KeyValuePair <AtomicUnit, int> Factor in this.factors)
            {
                if (Factor.Value > 0)
                {
                    if (Numerator is null)
                    {
                        if (IncludePrefix)
                        {
                            Numerator = new StringBuilder(Prefixes.ToString(this.prefix));
                        }
                        else
                        {
                            Numerator = new StringBuilder();
                        }
                    }
                    else
                    {
                        Numerator.Append('⋅');
                    }

                    Numerator.Append(Factor.Key.Name);

                    if (Factor.Value > 1)
                    {
                        if (Factor.Value == 2)
                        {
                            Numerator.Append('²');
                        }
                        else if (Factor.Value == 3)
                        {
                            Numerator.Append('³');
                        }
                        else
                        {
                            Numerator.Append('^');
                            Numerator.Append(Factor.Value.ToString());
                        }
                    }
                }
                else
                {
                    if (Denominator is null)
                    {
                        Denominator = new StringBuilder();
                    }
                    else
                    {
                        Denominator.Append('⋅');
                    }

                    NrDenominators++;
                    Denominator.Append(Factor.Key.Name);

                    if (Factor.Value < -1)
                    {
                        if (Factor.Value == -2)
                        {
                            Denominator.Append('²');
                        }
                        else if (Factor.Value == -3)
                        {
                            Denominator.Append('³');
                        }
                        else
                        {
                            Denominator.Append('^');
                            Denominator.Append((-Factor.Value).ToString());
                        }
                    }
                }
            }

            if (Numerator is null)
            {
                if (IncludePrefix)
                {
                    Numerator = new StringBuilder(Prefixes.ToString(this.prefix));
                }
                else
                {
                    Numerator = new StringBuilder();
                }
            }

            if (!(Denominator is null))
            {
                Numerator.Append('/');

                if (NrDenominators > 1)
                {
                    Numerator.Append('(');
                }

                Numerator.Append(Denominator.ToString());

                if (NrDenominators > 1)
                {
                    Numerator.Append(')');
                }
            }

            return(Numerator.ToString());
        }
Пример #2
0
 public virtual mpq Power(uint exponent)
 {
     return(new mpq(Numerator.Power(exponent), Denominator.Power(exponent)));
 }
Пример #3
0
 public virtual mpq Root(uint n)
 {
     return(new mpq(Numerator.Root(n), Denominator.Root(n)));
 }
Пример #4
0
 public override string ToString()
 {
     return(Denominator.CompareTo(BigInteger.One) != 0 ? Numerator + "/" + Denominator : Numerator.ToString());
 }
Пример #5
0
 private void penerimaanPotonganPembelian(ref Database db, ref int counterdb)
 {
     db.Commands.Add(db.CreateCommand("usp_PembayaranPemb_Potongan_INSERT"));
     db.Commands[counterdb].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, Guid.NewGuid()));
     db.Commands[counterdb].Parameters.Add(new Parameter("@Jenis", SqlDbType.VarChar, "POT"));
     db.Commands[counterdb].Parameters.Add(new Parameter("@NoTrans", SqlDbType.VarChar, Numerator.NextNumber("NKB")));
     db.Commands[counterdb].Parameters.Add(new Parameter("@Keterangan", SqlDbType.VarChar, "Potongan Pembelian DP Subsidi " + txtUraian.Text + " | " + lblNamaLeasing.Text.Trim() + " untuk " + lblNopol.Text.Trim()));
     db.Commands[counterdb].Parameters.Add(new Parameter("@PembRowID", SqlDbType.UniqueIdentifier, _PembelianRowID));
     db.Commands[counterdb].Parameters.Add(new Parameter("@Nominal", SqlDbType.Money, txtRefund.GetDoubleValue)); // txtNominal
     db.Commands[counterdb].Parameters.Add(new Parameter("@idrec", SqlDbType.VarChar, Tools.CreateFingerPrintMilliseconds()));
     db.Commands[counterdb].Parameters.Add(new Parameter("@CreatedBy", SqlDbType.VarChar, SecurityManager.UserID));
     db.Commands[counterdb].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
     db.Commands[counterdb].Parameters.Add(new Parameter("@BentukPembayaran", SqlDbType.SmallInt, 5));
     counterdb++;
 }
Пример #6
0
        public Rational Add(int val)
        {
            BigInteger val2 = Numerator.Add(Denominator.Multiply(BigInteger.Parse("" + val)));

            return(new Rational(val2, Denominator));
        }
Пример #7
0
 public Rational Abs()
 {
     return(new Rational(Numerator.Abs(), Denominator.Abs()));
 }
Пример #8
0
 public String toHTML()
 {
     return(@"\frac {" + Numerator.toHTML() + "} {" + Denominator.toHTML() + "}");
 }
Пример #9
0
 public String toText()
 {
     return("( " + Numerator.toText() + " ) / ( " + Denominator.toText() + " )");
 }
Пример #10
0
        protected void save_Click(object sender, System.EventArgs e)
        {
            if (valid())
            {
                DateTime TglKontrak = Convert.ToDateTime(tglkontrak.Text);
                string   Project    = Db.SingleString("SELECT Project FROM MS_UNIT WHERE NoStock = '" + NoStock + "'");
                //Numerator
                nokontrak.Text = Numerator.SuratPesanan(TglKontrak.Month, TglKontrak.Year, Project);

                decimal nilaitagihan = Db.SingleDecimal("SELECT Netto FROM MS_RESERVASI WHERE NoReservasi = '" + NoReservasi + "'");

                DateTime TargetST  = Convert.ToDateTime(targetst.Text);
                string   Skema     = Cf.Str(carabayar.SelectedItem.Text);
                decimal  surcharge = Convert.ToDecimal(Surcharge.Text);

                Db.Execute("EXEC spKontrakDaftar"
                           + " '" + NoKontrak + "'"
                           + ",'" + NoStock + "'"
                           + ",'" + TglKontrak + "'"
                           + ",'" + Skema + "'"
                           + ",'" + TargetST + "'"
                           );

                int KPR = 0;
                if (carabayar2.SelectedValue == "KPR")
                {
                    KPR = 1;
                }
                else
                {
                    KPR = 0;
                }


                //Manual update
                string sSQL = "UPDATE MS_KONTRAK"
                              + " SET JenisPPN = '" + JenisPPN.SelectedItem.Text + "'"
                              + ", JenisKPR = " + KPR
                              + ", CaraBayar = '" + carabayar2.SelectedValue + "'"
                              + ", RefSkema = '" + carabayar.SelectedValue + "'"
                              + ", Surcharge='" + surcharge + "'"
                              + " WHERE NoKontrak = '" + NoKontrak + "'"
                ;
                Db.Execute(sSQL);

                //Update Status Reservasi
                Db.Execute("UPDATE MS_RESERVASI SET Status='C' WHERE NoReservasi='" + NoReservasi + "'");

                int c = Db.SingleInteger("SELECT COUNT(NoKontrak) FROM MS_KONTRAK WHERE NoKontrak = '" + NoKontrak + "'");
                if (c == 0)
                {
                    nokontrak.Text = "#AUTO#";

                    Js.Alert(
                        this
                        , "Unit Tidak Valid.\\n\\n"
                        + "Kemungkinan Sebab :\\n"
                        + "1. Unit sudah dijual kepada customer lain.\\n"
                        , "document.getElementById('tglkontrak').focus();"
                        + "document.getElementById('tglkontrak').select();"
                        );
                }
                else
                {
                    SaveTagihan();

                    int Count = Db.SingleInteger("SELECT COUNT(*) FROM MS_TAGIHAN WHERE NoKontrak = '" + NoKontrak + "'");
                    if (Count == 0)
                    {
                    }
                    else
                    {
                        SaveFO();
                    }

                    DataTable rs = Db.Rs("SELECT "
                                         + " MS_KONTRAK.NoKontrak AS [No. Kontrak]"
                                         + ",MS_KONTRAK.NoUnit AS [Unit]"
                                         + ",MS_CUSTOMER.Nama AS [Customer]"
                                         + ",MS_AGENT.Nama + ' ' + MS_AGENT.Principal AS [Agent]"
                                         + ",CONVERT(varchar,MS_KONTRAK.TglKontrak,106) AS [Tanggal Kontrak]"
                                         + ",MS_KONTRAK.NoStock AS [No. Stock]"
                                         + ",MS_KONTRAK.Luas AS [Luas]"
                                         + ",MS_KONTRAK.Gross AS [Nilai Gross]"
                                         + ",MS_KONTRAK.DiskonRupiah AS [Diskon dalam Rupiah]"
                                         + ",MS_KONTRAK.DiskonPersen AS [Diskon dalam Persen]"
                                         + ",MS_KONTRAK.DiskonKet AS [Keterangan Diskon]"
                                         + ",MS_KONTRAK.NilaiKontrak AS [Nilai Kontrak]"
                                         + ",MS_KONTRAK.Skema"
                                         + ",CONVERT(varchar,MS_KONTRAK.TargetST,106) AS [Jadwal Serah Terima]"
                                         + ", MS_KONTRAK.JenisPPN AS [PPN Ditanggung]"
                                         + ", CASE MS_KONTRAK.JenisKPR"
                                         + "		WHEN 0 THEN 'KPR'"
                                         + "		WHEN 1 THEN 'NON-KPR'"
                                         + "	END AS [Jenis KPR]"
                                         + " FROM MS_KONTRAK INNER JOIN MS_CUSTOMER ON MS_KONTRAK.NoCustomer = MS_CUSTOMER.NoCustomer"
                                         + " INNER JOIN MS_AGENT ON MS_KONTRAK.NoAgent = MS_AGENT.NoAgent"
                                         + " WHERE NoKontrak = '" + NoKontrak + "'"
                                         );

                    DataTable rsTagihan = Db.Rs("SELECT "
                                                + "CONVERT(VARCHAR,NoUrut) + '.   ' + NamaTagihan + ' ('+Tipe+')   ' + CONVERT(VARCHAR,TglJT,106) + '   ' + CONVERT(VARCHAR,NilaiTagihan,1) "
                                                + "FROM MS_TAGIHAN WHERE NoKontrak = '" + NoKontrak + "' ORDER BY NoUrut");

                    //Logfile
                    string Ket = Cf.LogCapture(rs)
                                 + Cf.LogList(rsTagihan, "JADWAL TAGIHAN");

                    Db.Execute("EXEC spLogKontrak"
                               + " 'DAFTAR'"
                               + ",'" + Act.UserID + "'"
                               + ",'" + Act.IP + "'"
                               + ",'" + Ket + "'"
                               + ",'" + NoKontrak + "'"
                               );

                    decimal LogID = Db.SingleDecimal("SELECT TOP 1 LogID FROM MS_KONTRAK_LOG ORDER BY LogID DESC");
                    Db.Execute("UPDATE MS_KONTRAK_LOG SET Project = '" + Project + "' WHERE LogID  = " + LogID);

                    //floor plan
                    string Peta = Db.SingleString("SELECT Peta "
                                                  + " FROM MS_UNIT INNER JOIN MS_KONTRAK ON MS_UNIT.NoStock = MS_KONTRAK.NoStock "
                                                  + " WHERE NoKontrak = '" + NoKontrak + "'");
                    Func.GenerateFP(Peta);

                    Response.Redirect("KontrakDaftar3.aspx?NoKontrak=" + NoKontrak);
                }
            }
        }
Пример #11
0
        public void CreateData()
        {
            CreateDefaultCurrenciesIfNeeded();

            if (!ShouldCreateData())
            {
                return;
            }

            var saleAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Sales)
            };
            var receivableAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Receiveable)
            };
            var paymentAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Payment)
            };
            var discountAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Discount)
            };
            var customerAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Customer)
            };

            _workspace.Add(receivableAccountType);
            _workspace.Add(saleAccountType);
            _workspace.Add(paymentAccountType);
            _workspace.Add(discountAccountType);
            _workspace.Add(customerAccountType);
            _workspace.CommitChanges();

            var customerEntityType = new EntityType {
                Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name
            };

            customerEntityType.EntityCustomFields.Add(new EntityCustomField {
                EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone
            });
            customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]";
            var tableEntityType = new EntityType {
                Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name
            };

            _workspace.Add(customerEntityType);
            _workspace.Add(tableEntityType);

            _workspace.CommitChanges();

            var accountScreen = new AccountScreen {
                Name = Resources.General
            };

            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40
            });
            _workspace.Add(accountScreen);

            var defaultSaleAccount = new Account {
                AccountTypeId = saleAccountType.Id, Name = Resources.Sales
            };
            var defaultReceivableAccount = new Account {
                AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables
            };
            var cashAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Cash
            };
            var creditCardAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard
            };
            var voucherAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher
            };
            var defaultDiscountAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Discount
            };
            var defaultRoundingAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Rounding
            };

            _workspace.Add(defaultSaleAccount);
            _workspace.Add(defaultReceivableAccount);
            _workspace.Add(defaultDiscountAccount);
            _workspace.Add(defaultRoundingAccount);
            _workspace.Add(cashAccount);
            _workspace.Add(creditCardAccount);
            _workspace.Add(voucherAccount);

            _workspace.CommitChanges();

            var discountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Discount),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultDiscountAccount.Id
            };

            var roundingTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Rounding),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultRoundingAccount.Id
            };

            var saleTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Sale),
                SourceAccountTypeId    = saleAccountType.Id,
                TargetAccountTypeId    = receivableAccountType.Id,
                DefaultSourceAccountId = defaultSaleAccount.Id,
                DefaultTargetAccountId = defaultReceivableAccount.Id
            };

            var paymentTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Payment),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerAccountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.AccountTransaction),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = customerAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id
            };

            var customerCashPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CashPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerCreditCardPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = creditCardAccount.Id
            };

            _workspace.Add(saleTransactionType);
            _workspace.Add(paymentTransactionType);
            _workspace.Add(discountTransactionType);
            _workspace.Add(roundingTransactionType);
            _workspace.Add(customerAccountTransactionType);
            _workspace.Add(customerCashPaymentType);
            _workspace.Add(customerCreditCardPaymentType);

            var discountService = new CalculationType
            {
                AccountTransactionType = discountTransactionType,
                CalculationMethod      = 0,
                DecreaseAmount         = true,
                Name = Resources.Discount
            };

            var roundingService = new CalculationType
            {
                AccountTransactionType = roundingTransactionType,
                CalculationMethod      = 2,
                DecreaseAmount         = true,
                IncludeTax             = true,
                Name = Resources.Round
            };

            var discountSelector = new CalculationSelector {
                Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign
            };

            discountSelector.CalculationTypes.Add(discountService);
            discountSelector.AddCalculationSelectorMap();

            var roundingSelector = new CalculationSelector {
                Name = Resources.Round, ButtonHeader = Resources.Round
            };

            roundingSelector.CalculationTypes.Add(roundingService);
            roundingSelector.AddCalculationSelectorMap();


            _workspace.Add(discountService);
            _workspace.Add(roundingService);
            _workspace.Add(discountSelector);
            _workspace.Add(roundingSelector);

            var screen = new ScreenMenu();

            _workspace.Add(screen);

            var ticketNumerator = new Numerator {
                Name = Resources.TicketNumerator
            };

            _workspace.Add(ticketNumerator);

            var orderNumerator = new Numerator {
                Name = Resources.OrderNumerator
            };

            _workspace.Add(orderNumerator);



            _workspace.CommitChanges();

            var ticketType = new TicketType
            {
                Name                = Resources.Ticket,
                TicketNumerator     = ticketNumerator,
                OrderNumerator      = orderNumerator,
                SaleTransactionType = saleTransactionType,
                ScreenMenuId        = screen.Id,
            };

            ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment {
                EntityTypeId = tableEntityType.Id, EntityTypeName = tableEntityType.Name, SortOrder = 10
            });
            ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment {
                EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20
            });

            var cashPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = cashAccount,
                Name    = cashAccount.Name
            };

            cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var creditCardPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = creditCardAccount,
                Name    = creditCardAccount.Name
            };

            creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var voucherPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = voucherAccount,
                Name    = voucherAccount.Name
            };

            voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var accountPayment = new PaymentType
            {
                AccountTransactionType = customerAccountTransactionType,
                Name = Resources.CustomerAccount
            };

            accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            _workspace.Add(cashPayment);
            _workspace.Add(creditCardPayment);
            _workspace.Add(voucherPayment);
            _workspace.Add(accountPayment);
            _workspace.Add(ticketType);

            var warehouseType = new WarehouseType {
                Name = Resources.Warehouses
            };

            _workspace.Add(warehouseType);
            _workspace.CommitChanges();

            var localWarehouse = new Warehouse
            {
                Name            = Resources.LocalWarehouse,
                WarehouseTypeId = warehouseType.Id
            };

            _workspace.Add(localWarehouse);
            _workspace.CommitChanges();

            var department = new Department
            {
                Name         = Resources.Restaurant,
                TicketTypeId = ticketType.Id,
                WarehouseId  = localWarehouse.Id
            };

            _workspace.Add(department);

            var transactionType = new InventoryTransactionType
            {
                Name = Resources.PurchaseTransactionType,
                TargetWarehouseTypeId    = warehouseType.Id,
                DefaultTargetWarehouseId = localWarehouse.Id
            };

            _workspace.Add(transactionType);

            var transactionDocumentType = new InventoryTransactionDocumentType
            {
                Name = Resources.PurchaseTransaction,
                InventoryTransactionType = transactionType
            };

            _workspace.Add(transactionDocumentType);

            var role = new UserRole("Admin")
            {
                IsAdmin = true, DepartmentId = 1
            };

            _workspace.Add(role);

            var u = new User("Administrator", "1234")
            {
                UserRole = role
            };

            _workspace.Add(u);

            var ticketPrinterTemplate = new PrinterTemplate {
                Name = Resources.TicketTemplate, Template = GetDefaultTicketPrintTemplate()
            };
            var kitchenPrinterTemplate = new PrinterTemplate {
                Name = Resources.KitchenOrderTemplate, Template = GetDefaultKitchenPrintTemplate()
            };
            var customerReceiptTemplate = new PrinterTemplate {
                Name = Resources.CustomerReceiptTemplate, Template = GetDefaultCustomerReceiptTemplate()
            };

            _workspace.Add(ticketPrinterTemplate);
            _workspace.Add(kitchenPrinterTemplate);
            _workspace.Add(customerReceiptTemplate);

            var printer1 = new Printer {
                Name = Resources.TicketPrinter
            };
            var printer2 = new Printer {
                Name = Resources.KitchenPrinter
            };
            var printer3 = new Printer {
                Name = Resources.InvoicePrinter
            };

            _workspace.Add(printer1);
            _workspace.Add(printer2);
            _workspace.Add(printer3);

            _workspace.CommitChanges();

            var t = new Terminal
            {
                IsDefault            = true,
                Name                 = Resources.Server,
                ReportPrinterId      = printer1.Id,
                TransactionPrinterId = printer1.Id,
            };

            var pm1 = new PrinterMap {
                PrinterId = printer1.Id, PrinterTemplateId = ticketPrinterTemplate.Id
            };

            _workspace.Add(pm1);

            var pj1 = new PrintJob
            {
                Name        = Resources.PrintBill,
                WhatToPrint = (int)WhatToPrintTypes.Everything,
            };

            pj1.PrinterMaps.Add(pm1);


            _workspace.Add(pj1);

            var pm2 = new PrinterMap {
                PrinterId = printer2.Id, PrinterTemplateId = kitchenPrinterTemplate.Id
            };
            var pj2 = new PrintJob
            {
                Name        = Resources.PrintOrdersToKitchenPrinter,
                WhatToPrint = (int)WhatToPrintTypes.Everything,
            };

            pj2.PrinterMaps.Add(pm2);

            _workspace.Add(pj2);
            _workspace.Add(t);

            new RuleGenerator().GenerateSystemRules(_workspace);

            ImportMenus(screen);
            ImportTableResources(tableEntityType, ticketType);

            var customerScreen = new EntityScreen {
                Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id
            };

            customerScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerScreen);

            var customerTicketScreen = new EntityScreen {
                Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id
            };

            customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerTicketScreen);

            var customerCashDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.Cash),
                ButtonHeader        = Resources.Cash,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCashDocument.AddAccountTransactionDocumentTypeMap();
            customerCashDocument.TransactionTypes.Add(customerCashPaymentType);

            var customerCreditCardDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.CreditCard),
                ButtonHeader        = Resources.CreditCard,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCreditCardDocument.AddAccountTransactionDocumentTypeMap();
            customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType);

            _workspace.Add(customerCashDocument);
            _workspace.Add(customerCreditCardDocument);

            ImportItems(BatchCreateEntities);
            ImportItems(BatchCreateTransactionTypes);
            ImportItems(BatchCreateTransactionTypeDocuments);

            _workspace.CommitChanges();
            _workspace.Dispose();
        }
Пример #12
0
        private void cmdSaveTitipan_Click(object sender, EventArgs e)
        {
            if (validasiInputan())
            {
                Double      decNilaiBGC             = 0;
                Double      decNilaiNominal         = 0;
                int         bentukPembayaran        = 1;
                System.Guid rekeningPembayaranRowID = System.Guid.Empty;
                decNilaiNominal = Convert.ToDouble(txtPembayaran.Text);

                if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "transfer")
                {
                    bentukPembayaran        = 2;
                    rekeningPembayaranRowID = lookUpRekening1.RekeningRowID;
                }
                else if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                {
                    bentukPembayaran = 3;
                    decNilaiBGC      = Convert.ToDouble(txtPembayaran.Text);
                    decNilaiNominal  = 0;
                }

                if (mode == FormMode.New)
                {
                    int tempTipeTitipan = 0;
                    if (cboTipeTitipan.SelectedIndex == 0)
                    {
                        // berarti yang titipan murni
                        tempTipeTitipan     = 0;
                        txtNoTransaksi.Text = Numerator.NextNumber("NTP");
                        if (txtNoTransaksi.Text == "")
                        {
                            MessageBox.Show("No Transaksi masih kosong");
                            return;
                        }
                    }
                    else if (cboTipeTitipan.SelectedIndex == 1)
                    {
                        // berarti titipan UM
                        tempTipeTitipan     = 1;
                        txtNoTransaksi.Text = "K" + Numerator.NextNumber("NKJ");
                        if (txtNoTransaksi.Text == "")
                        {
                            MessageBox.Show("No Transaksi masih kosong");
                            return;
                        }
                    }

                    System.Guid rowIDNewTitipan = new System.Guid();
                    Guid        penerimaanUangRowID;
                    penerimaanUangRowID   = Guid.NewGuid();
                    rowIDNewTitipan       = System.Guid.NewGuid();
                    _selectedTitipanRowID = rowIDNewTitipan;

                    Database db = new Database();
                    Database dbf = new Database(GlobalVar.DBFinanceOto);
                    int      counterdb = 0, counterdbf = 0;

                    try
                    {
                        PenerimaanTitipanInsert(ref db, ref counterdb, decNilaiNominal, decNilaiBGC, rowIDNewTitipan, rekeningPembayaranRowID, penerimaanUangRowID, tempTipeTitipan);


                        // kalo tipe pembayarannya itu tunai/transfer baru boleh masukkin ke data penerimaanUang
                        if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "tunai" || cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "transfer")
                        {
                            String tempBentukPenerimaan = "";
                            switch (cbxBentukPembayaran.SelectedIndex + 1)
                            {
                            case 1:     // kalau kas
                                tempBentukPenerimaan = "K";
                                break;

                            case 2:     // kalau transfer
                                tempBentukPenerimaan = "B";
                                break;

                            case 3:     // kalau giro
                                tempBentukPenerimaan = "G";
                                break;

                            case 4:     // kalau titipan
                                tempBentukPenerimaan = "K";
                                break;
                            }
                            // buat no trans penerimaanUang nya dulu
                            Database dbfNumerator      = new Database(GlobalVar.DBFinanceOto);
                            String   NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                   "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                                   string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                   , 4, false, true);
                            PenerimaanUangInsert(ref dbf, ref counterdbf, decNilaiNominal, rekeningPembayaranRowID, penerimaanUangRowID, NoTransPenerimaan);
                        }

                        db.BeginTransaction();
                        dbf.BeginTransaction();
                        int looper = 0;
                        for (looper = 0; looper < counterdb; looper++)
                        {
                            db.Commands[looper].ExecuteNonQuery();
                        }
                        for (looper = 0; looper < counterdbf; looper++)
                        {
                            dbf.Commands[looper].ExecuteNonQuery();
                        }
                        db.CommitTransaction();
                        dbf.CommitTransaction();

                        MessageBox.Show("Data berhasil ditambahkan");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        db.RollbackTransaction();
                        dbf.RollbackTransaction();
                        Error.LogError(ex);
                        MessageBox.Show("Penambahan penerimaan titipan gagal disimpan : " + ex.Message.ToString());
                    }
                }
                else if (mode == FormMode.Update)
                {
                    Database db        = new Database();
                    int      counterdb = 0;
                    try
                    {
                        PenerimaanTitipanUpdate(ref db, ref counterdb, decNilaiNominal, decNilaiBGC, rekeningPembayaranRowID);
                        db.BeginTransaction();
                        int looper = 0;
                        for (looper = 0; looper < counterdb; looper++)
                        {
                            db.Commands[looper].ExecuteNonQuery();
                        }
                        db.CommitTransaction();
                        MessageBox.Show("Data berhasil diupdate");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        db.RollbackTransaction();
                        Error.LogError(ex);
                        MessageBox.Show("Data gagal diproses : " + ex.Message.ToString());
                    }
                }
            }
        }
Пример #13
0
        private string SaveTTS(string NoNUP, string cabar, string rekpers, string ketbayar, DateTime TglTransfer, int NoCustomer, decimal nilai, string Jenis)
        {
            int roman = Convert.ToInt32(Cf.Bulan(DateTime.Now));

            DateTime TglTTS    = TglTransfer;
            string   Customer  = Cf.Str(Db.SingleString("SELECT Nama FROM MS_CUSTOMER WHERE NoCustomer = " + NoCustomer));
            string   CaraBayar = cabar;

            Db.Execute("EXEC ISC064_FINANCEAR..spTTSRegistrasi"
                       + " '" + TglTTS + "'"
                       + ",'" + Act.UserID + "'"
                       + ",'" + Act.IP + "'"
                       + ",'JUAL'"
                       + ",''" //Ref / NoKontrak
                       + ",''" //Unit
                       + ",'" + Customer + "'"
                       + ",'" + CaraBayar + "'"
                       + ",'PEMBAYARAN PLP'"
                       );

            int NoTTS = Db.SingleInteger("SELECT TOP 1 NoTTS FROM ISC064_FINANCEAR..MS_TTS ORDER BY NoTTS DESC");

            //di hard code untuk projectnya
            string NoTTS2 = Numerator.TTS(TglTTS.Month, TglTTS.Year, "SVS");

            //update nilai bayar di TTSnya
            decimal nBayar = nilai;

            Db.Execute("UPDATE ISC064_FINANCEAR..MS_TTS SET Total=" + nBayar
                       + ", Acc = '" + rekpers + "'"
                       + ", NoNUP = '" + NoNUP + "'"
                       + ", Jenis = '" + Jenis + "'"
                       + ", NoTTS2 = '" + NoTTS2 + "'"
                       //+ ", NoKK = '" + Cf.Str(noKK) + "'"
                       + ", Catatan = '" + Cf.Str(ketbayar) + "'"
                       + " WHERE NoTTS='" + NoTTS + "'");

            DataTable rs = Db.Rs("SELECT "
                                 + " CONVERT(varchar, TglTTS, 106) AS [Tanggal]"
                                 + ",Tipe"
                                 + ",Ref AS [Ref.]"
                                 + ",Unit"
                                 + ",Customer"
                                 + ",CaraBayar AS [Cara Bayar]"
                                 + ",Ket AS [Keterangan]"
                                 + ",Total"
                                 + ",NoBG AS [No. BG]"
                                 + ",CONVERT(varchar, TglBG, 106) AS [Tanggal BG]"
                                 + " FROM ISC064_FINANCEAR..MS_TTS WHERE NoTTS = " + NoTTS);

            string KetLog =
                "***PEMBAYARAN NUP PERTAMA: " + NoNUP + " Tipe = " + Jenis + "<br/><br/>"
                + Cf.LogCapture(rs);

            Db.Execute("EXEC ISC064_FINANCEAR..spLogTTS"
                       + " 'REGIS'"
                       + ",'" + Act.UserID + "'"
                       + ",'" + Act.IP + "'"
                       + ",'" + KetLog + "'"
                       + ",'" + NoTTS.ToString().PadLeft(7, '0') + "'"
                       );

            return(NoTTS.ToString());
        }
Пример #14
0
        protected string SubtractFractions(int N1, int D1, int N2, int D2)
        {
            int MaxNumber = 0, LCD = 0, temp = 0, Multiplier1 = 1, Multiplier2 = 1;

            if (D1 == D2)
            {
                LCD         = D1;
                Multiplier1 = 1;
                Multiplier2 = 1;
            }
            else
            {
                if (D1 > D2)
                {
                    LCD = D1;
                }
                else if (D1 < D2)
                {
                    LCD = D2;
                }

                MaxNumber = D1 * D2;
                for (int i = 1; i <= MaxNumber; i++)
                {
                    temp = LCD * i;
                    if ((temp % D2 == 0) && (temp % D1 == 0))
                    {
                        LCD         = temp;
                        Multiplier1 = LCD / D1;
                        Multiplier2 = LCD / D2;
                        break;
                    }
                }
            }

            Denominator = LCD;
            Numerator   = (N1 * Multiplier1 - N2 * Multiplier2);

            int Min;

            if (Denominator == Numerator)
            {
                Numerator   = 1;
                Denominator = 1;
            }
            else
            {
                if (Denominator > Numerator)
                {
                    Min = Numerator;
                }
                else
                {
                    Min = Denominator;
                }
                for (int i = Min; i >= 1; i--)
                {
                    if ((Numerator % i == 0) && (Denominator % i == 0))
                    {
                        Numerator   = Numerator / i;
                        Denominator = Denominator / i;
                    }
                }
            }

            return(Numerator.ToString() + " / " + Denominator.ToString());
        }
        private Numerator CalculateNumeratorFor(Person p)
        {
            var povertyYears = p.GetPovertyYears();

            int numPovertyYears = povertyYears.Count;

            if (numPovertyYears == 0)
                return Numerator.Zero; ;

            if (numPovertyYears == 1)
                return Numerator.Create(p.GetPovertyGapForYear(povertyYears[0]));

            var result = new Numerator();

            for (int n = 0; n < numPovertyYears - 1; n++) {
                for (int m = n + 1; m < numPovertyYears; m++) {
                    int lowYear = povertyYears[n];
                    int highYear = povertyYears[m];
                    int i = (highYear - minYear) + 1;
                    int j = (lowYear - minYear) + 1;

                    double Oij = p.GetNonPovertyYearsBetween(lowYear, highYear);
                    double Wij = p.GetPovertyGapAverage(lowYear, highYear);
                    double Pij = GetPovertyPersistenceRatioValue(p.Country, lowYear, highYear);

                    // double term = (Math.Pow((i - j + 1), -(Pij * (Oij + 1)))) * Wij;

                    result.S1.Terms.Add(Wij * Math.Pow((i - j + 1), -(Pij * (Oij + 1))));
                    result.S2.Terms.Add(Math.Pow((i - j + 1), -(Pij * (Oij + 1))));
                    result.S3.Terms.Add(Wij * Math.Pow((i - j + 1), -(Oij + 1)));
                    result.S4.Terms.Add(Wij * Math.Pow((i - j + 1), -1.0));
                    result.S5.Terms.Add(Math.Pow((i - j + 1), -1.0));
                }
            }

            return result;
        }
Пример #16
0
 public bool canEvaluateIfSymbolsConst(Symbol[] availableSymbols)
 {
     return(Numerator.canEvaluateIfSymbolsConst(availableSymbols) &&
            Denominator.canEvaluateIfSymbolsConst(availableSymbols));
 }
Пример #17
0
 public override void Negate()
 {
     Numerator.Negate();
 }
Пример #18
0
 public List <Symbol> symbolsInExpression(List <Symbol> symbols)
 {
     symbols = Numerator.symbolsInExpression(symbols);
     return(Denominator.symbolsInExpression(symbols));
 }
Пример #19
0
 public Rational Negate()
 {
     return(new Rational(Numerator.Negate(), Denominator));
 }
Пример #20
0
 /// <inheritdoc />
 public override string ToString()
 {
     return(Numerator.ToString("G", CultureInfo.InvariantCulture) + "/" + Denominator.ToString("G", CultureInfo.InvariantCulture));
 }
Пример #21
0
 public BigInteger Truncate()
 {
     return(Denominator.CompareTo(BigInteger.One) == 0 ? Numerator : Numerator.Divide(Denominator));
 }
Пример #22
0
        private void frmPenerimaanTunaiPIN_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = new DataTable();
                using (Database db = new Database(GlobalVar.DBName))
                {
                    db.Commands.Add(db.CreateCommand("usp_PenerimaanTunai_LIST"));
                    db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, _RowID));
                    dt = db.Commands[0].ExecuteDataTable();
                }

                _RowIDInden       = Guid.NewGuid();
                _RowIDIndenDetail = Guid.NewGuid();
                _RecordIDInden    = Tools.CreateFingerPrint(GlobalVar.PerusahaanID, SecurityManager.UserInitial);
                //_RecordIDIndenDetail = Tools.CreateFingerPrint(GlobalVar.PerusahaanID, SecurityManager.UserInitial);
                _TglKasir      = _TglTerima; // GlobalVar.DateOfServer;
                _Kasir         = SecurityManager.UserName;
                _NoBukti       = Numerator.BookNumerator("IND");
                _CollectorID   = Tools.isNull(dt.Rows[0]["CollectorID"], "").ToString();
                _NamaCollector = Tools.isNull(dt.Rows[0]["Nama"], "").ToString();
                _Acc           = "";
                _Nominal       = dt.Rows[0]["Nominal"].ToString();


                txtPublicKey.Text = Tools.isNull(dt.Rows[0]["PublicKey"], "").ToString();


                if (_NamaCollector == "VIA")
                {
                    DataTable dtAppSet;
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_AppSetting_LIST"));
                        db.Commands[0].Parameters.Add(new Parameter("@key", SqlDbType.VarChar, "PENERIMAAN TUNAI"));
                        dtAppSet = db.Commands[0].ExecuteDataTable();
                    }

                    if (dtAppSet.Rows.Count > 0)
                    {
                        if (dtAppSet.Rows[0]["Value"].ToString() == "1")
                        {
                            MD5 md5Hash = MD5.Create();

                            string _PIN = key.GetMd5Hash(md5Hash, txtPublicKey.Text);
                            txtPin.Text = _PIN;
                        }
                    }
                }
                /*pin dilepas*/
                if (GlobalVar.Gudang == "2808")
                {
                    MD5 md5Hash = MD5.Create();

                    string _PIN = key.GetMd5Hash(md5Hash, txtPublicKey.Text);
                    txtPin.Text = _PIN;
                }
                else
                {
                    MD5 md5Hash = MD5.Create();

                    string _PIN = key.GetMd5Hash(md5Hash, txtPublicKey.Text);
                    txtPin.Text = _PIN;
                }
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }
Пример #23
0
 public override decimal?Evaluate() => Numerator.Evaluate() / Denominator.Evaluate();
Пример #24
0
 /// <summary>
 /// Validate that this RTO meets minimum conformance criteria
 /// </summary>
 public override bool Validate()
 {
     return((NullFlavor != null) ^ (Denominator != null || Numerator != null) &&
            ((Numerator != null && Denominator != null && Denominator.Validate() && Numerator.Validate()) ||
             (Numerator == null && Denominator == null)) &&
            UncertainRange == null);
 }
Пример #25
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (ValidateSave())
            {
                if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                {
                    MessageBox.Show("Tidak bisa menggunakan giro!");
                    return;
                }

                Database db = new Database();
                Database dbf = new Database(GlobalVar.DBFinanceOto);
                int      counterdb = 0, counterdbf = 0;
                Guid     PenerimaanUMRowID   = Guid.NewGuid();
                Guid     PenerimaanUangRowID = Guid.NewGuid();
                _rowID = PenerimaanUMRowID;
                int    bentukPembayaran = 1;
                string bentukPenerimaan = "K";
                switch (cbxBentukPembayaran.SelectedIndex)
                {
                case 0:     // kalau kas
                    bentukPenerimaan = "K";
                    bentukPembayaran = 1;
                    break;

                case 1:      // kalau transfer
                    bentukPenerimaan = "B";
                    bentukPembayaran = 2;
                    break;

                case 2:      // kalau giro
                    bentukPenerimaan = "G";
                    bentukPembayaran = 3;
                    break;

                case 3:      // kalau potongan pembelian
                    bentukPenerimaan = "K";
                    bentukPembayaran = 5;
                    break;
                }

                if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "potongan pembelian")
                {
                }
                else if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                {
                    // NTP untuk kode dokumen titipan , seperti giro
                    txtNoTrans.Text  = Numerator.NextNumber("NTP");
                    bentukPembayaran = 3;
                }
                else
                {
                    // NKJ untuk kode dokumen non giro
                    txtNoTrans.Text = "K" + Numerator.NextNumber("NKJ");
                }

                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                    {
                        penerimaanTitipanInsert(ref db, ref counterdb, PenerimaanUMRowID, bentukPembayaran);
                    }
                    else
                    {
                        penerimaanUMInsert(ref db, ref counterdb, PenerimaanUMRowID, bentukPembayaran, PenerimaanUangRowID);

                        if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "potongan pembelian")
                        {
                            penerimaanPotonganPembelian(ref db, ref counterdb);
                        }
                        else
                        {
                            Database dbfNumerator      = new Database(GlobalVar.DBFinanceOto);
                            String   NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                   "/B" + bentukPenerimaan.Trim() + "M/" +
                                                                                   string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                   , 4, false, true);
                            penerimaanUangInsert(ref dbf, ref counterdbf, PenerimaanUangRowID, NoTransPenerimaan);
                        }
                    }

                    db.BeginTransaction();
                    dbf.BeginTransaction();
                    int looper = 0;
                    for (looper = 0; looper < counterdb; looper++)
                    {
                        db.Commands[looper].ExecuteNonQuery();
                    }
                    for (looper = 0; looper < counterdbf; looper++)
                    {
                        dbf.Commands[looper].ExecuteNonQuery();
                    }
                    db.CommitTransaction();
                    dbf.CommitTransaction();

                    String messageTemp;
                    messageTemp = "Data berhasil ditambahkan. \n";
                    MessageBox.Show(messageTemp);
                    this.Close();
                }
                catch (Exception ex)
                {
                    db.RollbackTransaction();
                    dbf.RollbackTransaction();
                    MessageBox.Show("Data gagal ditambahkan !\n " + ex.Message);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
Пример #26
0
 public override string ToString()
 {
     return(Numerator.ToString() + "/" + Denominator.ToString());
 }
Пример #27
0
 public virtual mpq Sqrt()
 {
     return(new mpq(Numerator.Sqrt(), Denominator.Sqrt()));
 }
Пример #28
0
 public override Token Clone()
 {
     return(new FractionToken((ValueToken)Numerator.Clone(), (ValueToken)Denominator.Clone()));
 }
Пример #29
0
 public override int GetHashCode()
 {
     return(13 * (Numerator.GetHashCode() + Denominator.GetHashCode()));
 }
Пример #30
0
 public override decimal GreatestCommonDivisor()
 {
     return(Utility.GreatestCommonDivisor(Numerator.GreatestCommonDivisor(), Denominator.GreatestCommonDivisor()));
 }
Пример #31
0
        public void Create(DataCreationService dataCreationService, IWorkspace workspace)
        {
            this._workspace = workspace;
            var saleAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Sales)
            };
            var receivableAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Receiveable)
            };
            var paymentAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Payment)
            };
            var discountAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Discount)
            };
            var customerAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Customer)
            };

            _workspace.Add(receivableAccountType);
            _workspace.Add(saleAccountType);
            _workspace.Add(paymentAccountType);
            _workspace.Add(discountAccountType);
            _workspace.Add(customerAccountType);
            _workspace.CommitChanges();

            var customerEntityType = new EntityType {
                Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name
            };

            customerEntityType.EntityCustomFields.Add(new EntityCustomField {
                EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone
            });
            customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]";
            //var tableEntityType = new EntityType { Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name };

            _workspace.Add(customerEntityType);
            //_workspace.Add(tableEntityType);

            _workspace.CommitChanges();

            var accountScreen = new AccountScreen {
                Name = Resources.General
            };

            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40
            });
            _workspace.Add(accountScreen);

            var defaultSaleAccount = new Account {
                AccountTypeId = saleAccountType.Id, Name = Resources.Sales
            };
            var defaultReceivableAccount = new Account {
                AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables
            };
            var cashAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Cash
            };
            var creditCardAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard
            };
            var voucherAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher
            };
            var defaultDiscountAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Discount
            };
            var defaultRoundingAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Rounding
            };

            _workspace.Add(defaultSaleAccount);
            _workspace.Add(defaultReceivableAccount);
            _workspace.Add(defaultDiscountAccount);
            _workspace.Add(defaultRoundingAccount);
            _workspace.Add(cashAccount);
            _workspace.Add(creditCardAccount);
            _workspace.Add(voucherAccount);

            _workspace.CommitChanges();

            var discountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Discount),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultDiscountAccount.Id
            };

            var roundingTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Rounding),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultRoundingAccount.Id
            };

            var saleTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Sale),
                SourceAccountTypeId    = saleAccountType.Id,
                TargetAccountTypeId    = receivableAccountType.Id,
                DefaultSourceAccountId = defaultSaleAccount.Id,
                DefaultTargetAccountId = defaultReceivableAccount.Id
            };

            var paymentTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Payment),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerAccountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.AccountTransaction),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = customerAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id
            };

            var customerCashPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CashPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerCreditCardPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = creditCardAccount.Id
            };

            _workspace.Add(saleTransactionType);
            _workspace.Add(paymentTransactionType);
            _workspace.Add(discountTransactionType);
            _workspace.Add(roundingTransactionType);
            _workspace.Add(customerAccountTransactionType);
            _workspace.Add(customerCashPaymentType);
            _workspace.Add(customerCreditCardPaymentType);

            var discountService = new CalculationType
            {
                AccountTransactionType = discountTransactionType,
                CalculationMethod      = 0,
                DecreaseAmount         = true,
                Name = Resources.Discount
            };

            var roundingService = new CalculationType
            {
                AccountTransactionType = roundingTransactionType,
                CalculationMethod      = 2,
                DecreaseAmount         = true,
                IncludeTax             = true,
                Name = Resources.Round
            };

            var discountSelector = new CalculationSelector {
                Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign
            };

            discountSelector.CalculationTypes.Add(discountService);
            discountSelector.AddCalculationSelectorMap();

            var roundingSelector = new CalculationSelector {
                Name = Resources.Round, ButtonHeader = Resources.Round
            };

            roundingSelector.CalculationTypes.Add(roundingService);
            roundingSelector.AddCalculationSelectorMap();


            _workspace.Add(discountService);
            _workspace.Add(roundingService);
            _workspace.Add(discountSelector);
            _workspace.Add(roundingSelector);

            var screen = new ScreenMenu();

            _workspace.Add(screen);

            var ticketNumerator = new Numerator {
                Name = Resources.TicketNumerator
            };

            _workspace.Add(ticketNumerator);

            var orderNumerator = new Numerator {
                Name = Resources.OrderNumerator
            };

            _workspace.Add(orderNumerator);



            _workspace.CommitChanges();

            var ticketType = new TicketType
            {
                Name                = Resources.Ticket,
                TicketNumerator     = ticketNumerator,
                OrderNumerator      = orderNumerator,
                SaleTransactionType = saleTransactionType,
                ScreenMenuId        = screen.Id,
            };

            ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment {
                EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20
            });

            var cashPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = cashAccount,
                Name    = cashAccount.Name
            };

            cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var creditCardPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = creditCardAccount,
                Name    = creditCardAccount.Name
            };

            creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var voucherPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = voucherAccount,
                Name    = voucherAccount.Name
            };

            voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var accountPayment = new PaymentType
            {
                AccountTransactionType = customerAccountTransactionType,
                Name = Resources.CustomerAccount
            };

            accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            _workspace.Add(cashPayment);
            _workspace.Add(creditCardPayment);
            _workspace.Add(voucherPayment);
            _workspace.Add(accountPayment);
            _workspace.Add(ticketType);

            var warehouseType = new WarehouseType {
                Name = Resources.Warehouses
            };

            _workspace.Add(warehouseType);
            _workspace.CommitChanges();

            var localWarehouse = new Warehouse
            {
                Name            = Resources.LocalWarehouse,
                WarehouseTypeId = warehouseType.Id
            };

            _workspace.Add(localWarehouse);
            _workspace.CommitChanges();

            var department = new Department
            {
                Name         = Resources.Retail,
                TicketTypeId = ticketType.Id,
                WarehouseId  = localWarehouse.Id
            };

            _workspace.Add(department);

            var transactionType = new InventoryTransactionType
            {
                Name = Resources.PurchaseTransactionType,
                TargetWarehouseTypeId    = warehouseType.Id,
                DefaultTargetWarehouseId = localWarehouse.Id
            };

            _workspace.Add(transactionType);

            var transactionDocumentType = new InventoryTransactionDocumentType
            {
                Name = Resources.PurchaseTransaction,
                InventoryTransactionType = transactionType
            };

            _workspace.Add(transactionDocumentType);

            AddDefaultUsers();

            PrinterTemplate customerReceiptTemplate = AddDefaultPrintersAndTerminal();

            new RuleGenerator().GenerateSystemRules(_workspace);

            dataCreationService.ImportMenus(screen);
            //dataCreationService.ImportTableResources(tableEntityType, ticketType);
            //RL - import data and associate with an entity.
            //C:\Users\Roy Lawson\source\repos\sdselite\SambaPOS-3\Samba.Presentation\bin\Debug\Imports

            var customerScreen = new EntityScreen {
                Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id
            };

            customerScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerScreen);

            var customerTicketScreen = new EntityScreen {
                Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id
            };

            customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerTicketScreen);

            var customerCashDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.Cash),
                ButtonHeader        = Resources.Cash,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCashDocument.AddAccountTransactionDocumentTypeMap();
            customerCashDocument.TransactionTypes.Add(customerCashPaymentType);

            var customerCreditCardDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.CreditCard),
                ButtonHeader        = Resources.CreditCard,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCreditCardDocument.AddAccountTransactionDocumentTypeMap();
            customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType);

            _workspace.Add(customerCashDocument);
            _workspace.Add(customerCreditCardDocument);
        }
 public static Numerator Create(double term)
 {
     var result = new Numerator();
     result.S1.Terms.Add(term);
     result.S2.Terms.Add(term);
     result.S3.Terms.Add(term);
     result.S4.Terms.Add(term);
     result.S5.Terms.Add(term);
     return result;
 }