Exemplo n.º 1
0
 private static ISequenceStartingWithOne <Invoice> CreditInvoiceNonAssociatedForForeignCompany()
 {
     return(SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create(
                                                       new Invoice(CreditInvoice.Create(
                                                                       info: CreateInvoiceInfo(),
                                                                       revenueItems: SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create(
                                                                                                                                NegativeRevenue.Create(NegativeAmount.Create(-88.50m).Success.Get(), NonPositiveAmount.Create(-11.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Products)).Success.Get(),
                                                                                                                                NegativeRevenue.Create(NegativeAmount.Create(-88.50m).Success.Get(), NonPositiveAmount.Create(-11.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Services)).Success.Get(),
                                                                                                                                NegativeRevenue.Create(NegativeAmount.Create(-88.50m).Success.Get(), NonPositiveAmount.Create(-11.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Other)).Success.Get()
                                                                                                                                )),
                                                                       payments: NonEmptyEnumerable.Create(
                                                                           NegativePayment.Create(NegativeAmount.Create(-100m).Success.Get(), PaymentType.Cash).Success.Get(),
                                                                           NegativePayment.Create(NegativeAmount.Create(-100m).Success.Get(), PaymentType.OnCredit).Success.Get(),
                                                                           NegativePayment.Create(NegativeAmount.Create(-100m).Success.Get(), PaymentType.DomesticPaymentsAccountNumber).Success.Get()
                                                                           ),
                                                                       counterPart: CreateInvoiceParty(Countries.Greece, "090701900", address: new Address(postalCode: NonEmptyString.CreateUnsafe("12"), city: NonEmptyString.CreateUnsafe("City")))
                                                                       ).Success.Get())
                                                       )));
 }
Exemplo n.º 2
0
        private async void EndPurchase()
        {
            IRestDataMapper mapper = containerExtension.Resolve <IRestDataMapper>();

            CurrenPurchase.recordState = ConstValues.RCS_FINE;
            _ = await PurchaseRestService.UpdatePurchaseAsync(mapper, CurrenPurchase);

            if (CurrenPurchase.creditAmount > 0.00m)
            {
                CurrenPurchase.invoiceType = ConstValues.INVT_CREDIT;
                CreditInvoice = CreditInvoice.CreateNewCreditInvoice(branch, loggedUser.LoggedUser, CurrenPurchase);
                SelectedSupplier.supplierCreditAccount.totalCredit += CurrenPurchase.creditAmount;
                _ = await SupplierCreditRestService.updateSupplierCreditAccountAsync(mapper, SelectedSupplier.supplierCreditAccount);

                _ = await SupplierCreditRestService.CreateSupplierCreditInvoiceAsync(mapper, CreditInvoice);
            }
            if (CurrenPurchase.payAmount > 0.00m)
            {
                CurrenCashBook = CurrenCashBook.CreateNewCashBook(branch, loggedUser.LoggedUser, CurrenPurchase);
                CurrenCashBook.branchAccount = SelectedBac;
                _ = await FinancialRestService.CreateCashBookAsync(mapper, CurrenCashBook);
            }
            if (CurrenPurchase.chqAmount > 0.00m)
            {
                CurrenChqueBook = CurrenChqueBook.CreateNewChequeBook(branch, loggedUser.LoggedUser, CurrenPurchase);
                CurrenChqueBook.branchAccount = SelectedBac;
                _ = await FinancialRestService.CreateChequeBookAsync(mapper, CurrenChqueBook);
            }
            SelectedStore       = null;
            SelectedUom         = null;
            SelectedItem        = null;
            SelectedItmCt       = null;
            CurrentPurchaseItem = null;
            CurrenPurchase      = null;
            SelectedSupCt       = null;
            SelectedSupplier    = null;
            CreditInvoice       = null;
            CurrenCashBook      = null;
            CurrenChqueBook     = null;
            PurchaseItems.Clear();
            Initialize();
        }
