Пример #1
0
        public async Task <ActionResult> PostAsync([FromBody] BusinessDomain businessDomain)
        {
            var createDomain = new CreateDomain()
            {
                Name        = businessDomain.Name,
                Description = businessDomain.Description,
                SubDomains  = businessDomain.SubDomains.Select(x => new CreateSubDomain()
                {
                    Name             = x.Name,
                    Description      = x.Description,
                    ParentDomainName = businessDomain.Name
                }).ToList()
            };

            var response = await _mediator.Send(createDomain);

            if (response.Result == CreateResult.Created)
            {
                return(Created($"api/business-domains/{businessDomain.Name}", null));
            }
            else
            {
                return(StatusCode(500));
            }
        }
Пример #2
0
        public void SetData(string from, string to, DateRanges range = DateRanges.Custom)
        {
            fromDateString = from;
            fromDate       = BusinessDomain.GetDateValue(from);
            if (fromDate.Value != DateTime.MinValue)
            {
                fromDate = fromDate.Value.Date;
            }
            else
            {
                fromDate = null;
            }

            toDateString = to;
            toDate       = BusinessDomain.GetDateValue(to);
            if (toDate.Value != DateTime.MinValue)
            {
                toDate = toDate.Value.Date;
            }
            else
            {
                toDate = null;
            }

            timeRange = range;
        }
Пример #3
0
        public PaymentReceipt(Payment payment)
        {
            ReceiptDate = BusinessDomain.GetFormattedDate(payment.Date);
            long number = payment.Id;

            if (payment.ParentOperation == null)
            {
                payment.ParentOperation = Operation.GetById((OperationType)payment.OperationType, payment.OperationId);
            }
            if (payment.ParentOperation != null)
            {
                number = payment.ParentOperation.Id;
            }
            ReceiptNumber = number.ToString(CultureInfo.InvariantCulture).PadLeft(BusinessDomain.AppConfiguration.DocumentNumberLength, '0');

            FillRecipient(payment.PartnerId);
            FillSupplier();

            Location = payment.LocationName;

            double debt = 0;

            if (payment.ParentOperation != null)
            {
                debt = payment.ParentOperation.TotalPlusVAT;
            }

            Debt    = Currency.ToString(debt, PriceType.SaleTotal);
            Total   = payment.Quantity;
            Balance = Currency.ToString(-Partner.GetDebt(payment.PartnerId), PriceType.SaleTotal);
        }
        private bool ReLoadDatabases()
        {
            if (reloadingDatabases)
            {
                return(true);
            }

            dataBases = null;

            try {
                cboDatabase.Sensitive = false;
                btnOK.Sensitive       = false;
                reloadingDatabases    = true;
                cboDatabase.Load(new [] { Translator.GetString("Loading...") }, null, null, null);
                PresentationDomain.ProcessUIEvents();

                string dbProviderName = DbProvider;
                if (!BusinessDomain.TryConnect(dbProviderName, Server, SlaveServer, User, Password))
                {
                    cboDatabase.Load(new [] { Translator.GetString("None", "Database") }, null, null, null);
                    reloadingDatabases = false;
                    return(false);
                }

                DataHelper.FireAndForget(startedProvider =>
                {
                    try {
                        dataBases = BusinessDomain.GetDatabases();
                        // If the provider changed after we started to look for databases, don't show them
                        if (startedProvider != DbProvider)
                        {
                            return;
                        }

                        PresentationDomain.Invoke(() =>
                        {
                            bool hasDbs = dataBases.Length > 0;
                            if (hasDbs)
                            {
                                cboDatabase.Load(dataBases, null, null, BusinessDomain.AppConfiguration.DbDatabase);
                            }
                            else
                            {
                                cboDatabase.Load(new [] { Translator.GetString("None", "Database") }, null, null, null);
                            }
                            cboDatabase.Sensitive = hasDbs;
                            btnOK.Sensitive       = hasDbs;
                            reloadingDatabases    = false;
                        });
                    } catch {
                        cboDatabase.Load(new [] { Translator.GetString("None", "Database") }, null, null, null);
                        reloadingDatabases = false;
                    }
                }, dbProviderName);
                return(true);
            } catch (Exception ex) {
                ErrorHandling.LogException(ex);
                return(false);
            }
        }
