コード例 #1
0
        private void ExecuteBalance()
        {
            ActualBill = this.BindingContext as DataContracts.Model.Bill;
            ActualBill.DiscountAmount     = 0;
            ActualBill.TaxesToPay         = 0;
            ActualBill.TotalAfterDiscount = 0;
            ActualBill.TotalToPay         = 0;
            ActualBill.SubTotalProducts   = 0;

            foreach (var parsedProduct in ActualBill.SoldProductsJSON.ClientProducts)
            {
                if (parsedProduct == null || parsedProduct.ProductQuantity == 0)
                {
                }
                else
                {
                    parsedProduct.TotalCost      = parsedProduct.ProductQuantity * parsedProduct.Price;
                    ActualBill.SubTotalProducts += parsedProduct.TotalCost;
                }
            }
            //We need to apply a discount
            if (ActualBill.SoldProductsJSON.DefaultDiscountPercentage != 0)
            {
                ActualBill.DiscountAmount = (ActualBill.SubTotalProducts / 100) * ActualBill.SoldProductsJSON.DefaultDiscountPercentage;
            }

            ActualBill.TotalAfterDiscount = ActualBill.SubTotalProducts - ActualBill.DiscountAmount;

            if (ActualBill.SoldProductsJSON.DefaultTaxesPercentage != 0)
            {
                ActualBill.TaxesToPay = (ActualBill.TotalAfterDiscount / 100) * ActualBill.SoldProductsJSON.DefaultTaxesPercentage;
            }
            ActualBill.TotalToPay = ActualBill.TaxesToPay + ActualBill.TotalAfterDiscount;

            //Setting Amounts

            TotalProducts.Text = "₡" + Utils.Utils.FormatNumericToString(ActualBill.SubTotalProducts);


            DescountAmountLabel.Text = string.Format("-Descuento({0}%)", ActualBill.SoldProductsJSON.DefaultDiscountPercentage);
            DescountAmount.Text      = "₡" + Utils.Utils.FormatNumericToString(ActualBill.DiscountAmount);

            TotalAfterDescount.Text = "₡" + Utils.Utils.FormatNumericToString(ActualBill.TotalAfterDiscount);


            TaxesAmountLabel.Text = string.Format("+Impuestos({0}%)", ActualBill.SoldProductsJSON.DefaultTaxesPercentage);
            TaxesAmount.Text      = "₡" + Utils.Utils.FormatNumericToString(ActualBill.TaxesToPay);

            Total.Text = "₡" + Utils.Utils.FormatNumericToString(ActualBill.TotalToPay) + " cols";


            if (ActualBill.SubTotalProducts != 0)
            {
                Button_CreateBill.IsVisible = true;
            }
            else
            {
                Button_CreateBill.IsVisible = false;
            }
        }
コード例 #2
0
        public BillDetail(DataContracts.Model.Bill pCurrentBill)
        {
            pCurrentBill.DiscountNature = pCurrentBill.SoldProductsJSON.DiscountNature;
            pCurrentBill.TaxCode        = pCurrentBill.SoldProductsJSON.TaxCode;
            InitializeComponent();
            ActualBill = pCurrentBill;

            /* StatusPicker.ItemsSource = Enum.GetNames(typeof(Model.BillStatus));
             * StatusPicker.SelectedItem = pCurrentBill.Status;
             * StatusPicker.SelectedIndexChanged += SetStatusClicked;*/
            this.BindingContext           = ActualBill;
            ProductListView.HeightRequest = pCurrentBill.SoldProductsJSON.ClientProducts.Count * 60;


            if (pCurrentBill.Status.Equals(Model.BillStatus.Error.ToString()))
            {
                Button_RetryBill.IsEnabled = true;
                Button_RetryBill.IsVisible = true;
            }
            if (pCurrentBill.Status.Equals(Model.BillStatus.Processing.ToString()))
            {
                Button_RetryBillStatus.IsEnabled = true;
                Button_RetryBillStatus.IsVisible = true;
            }
        }