Exemplo n.º 3
0
        public async Task ValidNegativeInvoiceWorks()
        {
            // Arrange
            var client = new AadeClient(UserId, UserSubscriptionKey, AadeEnvironment.Sandbox);

            // Act

            // Step 1 - regular invoice
            var country  = Countries.Greece;
            var invoices = SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create(
                                                                      new Invoice(SalesInvoice.Create(
                                                                                      info: AadeTestInvoicesData.CreateInvoiceInfo(invoiceSerialNumber: "50021"),
                                                                                      revenueItems: SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create(
                                                                                                                                               NonNegativeRevenue.Create(NonNegativeAmount.Create(88.50m).Success.Get(), NonNegativeAmount.Create(11.50m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat13, RevenueType.Products)).Success.Get(),
                                                                                                                                               NonNegativeRevenue.Create(NonNegativeAmount.Create(88.50m).Success.Get(), NonNegativeAmount.Create(11.50m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat13, RevenueType.Services)).Success.Get(),
                                                                                                                                               NonNegativeRevenue.Create(NonNegativeAmount.Create(88.50m).Success.Get(), NonNegativeAmount.Create(11.50m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat13, RevenueType.Other)).Success.Get()
                                                                                                                                               )),
                                                                                      payments: NonEmptyEnumerable.Create(
                                                                                          NonNegativePayment.Create(NonNegativeAmount.Create(100m).Success.Get(), PaymentType.Cash).Success.Get(),
                                                                                          NonNegativePayment.Create(NonNegativeAmount.Create(100m).Success.Get(), PaymentType.OnCredit).Success.Get(),
                                                                                          NonNegativePayment.Create(NonNegativeAmount.Create(100m).Success.Get(), PaymentType.DomesticPaymentsAccountNumber).Success.Get()
                                                                                          ),
                                                                                      counterpart: AadeTestInvoicesData.CreateInvoiceParty(country, "090701900")
                                                                                      ).Success.Get())
                                                                      ));

            var response = await client.SendInvoicesAsync(invoices);

            Assert.True(response.SendInvoiceResults.IsSuccess);
            Assert.All(response.SendInvoiceResults.Success.Get().Values, result => Assert.True(result.Value.IsSuccess));

            // We need to wait some time to allow external system to store the mark from the first call
            await Task.Delay(1000);

            // Step 2 - negative invoice
            var correlatedInvoice = response.SendInvoiceResults.Success.Get().Values.First().Value.Success.InvoiceRegistrationNumber.Value;

            var negativeInvoice = SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create(
                                                                             new Invoice(CreditInvoice.Create(
                                                                                             correlatedInvoice: correlatedInvoice,
                                                                                             info: AadeTestInvoicesData.CreateInvoiceInfo(invoiceSerialNumber: "50021"),
                                                                                             revenueItems: SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create(
                                                                                                                                                      NegativeRevenue.Create(NegativeAmount.Create(-53.65m).Success.Get(), NonPositiveAmount.Create(-12.88m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat6, RevenueType.Products)).Success.Get(),
                                                                                                                                                      NegativeRevenue.Create(NegativeAmount.Create(-53.65m).Success.Get(), NonPositiveAmount.Create(-12.88m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat6, RevenueType.Services)).Success.Get(),
                                                                                                                                                      NegativeRevenue.Create(NegativeAmount.Create(-53.65m).Success.Get(), NonPositiveAmount.Create(-12.88m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat6, RevenueType.Other)).Success.Get()
                                                                                                                                                      )),
                                                                                             payments: NonEmptyEnumerable.Create(
                                                                                                 NegativePayment.Create(NegativeAmount.Create(-133.06m).Success.Get(), PaymentType.Cash).Success.Get(),
                                                                                                 NegativePayment.Create(NegativeAmount.Create(-66.53m).Success.Get(), PaymentType.DomesticPaymentsAccountNumber).Success.Get()
                                                                                                 ),
                                                                                             counterPart: AadeTestInvoicesData.CreateInvoiceParty(country, "090701900", address: new Address(postalCode: NonEmptyString.CreateUnsafe("12"), city: NonEmptyString.CreateUnsafe("City")))
                                                                                             ).Success.Get())
                                                                             ));

            var negativeInvoiceResponse = await client.SendInvoicesAsync(negativeInvoice);

            // Assert
            Assert.True(negativeInvoiceResponse.SendInvoiceResults.IsSuccess);
            Assert.All(negativeInvoiceResponse.SendInvoiceResults.Success.Get().Values, result => Assert.True(result.Value.IsSuccess));
        }