Пример #5
0
        protected static string GetFieldText(DataType fieldType, object value)
        {
            switch (fieldType)
            {
            case DataType.Date:
                return(BusinessDomain.GetFormattedDate((DateTime)value));

            case DataType.DateTime:
                return(BusinessDomain.GetFormattedDateTime((DateTime)value));

            case DataType.Quantity:
                return(Quantity.ToEditString((double)value));

            case DataType.CurrencyIn:
                return(Currency.ToEditString((double)value, PriceType.Purchase));

            case DataType.CurrencyOut:
                return(Currency.ToEditString((double)value));

            case DataType.Currency:
                return(Currency.ToEditString((double)value, PriceType.Unknown));

            case DataType.Percent:
                return(Percent.ToEditString((double)value));

            default:
                return(value.ToString());
            }
        }
        public override DataQueryResult ExecuteReport(DataQuery dataQuery)
        {
            string    date = string.Empty;
            DataQuery qSet = dataQuery;

            foreach (DataFilter filter in qSet.Filters.Where(filter => filter.IsValid))
            {
                if (filter.FilteredFields.Any(field => field == DataField.OperationDate))
                {
                    date = BusinessDomain.GetFormattedDate((DateTime)filter.Values [0]);
                }

                if (!string.IsNullOrEmpty(date))
                {
                    break;
                }
            }

            if (string.IsNullOrEmpty(date))
            {
                date = BusinessDomain.GetFormattedDate(BusinessDomain.Today);
            }

            return(BusinessDomain.DataAccessProvider.ReportItemsAvailabilityAtDate(qSet, date));
        }
        private void OnDateChanged(Entry txtDate)
        {
            if (changingFilter)
            {
                return;
            }

            if (!txtDate.Sensitive)
            {
                return;
            }

            string value = txtDate.Text.Trim();

            if (value.Length > 0 &&
                BusinessDomain.GetDateValue(value) == DateTime.MinValue)
            {
                return;
            }

            int cursorPosition = txtDate.CursorPosition;

            OnFilterChanged(EventArgs.Empty);
            txtDate.GrabFocus();
            txtDate.SelectRegion(cursorPosition, cursorPosition);
        }
Пример #8
0
        public void CommitChanges(bool silent = false)
        {
            BusinessDomain.DataAccessProvider.AddUpdatePayment(this);

            if (!silent)
            {
                BusinessDomain.OnPaymentCommited(this);
            }
        }
Пример #9
0
        protected override void btnEdit_Clicked(object o, EventArgs args)
        {
            if (grid.Selection.Count <= 0)
            {
                MessageError.ShowDialog(Translator.GetString("Please select an operation to edit a payment of."), ErrorSeverity.Error);
                return;
            }

            Payment selectedPayment = entities [grid.Selection [0]];
            string  message;

            if (!BusinessDomain.CanEditPayment(selectedPayment, out message))
            {
                MessageError.ShowDialog(message);
                return;
            }

            selectedId = selectedPayment.Id;
            if (selectedPayment.OperationType == (int)OperationType.AdvancePayment)
            {
                using (new DbMasterScope(BusinessDomain.DataAccessProvider))
                    using (EditNewAdvancePayment dialog = new EditNewAdvancePayment(selectedPayment)) {
                        if (dialog.Run() != ResponseType.Ok || dialog.Payments.Count == 0)
                        {
                            return;
                        }

                        foreach (Payment payment in dialog.Payments)
                        {
                            payment.EditAdvance();
                        }

                        dialog.PrintPayments(dialog.Payments);
                        ReinitializeGrid(true, null);
                        return;
                    }
            }

            Operation operation = GetOperationOfSelectedPayment();

            if (operation == null)
            {
                return;
            }

            using (new DbMasterScope(BusinessDomain.DataAccessProvider))
                using (EditNewPayment dialog = new EditNewPayment(operation)) {
                    if (dialog.Run() != ResponseType.Ok)
                    {
                        return;
                    }

                    operation.CommitPayments();
                    dialog.PrintPayments(dialog.OriginalPayments, operation);
                    ReinitializeGrid(true, null);
                }
        }