コード例 #3
0
        private async void Button_RetryBill_Clicked(object sender, EventArgs e)
        {
            App.ShowLoading(true);
            ActualBill = this.BindingContext as DataContracts.Model.Bill;
            ActualBill.EmissionDate = null;
            ActualBill.LastSendDate = null;
            ActualBill.ClientId     = ActualBill.SoldProductsJSON.ClientId;
            try
            {
                // Remove Unused Products
                ActualBill.SoldProductsJSON.RemoveProductsWithoutQuantity();

                var vRetryBillProxy = new BusinessProxy.Bill.TryToBillWithHacienda();
                var vBillRequest    = new BusinessProxy.Models.BillRequest
                {
                    SSOT       = App.SSOT,
                    User       = App.ActualUser,
                    ClientBill = ActualBill,
                };
                var vRetryResponse = await vRetryBillProxy.GetDataAsync(vBillRequest);

                // For testing
                var jsonTEST = Newtonsoft.Json.JsonConvert.SerializeObject(vBillRequest);
                if (vRetryResponse != null)
                {
                    if (vRetryResponse.IsSuccessful)
                    {
                        App.ShowLoading(false);

                        Button_RetryBill.IsEnabled = false;
                        Button_RetryBill.IsVisible = false;

                        await Toasts.ToastRunner.ShowSuccessToast("", "Se ha podido enviar con éxito");
                    }
                    else
                    {
                        App.ShowLoading(false);
                        await DisplayAlert("",
                                           string.IsNullOrEmpty(vRetryResponse.TechnicalMessage)?
                                           vRetryResponse.UserMessage : vRetryResponse.TechnicalMessage, "Ok");

                        //await Toasts.ToastRunner.ShowErrorToast("Sistema", vRetryResponse.UserMessage);
                        //await DisplayAlert("", vRetryResponse.TechnicalMessage, "Ok");
                    }
                    EditorSystemMessage.Text = vRetryResponse.UserMessage;
                }
                else
                {
                    App.ShowLoading(false);
                    await DisplayAlert("", "Respuesta Null", "Ok");
                }
            }
            catch (Exception ex)
            {
                await Toasts.ToastRunner.ShowErrorToast("Sistema", ex.Message);
            }
        }
コード例 #4
0
 public AddBill(DataContracts.Model.Bill pClient)
 {
     pClient.DiscountNature = pClient.SoldProductsJSON.DiscountNature;
     pClient.TaxCode        = pClient.SoldProductsJSON.TaxCode;
     InitializeComponent();
     this.BindingContext = pClient;
     if (pClient.SoldProductsJSON != null && pClient.SoldProductsJSON.ClientProducts != null && pClient.SoldProductsJSON.ClientProducts.Any())
     {
         ProductListView.HeightRequest = pClient.SoldProductsJSON.ClientProducts.Count * 60;
     }
 }
コード例 #5
0
        private async void Generate_Bill(object sender, EventArgs e)
        {
            App.ShowLoading(true);
            ActualBill = this.BindingContext as DataContracts.Model.Bill;
            ActualBill.EmissionDate = null;
            ActualBill.LastSendDate = null;
            ActualBill.ClientId     = ActualBill.SoldProductsJSON.ClientId;
            try
            {
                // Remove Unused Products
                ActualBill.SoldProductsJSON.RemoveProductsWithoutQuantity();

                var vCreateUserBills = new BusinessProxy.Bill.CreateBill();
                var vBillRequest     = new BusinessProxy.Models.BillRequest
                {
                    SSOT       = App.SSOT,
                    User       = App.ActualUser,
                    ClientBill = ActualBill,
                };
                // For testing
                var jsonTEST             = Newtonsoft.Json.JsonConvert.SerializeObject(vBillRequest);
                var vCreateBillsResponse = await vCreateUserBills.GetDataAsync(vBillRequest);


                if (vCreateBillsResponse != null)
                {
                    if (vCreateBillsResponse.IsSuccessful)
                    {
                        App.ShowLoading(false);
                        if (vCreateBillsResponse.PdfInvoice != null)
                        {
                            DependencyService.Get <IReportingService>().SaveAndOpenFile("Factura" + vCreateBillsResponse.BillNumber + ".pdf",
                                                                                        vCreateBillsResponse.PdfInvoice);
                        }

                        await Navigation.PopToRootAsync();

                        await Toasts.ToastRunner.ShowSuccessToast("Sistema",
                                                                  string.IsNullOrEmpty(vCreateBillsResponse.UserMessage)?"Se procesará la solicitud de la factura N°" + vCreateBillsResponse.BillNumber : vCreateBillsResponse.UserMessage
                                                                  );
                    }
                    else
                    {
                        App.ShowLoading(false);
                        //await Toasts.ToastRunner.ShowErrorToast("Sistema", vCreateBillsResponse.UserMessage);
                        await DisplayAlert("", string.IsNullOrEmpty(vCreateBillsResponse.UserMessage)?
                                           vCreateBillsResponse.TechnicalMessage : vCreateBillsResponse.UserMessage, "Ok");

                        await Navigation.PopToRootAsync();
                    }
                }
                else
                {
                    App.ShowLoading(false);
                    await DisplayAlert("", "Respuesta Null", "Ok");
                }
            }
            catch (Exception vEx)
            {
                await DisplayAlert("Error", vEx.ToString(), "Ok");
            }
        }