private ModificationInvoice CreateModificationInvoice(InvoiceNumber originalDocumentNumber, Receiver receiver) { var nowUtc = DateTime.UtcNow.Date; var item1Amount = new Amount(net: new AmountValue(-1694.92m), gross: new AmountValue(-2000), tax: new AmountValue(-305.08m)); var item2Amount = new Amount(new AmountValue(-2362.20m), new AmountValue(-3000), new AmountValue(-637.8m)); var item3Amount = new Amount(new AmountValue(-952.38m), new AmountValue(-1000), new AmountValue(-47.62m)); var unitAmount1 = new ItemAmounts(item1Amount, item1Amount, 0.18m); var unitAmount2 = new ItemAmounts(item2Amount, item2Amount, 0.27m); var unitAmount3 = new ItemAmounts(item3Amount, item3Amount, 0.05m); var items = new[] { new InvoiceItem( consumptionDate: nowUtc, totalAmounts: new ItemAmounts(item1Amount, item1Amount, 0.18m), description: Description.Create("Item 1 description").Success.Get(), measurementUnit: MeasurementUnit.Night, quantity: -1, unitAmounts: unitAmount1, exchangeRate: ExchangeRate.Create(1).Success.Get() ), new InvoiceItem( consumptionDate: nowUtc, totalAmounts: new ItemAmounts(item2Amount, item2Amount, 0.27m), description: Description.Create("Item 2 description").Success.Get(), measurementUnit: MeasurementUnit.Night, quantity: -1, unitAmounts: unitAmount2, exchangeRate: ExchangeRate.Create(1).Success.Get() ), new InvoiceItem( consumptionDate: nowUtc, totalAmounts: new ItemAmounts(item3Amount, item3Amount, 0.05m), description: Description.Create("Item 3 description").Success.Get(), measurementUnit: MeasurementUnit.Night, quantity: -1, unitAmounts: unitAmount3, exchangeRate: ExchangeRate.Create(1).Success.Get() ) }; return(new ModificationInvoice( number: InvoiceNumber.Create($"REBATE-{Guid.NewGuid()}").Success.Get(), supplierInfo: CreateSupplierInfo(), receiver: receiver, items: Sequence.FromPreordered(items, startIndex: 1).Get(), currencyCode: CurrencyCode.Create("EUR").Success.Get(), issueDate: nowUtc, paymentDate: nowUtc, itemIndexOffset: 3, modificationIndex: 1, modifyWithoutMaster: false, originalDocumentNumber: originalDocumentNumber, paymentMethod: PaymentMethod.Cash )); }
public async Task SendCorrectionCustomerInvoiceSucceeds() { var receiver = Receiver.Customer(); var invoiceNumber = InvoiceNumber.Create($"INVOICE-{Guid.NewGuid()}").Success.Get(); var sendInvoicesResult = await SendInvoices(receiver, invoiceNumber); await AssertInvoices(sendInvoicesResult); var sendModificationInvoicesResult = await SendModificationInvoices(receiver, originalInvoiceNumber : invoiceNumber); await AssertInvoices(sendModificationInvoicesResult); }
private Invoice CreateInvoice(Receiver receiver, InvoiceNumber invoiceNumber = null) { var nowUtc = DateTime.UtcNow.Date; var item1Amount = new Amount(net: new AmountValue(1694.92m), gross: new AmountValue(2000), tax: new AmountValue(305.08m)); var item2Amount = new Amount(new AmountValue(2362.20m), new AmountValue(3000), new AmountValue(637.8m)); var item3Amount = new Amount(new AmountValue(952.38m), new AmountValue(1000), new AmountValue(47.62m)); var unitAmount1 = new ItemAmounts(item1Amount, item1Amount, 0.18m); var unitAmount2 = new ItemAmounts(item2Amount, item2Amount, 0.27m); var unitAmount3 = new ItemAmounts(item3Amount, item3Amount, 0.05m); var items = new[] { new InvoiceItem( consumptionDate: nowUtc, totalAmounts: new ItemAmounts(item1Amount, item1Amount, 0.18m), description: Description.Create("Item 1 description").Success.Get(), measurementUnit: MeasurementUnit.Night, quantity: 1, unitAmounts: unitAmount1, exchangeRate: ExchangeRate.Create(1).Success.Get() ), new InvoiceItem( consumptionDate: nowUtc, totalAmounts: new ItemAmounts(item2Amount, item2Amount, 0.27m), description: Description.Create("Item 2 description").Success.Get(), measurementUnit: MeasurementUnit.Night, quantity: 1, unitAmounts: unitAmount2, exchangeRate: ExchangeRate.Create(1).Success.Get() ), new InvoiceItem( consumptionDate: nowUtc, totalAmounts: new ItemAmounts(item3Amount, item3Amount, 0.05m), description: Description.Create("Item 3 description").Success.Get(), measurementUnit: MeasurementUnit.Night, quantity: 1, unitAmounts: unitAmount3, exchangeRate: ExchangeRate.Create(1).Success.Get() ) }; return(new Invoice( number: invoiceNumber ?? InvoiceNumber.Create($"INVOICE-{Guid.NewGuid()}").Success.Get(), issueDate: nowUtc, supplierInfo: CreateSupplierInfo(), receiver: receiver, items: Sequence.FromPreordered(items, startIndex: 1).Get(), paymentDate: nowUtc, currencyCode: CurrencyCode.Create("EUR").Success.Get(), paymentMethod: PaymentMethod.Card )); }
public async Task SendCorrectionLocalCompanyInvoiceSucceeds() { var receiver = Receiver.LocalCompany( taxpayerId: TaxpayerIdentificationNumber.Create(Countries.Hungary, "10630433").Success.Get(), name: Name.Create("Hungarian test company ltd.").Success.Get(), address: CreateAddress(Countries.Hungary) ).Success.Get(); var invoiceNumber = InvoiceNumber.Create($"INVOICE-{Guid.NewGuid()}").Success.Get(); var sendInvoicesResult = await SendInvoices(receiver, invoiceNumber); await AssertInvoices(sendInvoicesResult); var sendModificationInvoiceResponse = await SendModificationInvoices(receiver, originalInvoiceNumber : invoiceNumber); await AssertInvoices(sendModificationInvoiceResponse); }
public async Task SendCorrectionForeignCompanyInvoiceSucceeds(string countryCode, string taxId) { var country = Countries.GetByCode(countryCode).Get(); var taxpayerNumber = taxId.ToNonEmptyOption().Map(i => TaxpayerIdentificationNumber.Create(country, i).Success.Get()); var receiver = Receiver.ForeignCompany( name: Name.Create("Foreign test company ltd.").Success.Get(), address: CreateAddress(country), taxpayerId: taxpayerNumber.GetOrNull() ).Success.Get(); var invoiceNumber = InvoiceNumber.Create($"INVOICE-{Guid.NewGuid()}").Success.Get(); var sendInvoicesResult = await SendInvoices(receiver, invoiceNumber); await AssertInvoices(sendInvoicesResult); var sendModificationInvoiceResponse = await SendModificationInvoices(receiver, originalInvoiceNumber : invoiceNumber); await AssertInvoices(sendModificationInvoiceResponse); }
private ModificationInvoice GetModificationInvoice() { var amounts = GetItemAmounts(amount: 100, exchangeRate: 300); var unitAmounts = GetItemAmounts(amount: 100, exchangeRate: 300); var item = new InvoiceItem( consumptionDate: new DateTime(2020, 08, 30), totalAmounts: amounts, description: Description.Create("NIGHT 8/30/2020").Success.Get(), measurementUnit: MeasurementUnit.Night, quantity: -1, unitAmounts: unitAmounts, exchangeRate: ExchangeRate.Create(300).Success.Get() ); var amounts1 = GetItemAmounts(amount: 100, exchangeRate: 300); var unitAmounts1 = GetItemAmounts(amount: 100, exchangeRate: 300); var item1 = new InvoiceItem( consumptionDate: new DateTime(2020, 08, 31), totalAmounts: amounts1, description: Description.Create("NIGHT2 8/31/2020").Success.Get(), measurementUnit: MeasurementUnit.Night, quantity: 1, unitAmounts: unitAmounts1, exchangeRate: ExchangeRate.Create(300).Success.Get() ); return(new ModificationInvoice( number: InvoiceNumber.Create("ABC-18abfcefsaa").Success.Get(), supplierInfo: GetSupplierInfo(), customerInfo: GetCustomerInfo(), items: Sequence.FromPreordered(new[] { item, item1 }, startIndex: 1).Get(), currencyCode: CurrencyCode.Create("USD").Success.Get(), issueDate: new DateTime(2020, 08, 31), paymentDate: new DateTime(2020, 08, 31), itemIndexOffset: 4, modificationIndex: 4, modifyWithoutMaster: true, originalDocumentNumber: InvoiceNumber.Create("ABC-18afasadafa").Success.Get() )); }
private Invoice GetInvoice() { var item1Amount = new Amount(new AmountValue(1), new AmountValue(1), new AmountValue(0)); var item2Amount = new Amount(new AmountValue(20m), new AmountValue(16.81m), new AmountValue(3.19m)); var unitAmount1 = new ItemAmounts(item1Amount, item2Amount, 0.05m); var items = new[] { new InvoiceItem( consumptionDate: new DateTime(2020, 06, 30), totalAmounts: new ItemAmounts(item1Amount, item1Amount, 0.05m), description: Description.Create("Httt hzi serts (fl)").Success.Get(), measurementUnit: MeasurementUnit.Night, quantity: 15, unitAmounts: unitAmount1, exchangeRate: ExchangeRate.Create(1).Success.Get() ), new InvoiceItem( consumptionDate: new DateTime(2020, 06, 30), totalAmounts: new ItemAmounts(item2Amount, item2Amount, 0.05m), description: Description.Create("Httt hzi serts (fl)").Success.Get(), measurementUnit: MeasurementUnit.Night, quantity: -15, unitAmounts: unitAmount1, exchangeRate: ExchangeRate.Create(1).Success.Get() ), }; var address = GetAddress(); return(new Invoice( number: InvoiceNumber.Create("ABC-18a").Success.Get(), issueDate: new DateTime(2020, 06, 30), supplierInfo: GetSupplierInfo(), customerInfo: GetCustomerInfo(), items: Sequence.FromPreordered(items, startIndex: 1).Get(), paymentDate: new DateTime(2020, 06, 14), currencyCode: CurrencyCode.Create("EUR").Success.Get() )); }