Пример #10
0
        public override bool Validate(ValidateCallback callback, StateHolder state)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            if (sourceLocationId <= 0)
            {
                if (!callback(Translator.GetString("Source location cannot be empty!"), ErrorSeverity.Error, (int)ErrorCodes.SourceLocationEmpty, state))
                {
                    return(false);
                }
            }

            if (BusinessDomain.LoggedUser.LockedLocationId > 0 && BusinessDomain.LoggedUser.LockedLocationId != sourceLocationId)
            {
                if (!callback(Translator.GetString("The source location cannot be used!"), ErrorSeverity.Error, (int)ErrorCodes.SourceLocationCannotBeUsed, state))
                {
                    return(false);
                }
            }

            string error;
            string warning;

            if (!BusinessDomain.CanUseLocationInOperation(OperationType, sourceLocationId, out error, out warning))
            {
                if (error != null && !callback(error, ErrorSeverity.Error, (int)ErrorCodes.SourceLocationCannotBeUsed, state))
                {
                    return(false);
                }

                if (warning != null && !callback(error, ErrorSeverity.Warning, (int)ErrorCodes.SourceLocationCannotBeUsed, state))
                {
                    return(false);
                }
            }

            if (targetLocationId <= 0)
            {
                if (!callback(Translator.GetString("Target location cannot be empty!"), ErrorSeverity.Error, (int)ErrorCodes.TargetLocationEmpty, state))
                {
                    return(false);
                }
            }

            if (details.Any(d => d.Quantity.IsZero()))
            {
                if (!callback(Translator.GetString("Details contain zero quantities!"), ErrorSeverity.Error, (int)ErrorCodes.TargetLocationEmpty, state))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #11
0
 private void AddPayment(double amountReceived)
 {
     payments.Add(new Payment(operation, paymentWidget.GetPaymentTypeId(), PaymentMode.Paid)
     {
         Quantity = amountReceived,
         EndDate  = BusinessDomain.GetDateValue(txtDueDate.Text.Trim())
     });
     paymentWidget.RefreshGrid();
     RecalculateChange(paymentWidget.Received);
 }
Пример #12
0
 public override Report GetPrintData(string title)
 {
     return(new Report
     {
         ReportDetails = grid.ToDataTable(true),
         ReportHasFooter = TotalsShown,
         ReportDate = BusinessDomain.GetFormattedDate(BusinessDomain.Now),
         ReportName = title
     });
 }
Пример #13
0
        protected void OnRemainingDaysValueChanged(object sender, EventArgs args)
        {
            if (changingDueDate)
            {
                return;
            }

            changingDueDate = true;
            txtDueDate.Text = BusinessDomain.GetFormattedDate(GetDueDate().AddDays(spbRemainingDays.ValueAsInt));
            changingDueDate = false;
        }
 private static void ChooseDate(Entry txtDate)
 {
     using (ChooseDate chooseDate = new ChooseDate()) {
         if (chooseDate.Run() != ResponseType.Ok)
         {
             txtDate.GrabFocus();
             return;
         }
         txtDate.Text = BusinessDomain.GetFormattedDate(chooseDate.Selection);
     }
 }
Пример #15
0
 private static void ReinitializeHardware(Device oldItem, Device newItem)
 {
     BusinessDomain.ReinitializeHardware(oldItem, newItem,
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the cash receipt device. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the receipt device. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the external display. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the card reader device. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the electronic scale. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the sales data controller. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the kitchen printer. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the barcode scanner. Check the input parameters.")));
 }
Пример #16
0
        public void SetData(DateTime from, DateTime to, DateRanges range = DateRanges.Custom)
        {
            fromDateString = BusinessDomain.GetFormattedDate(from);
            fromTimeString = BusinessDomain.GetFormattedTime(from);
            fromDate       = from.Date;
            fromTime       = from.TimeOfDay;

            toDateString = BusinessDomain.GetFormattedDate(to);
            toTimeString = BusinessDomain.GetFormattedTime(to);
            toDate       = to.Date;
            toTime       = to.TimeOfDay;

            timeRange = range;
        }
        public override void ClearFilter()
        {
            FilterDateTimeRange f = (FilterDateTimeRange)filter;

            f.SetData(f.FromDate.Add(new TimeSpan(spbHoursFrom.ValueAsInt, spbMinutesFrom.ValueAsInt, 0)),
                      f.ToDate.Add(new TimeSpan(spbHoursTo.ValueAsInt, spbMinutesTo.ValueAsInt, 0)),
                      f.TimeRange);

            base.ClearFilter();

            txtFrom.Text = filter.FromDate == DateTime.MinValue ?
                           string.Empty : BusinessDomain.GetFormattedDate(filter.FromDate);
            txtTo.Text = filter.ToDate == DateTime.MinValue ?
                         string.Empty : BusinessDomain.GetFormattedDate(filter.ToDate);
        }
        private static bool ValidateDate(ref DateTime?date, Entry txtDate)
        {
            DateTime result = BusinessDomain.GetDateValue(txtDate.Text.Trim());

            if (result == DateTime.MinValue)
            {
                MessageError.ShowDialog(Translator.GetString("The entered date is invalid."), ErrorSeverity.Error);

                txtDate.GrabFocus();
                txtDate.SelectRegion(0, txtDate.Text.Length);
                return(false);
            }

            date = result;
            return(true);
        }
Пример #19
0
        protected override void btnAnnul_Clicked(object o, EventArgs args)
        {
            if (Message.ShowDialog(GetAnnulTitle(), string.Empty, GetAnnulQuestion(), "Icons.Question32.png",
                                   MessageButtons.YesNo) != ResponseType.Yes)
            {
                return;
            }

            string error;
            string warning;

            if (!BusinessDomain.CanAnnulOperation(SelectedItem, out error, out warning))
            {
                if (warning != null)
                {
                    if (MessageError.ShowDialog(warning, buttons: MessageButtons.YesNo) != ResponseType.Yes)
                    {
                        return;
                    }
                }
                else
                {
                    MessageError.ShowDialog(error);
                    return;
                }
            }

            try {
                AnnulOperation();
                GetEntities();
                grid.Model = entities;
                if (btnPreview.Active)
                {
                    previewWidget.LoadOperation(SelectedItem);
                }
            } catch (ArgumentException) {
            } catch (InsufficientItemAvailabilityException ex) {
                if (btnPreview.Active)
                {
                    previewWidget.LoadOperation(SelectedItem);
                }

                MessageError.ShowDialog(string.Format(Translator.GetString("The operation cannot be annulled " +
                                                                           "because the annulment will cause negative availability of item \"{0}\"."), ex.ItemName),
                                        ErrorSeverity.Warning, ex);
            }
        }
Пример #20
0
        private void InitializeEntries()
        {
            txtNumber.Text = document.NumberString;

            List <KeyValuePair <long, string> > paymentPairs = PaymentType.GetAll().Select(p => new KeyValuePair <long, string> (p.Id, p.Name)).ToList();

            if (IsEditable)
            {
                cboPaymentType.Load(paymentPairs, "Key", "Value", BusinessDomain.AppConfiguration.LastDocumentPaymentMethodId);
                Operation operation = operations.Last();
                cbeRecipient.Load(DocumentBase.GetRecipientSuggestions(operation.PartnerId), null, null);
                cbeEGN.Load(DocumentBase.GetEGNSuggestions(operation.PartnerId), null, null);
                cbeProvider.Load(DocumentBase.GetProviderSuggestions(), null, null);
                cbeReason.Load(DocumentBase.GetReasonSuggestions(), null, null);
                cbeDescription.Load(DocumentBase.GetDescriptionSuggestions(), null, null);
                cbeLocation.Load(DocumentBase.GetLocationSuggestions(), null, null);

                txtDate.Text    = BusinessDomain.GetFormattedDate(BusinessDomain.Today);
                txtTaxDate.Text = BusinessDomain.GetFormattedDate(operation.Date);
                Partner partner = Partner.GetById(partnerId);
                if (partner != null)
                {
                    lblPartnerValue.SetText(partner.Name);
                }
                txtNumber.GrabFocus();
            }
            else
            {
                txtRefNumber.Text = document.ReferenceNumberString;
                txtRefDate.Text   = document.ReferenceDateString;
                cboPaymentType.Load(paymentPairs, "Key", "Value", document.PaymentMethod);
                cbeRecipient.Entry.Text   = document.Recipient;
                cbeEGN.Entry.Text         = document.RecipientEGN;
                cbeProvider.Entry.Text    = document.Provider;
                cbeReason.Entry.Text      = document.Reason;
                cbeDescription.Entry.Text = document.Description;
                lblPartnerValue.SetText(document.RecipientName);
                cbeLocation.Entry.Text = document.Location;

                txtDate.Text            = document.DateString;
                txtTaxDate.Text         = document.TaxDateString;
                hboPartner.Sensitive    = false;
                fraMain.Sensitive       = false;
                fraAdditional.Sensitive = false;
            }
        }
Пример #21
0
        public ProductionProtocol(ComplexProduction production)
            : this()
        {
            ProtocolDate   = BusinessDomain.GetFormattedDate(production.Date);
            ProtocolNumber = production.FormattedOperationNumber;
            Note           = production.Note;

            CompanyRecord company = CompanyRecord.GetDefault();

            CompanyName         = company.Name;
            CompanyNumber       = company.Bulstat;
            CompanyCity         = company.City;
            CompanyAddress      = company.Address;
            CompanyTelephone    = company.Telephone;
            CompanyLiablePerson = company.LiablePerson;

            Location = production.Location2;

            double vat = production.VAT;

            if (BusinessDomain.AppConfiguration.VATIncluded)
            {
                Total        = Currency.ToString(production.Total - vat, PriceType.Purchase);
                Vat          = Currency.ToString(vat, PriceType.Purchase);
                TotalPlusVat = production.Total;
            }
            else
            {
                Total        = Currency.ToString(production.Total, PriceType.Purchase);
                Vat          = Currency.ToString(vat, PriceType.Purchase);
                TotalPlusVat = production.Total + vat;
            }

            int i = 1;

            foreach (ComplexProductionDetail detail in production.Details)
            {
                ProtocolDetailsMaterials.Add(new ProtocolDetail(i++, detail));
            }

            i = 1;
            foreach (ComplexProductionDetail detail in production.DetailsProd)
            {
                ProtocolDetailsProducts.Add(new ProtocolDetail(i++, detail));
            }
        }
Пример #22
0
        public StockTakingProtocol(StockTaking stockTaking)
            : this()
        {
            ProtocolDate   = BusinessDomain.GetFormattedDate(stockTaking.Date);
            ProtocolNumber = stockTaking.FormattedOperationNumber;
            Note           = stockTaking.Note;

            CompanyRecord company = CompanyRecord.GetDefault();

            CompanyName         = company.Name;
            CompanyNumber       = company.Bulstat;
            CompanyCity         = company.City;
            CompanyAddress      = company.Address;
            CompanyTelephone    = company.Telephone;
            CompanyLiablePerson = company.LiablePerson;

            Location = stockTaking.Location2;

            double vat = stockTaking.VAT;

            if (BusinessDomain.AppConfiguration.VATIncluded)
            {
                Total        = Currency.ToString(stockTaking.Total - vat);
                Vat          = Currency.ToString(vat);
                TotalPlusVat = stockTaking.Total;
            }
            else
            {
                Total        = Currency.ToString(stockTaking.Total);
                Vat          = Currency.ToString(vat);
                TotalPlusVat = stockTaking.Total + vat;
            }

            int i = 1;

            foreach (StockTakingDetail detail in stockTaking.Details)
            {
                StockTakingProtocolDetail stockTakingProtocolDetail = new StockTakingProtocolDetail(i++, detail, false);
                stockTakingProtocolDetail.ExpectedQuantity = Quantity.ToString(detail.ExpectedQuantity);
                stockTakingProtocolDetail.EnteredQuantity  = Quantity.ToString(detail.EnteredQuantity);
                StockTakingProtocolDetails.Add(stockTakingProtocolDetail);
            }

            TotalQuantity = Quantity.ToString(stockTaking.Details.Sum(d => d.EnteredQuantity));
        }
Пример #23
0
        private void btnNew_Clicked(object sender, EventArgs e)
        {
            if (!BusinessDomain.TryConnect(DbProvider, Server, SlaveServer, User, Password))
            {
                MessageError.ShowDialog(Translator.GetString("The connection to the server was not successful!"),
                                        "Icons.Database32.png");
                return;
            }

            CreateDatabaseType dbType;

            using (NewDatabase dlgNewDB = new NewDatabase()) {
                ResponseType response = dlgNewDB.Run();
                if (response == ResponseType.Apply)
                {
                    BusinessDomain.AppConfiguration.DbDatabase = dlgNewDB.DatabaseName;
                    ReLoadDatabases();
                }

                if (response != ResponseType.Ok)
                {
                    return;
                }

                dbType = dlgNewDB.DatabaseType;

                // Set the new database as the only one as at this point we are closing the dialog and we don't nee the full list
                cboDatabase.Load(new [] { dlgNewDB.DatabaseName }, null, null, null);
            }

            // Unclutter the screen by hiding the background dialog which is no longer needed anyway
            dlgEditDBConnection.Hide();
            if (dbType == CreateDatabaseType.Blank)
            {
                SetSettings();
                BusinessDomain.AppConfiguration.Load(false);

                using (Assistant assistant = new Assistant(AssistType.DatabaseSetup))
                    assistant.Run();

                BusinessDomain.AppConfiguration.Save(true);
            }

            dlgEditDBConnection.Respond(ResponseType.Ok);
        }
Пример #24
0
        protected void OnDueDateChanged(object o, EventArgs args)
        {
            if (changingDueDate)
            {
                return;
            }

            DateTime date = BusinessDomain.GetDateValue(txtDueDate.Text.Trim());

            if (date == DateTime.MinValue)
            {
                return;
            }

            changingDueDate        = true;
            spbRemainingDays.Value = (date - GetDueDate()).Days;
            changingDueDate        = false;
        }
Пример #25
0
        public WasteProtocol(Waste waste)
            : this()
        {
            ProtocolDate   = BusinessDomain.GetFormattedDate(waste.Date);
            ProtocolNumber = waste.FormattedOperationNumber;
            Note           = waste.Note;

            CompanyRecord company = CompanyRecord.GetDefault();

            CompanyName         = company.Name;
            CompanyNumber       = company.Bulstat;
            CompanyCity         = company.City;
            CompanyAddress      = company.Address;
            CompanyTelephone    = company.Telephone;
            CompanyLiablePerson = company.LiablePerson;

            Location = waste.Location2;
            bool      usePriceIn = !BusinessDomain.LoggedUser.HideItemsPurchasePrice;
            PriceType priceType  = usePriceIn ? PriceType.PurchaseTotal : PriceType.SaleTotal;

            double vat = waste.VAT;

            if (BusinessDomain.AppConfiguration.VATIncluded)
            {
                Total        = Currency.ToString(waste.Total - vat, priceType);
                Vat          = Currency.ToString(vat, priceType);
                TotalPlusVat = waste.Total;
            }
            else
            {
                Total        = Currency.ToString(waste.Total, priceType);
                Vat          = Currency.ToString(vat, priceType);
                TotalPlusVat = waste.Total + vat;
            }

            int i = 1;

            foreach (WasteDetail detail in waste.Details)
            {
                ProtocolDetails.Add(new ProtocolDetail(i++, detail, usePriceIn));
            }

            TotalQuantity = Quantity.ToString(waste.Details.Sum(d => d.Quantity));
        }
Пример #26
0
        public PurchaseReceipt(Purchase purchase)
            : this()
        {
            ReceiptDate   = BusinessDomain.GetFormattedDate(purchase.Date);
            ReceiptNumber = purchase.FormattedOperationNumber;
            Note          = purchase.Note;

            Invoice invoice = Invoice.GetReceivedForOperation(purchase.Id);

            if (invoice != null)
            {
                InvoiceDate   = invoice.DateString;
                InvoiceNumber = invoice.NumberString;
            }

            FillRecipient();
            FillSupplier(purchase.PartnerId);

            Location = purchase.Location2;

            double vat = purchase.VAT;

            if (BusinessDomain.AppConfiguration.VATIncluded)
            {
                Total        = purchase.Total - vat;
                Vat          = Currency.ToString(vat, PriceType.Purchase);
                TotalPlusVat = purchase.Total;
            }
            else
            {
                Total        = purchase.Total;
                Vat          = Currency.ToString(vat, PriceType.Purchase);
                TotalPlusVat = purchase.Total + vat;
            }

            int i = 1;

            foreach (PurchaseDetail detail in purchase.Details)
            {
                ReceiptDetails.Add(new ReceiptDetail(i++, detail));
            }

            TotalQuantity = Quantity.ToString(purchase.Details.Sum(d => d.Quantity));
        }
Пример #27
0
 private void SetDocumentFields()
 {
     document.Number = long.Parse(txtNumber.Text);
     document.Date   = BusinessDomain.GetDateValue(txtDate.Text);
     if (txtRefNumber.Visible)
     {
         document.ReferenceNumber = long.Parse(txtRefNumber.Text);
     }
     document.ReferenceDate       = BusinessDomain.GetDateValue(txtRefDate.Text);
     document.Description         = cbeDescription.Entry.Text;
     document.Location            = cbeLocation.Entry.Text;
     document.TaxDate             = BusinessDomain.GetDateValue(txtTaxDate.Text);
     document.Reason              = cbeReason.Entry.Text;
     document.PaymentMethod       = (long)cboPaymentType.GetSelectedValue();
     document.PaymentMethodString = cboPaymentType.GetSelectedText();
     document.Recipient           = cbeRecipient.Entry.Text;
     document.RecipientEGN        = cbeEGN.Entry.Text;
     document.Provider            = cbeProvider.Entry.Text;
 }
Пример #28
0
        public TransferReceipt(Transfer transfer)
            : this()
        {
            ReceiptDate   = BusinessDomain.GetFormattedDate(transfer.Date);
            ReceiptNumber = transfer.FormattedOperationNumber;
            Note          = transfer.Note;

            FillSupplier();

            SourceLocation = transfer.SourceLocation2;
            TargetLocation = transfer.TargetLocation2;
            Transfer clone = transfer.Clone <Transfer, TransferDetail> ();

            if (BusinessDomain.AppConfiguration.AlwaysPrintTransfersUsingSalePrices)
            {
                clone.SetUsePriceIn(false);
            }

            int i = 1;

            foreach (TransferDetail detail in clone.Details)
            {
                detail.TotalEvaluate();
                ReceiptDetails.Add(new ReceiptDetail(i++, detail, clone.GetUsePriceIn()));
            }

            double vat = clone.VAT;

            if (BusinessDomain.AppConfiguration.VATIncluded)
            {
                Total        = Currency.ToString(clone.Total - vat, clone.TotalsPriceType);
                Vat          = Currency.ToString(vat, clone.TotalsPriceType);
                TotalPlusVat = clone.Total;
            }
            else
            {
                Total        = Currency.ToString(clone.Total, clone.TotalsPriceType);
                Vat          = Currency.ToString(vat, clone.TotalsPriceType);
                TotalPlusVat = clone.Total + vat;
            }

            TotalQuantity = Quantity.ToString(clone.Details.Sum(d => d.Quantity));
        }
Пример #29
0
        private bool ValidateDate()
        {
            DateTime date = BusinessDomain.GetDateValue(txtDueDate.Text.Trim());

            if (date == DateTime.MinValue)
            {
                MessageError.ShowDialog(Translator.GetString("The entered date is invalid."), ErrorSeverity.Error);
                txtDueDate.GrabFocus();
                return(false);
            }

            if (date >= operation.Date)
            {
                return(true);
            }

            ShowMessageTooEarlyDate();
            return(false);
        }
Пример #30
0
        protected void btnDateReport_Clicked(object o, EventArgs args)
        {
            DateTime dtStart = BusinessDomain.GetDateValue(txtDateFrom.Text);

            if (dtStart == DateTime.MinValue)
            {
                txtDateFrom.SelectRegion(0, txtDateFrom.Text.Length);
                return;
            }

            DateTime dtEnd = BusinessDomain.GetDateValue(txtDateTo.Text);

            if (dtEnd == DateTime.MinValue)
            {
                txtDateTo.SelectRegion(0, txtDateTo.Text.Length);
                return;
            }

            if (dtEnd < dtStart)
            {
                MessageError.ShowDialog(
                    Translator.GetString("The end date must be after the start date!"),
                    ErrorSeverity.Error);
                return;
            }

            FormHelper.TryReceiptPrinterCommand(delegate
            {
                BusinessDomain.DeviceManager.TryDeviceCommand(delegate
                {
                    if (rbnDateReport.Active)
                    {
                        cashReceiptDriver.ShortFMReportByDates(dtStart, dtEnd);
                    }
                    else if (rbnDateDetailReport.Active)
                    {
                        cashReceiptDriver.DetailFMReportByDates(dtStart, dtEnd);
                    }
                });
            });
        }