diff --git a/src/bricklink/order.cpp b/src/bricklink/order.cpp index ac36e22a..e7c686b8 100755 --- a/src/bricklink/order.cpp +++ b/src/bricklink/order.cpp @@ -263,7 +263,9 @@ double Order::usSalesTax() const double Order::grandTotal() const { - return d->m_grandTotal; + // return d->m_grandTotal; // this is sometimes off by 1 cent + return orderTotal() + shipping() + insurance() + additionalCharges1() + additionalCharges2() + - credit() - creditCoupon() + usSalesTax(); } double Order::vatChargeSeller() const diff --git a/src/desktop/orderinformationdialog.cpp b/src/desktop/orderinformationdialog.cpp index 317431d2..c5b2bc2b 100755 --- a/src/desktop/orderinformationdialog.cpp +++ b/src/desktop/orderinformationdialog.cpp @@ -87,35 +87,51 @@ OrderInformationDialog::OrderInformationDialog(const BrickLink::Order *order, QW % order->paymentCurrencyCode()); } - static auto setVatLabel = [](QLabel *l, const BrickLink::Order *order, double vatCharge) { - double gt = order->grandTotal() + order->credit() + order->creditCoupon(); - double gtNet = gt - vatCharge; + bool vatFromSeller = !qFuzzyIsNull(order->vatChargeSeller()); + double vatCharge = vatFromSeller ? order->vatChargeSeller() : order->vatChargeBrickLink(); + bool hasVat = !qFuzzyIsNull(vatCharge); + double coupon = order->creditCoupon(); + double gtGross = order->grandTotal() + coupon; // see below for why creditCoupon is needed here + double gtNet = gtGross - vatCharge; + double vatPercent = Utility::roundTo(100 * (gtGross / (qFuzzyIsNull(gtNet) ? gtGross : gtNet) - 1.0), 0); - double p = Utility::roundTo(100 * (gt / (qFuzzyIsNull(gtNet) ? gt : gtNet) - 1.0), 1); - l->setText(l->text().arg(QLocale().toString(p, 'f', QLocale::FloatingPointShortest) % u'%')); - }; + if (!qFuzzyIsNull(coupon)) { + // the vatCharge values are wrong when a orderCoupon is active + // we can however re-calculate this value + double netFix = coupon * 100 / (100 + vatPercent); + gtNet -= netFix; + gtGross -= coupon; + vatCharge = gtGross - gtNet; + vatPercent = Utility::roundTo(100 * (gtGross / (qFuzzyIsNull(gtNet) ? gtGross : gtNet) - 1.0), 0); + } - setVatLabel(w_vatSellerLabel, order, order->vatChargeSeller()); - setVatLabel(w_vatBLLabel, order, order->vatChargeBrickLink()); + w_vatInfoLabel->setVisible(hasVat); + w_vatSeparator->setVisible(hasVat); + w_vatLabel->setText(w_vatLabel->text() + .arg(QLocale().toString(vatPercent, 'f', QLocale::FloatingPointShortest) % u'%') + .arg(vatFromSeller ? tr("Seller", "x% VAT (Seller)") + : tr("BrickLink", "x% VAT (BrickLink)"))); - setup(w_shipping, w_shippingCopy, Currency::toDisplayString(order->shipping(), { }, 2), - !qFuzzyIsNull(order->shipping()), w_shippingLabel); - setup(w_insurance, w_insuranceCopy, Currency::toDisplayString(order->insurance(), { }, 2), - !qFuzzyIsNull(order->insurance()), w_insuranceLabel); - setup(w_addCharges1, w_addCharges1Copy, Currency::toDisplayString(order->additionalCharges1(), { }, 2), + setup(w_shipping, w_shippingCopy, Currency::toDisplayString(order->shipping(), { }, 2), + !qFuzzyIsNull(order->shipping()), w_shippingLabel); + setup(w_insurance, w_insuranceCopy, Currency::toDisplayString(order->insurance(), { }, 2), + !qFuzzyIsNull(order->insurance()), w_insuranceLabel); + setup(w_addCharges1, w_addCharges1Copy, Currency::toDisplayString(order->additionalCharges1(), { }, 2), !qFuzzyIsNull(order->additionalCharges1()), w_addCharges1Label); - setup(w_addCharges2, w_addCharges2Copy, Currency::toDisplayString(order->additionalCharges2(), { }, 2), + setup(w_addCharges2, w_addCharges2Copy, Currency::toDisplayString(order->additionalCharges2(), { }, 2), !qFuzzyIsNull(order->additionalCharges2()), w_addCharges2Label); - setup(w_credit, w_creditCopy, Currency::toDisplayString(order->credit(), { }, 2), - !qFuzzyIsNull(order->credit()), w_creditLabel); - setup(w_creditCoupon, w_creditCouponCopy, Currency::toDisplayString(order->creditCoupon(), { }, 2), - !qFuzzyIsNull(order->creditCoupon()), w_creditCouponLabel); - setup(w_total, w_totalCopy, Currency::toDisplayString(order->orderTotal(), { }, 2)); - setup(w_salesTax, w_salesTaxCopy, Currency::toDisplayString(order->usSalesTax(), { }, 2), - !qFuzzyIsNull(order->usSalesTax()), w_salesTaxLabel); - setup(w_grandTotal, w_grandTotalCopy, Currency::toDisplayString(order->grandTotal(), { }, 2)); - setup(w_vatSeller, w_vatSellerCopy, Currency::toDisplayString(order->vatChargeSeller(), { }, 2), - !qFuzzyIsNull(order->vatChargeSeller()), w_vatSellerLabel); - setup(w_vatBL, w_vatBLCopy, Currency::toDisplayString(order->vatChargeBrickLink(), { }, 2), - !qFuzzyIsNull(order->vatChargeBrickLink()), w_vatBLLabel); + setup(w_credit, w_creditCopy, Currency::toDisplayString(order->credit(), { }, 2), + !qFuzzyIsNull(order->credit()), w_creditLabel); + setup(w_creditCoupon, w_creditCouponCopy, Currency::toDisplayString(order->creditCoupon(), { }, 2), + !qFuzzyIsNull(order->creditCoupon()), w_creditCouponLabel); + setup(w_total, w_totalCopy, Currency::toDisplayString(order->orderTotal(), { }, 2)); + setup(w_salesTax, w_salesTaxCopy, Currency::toDisplayString(order->usSalesTax(), { }, 2), + !qFuzzyIsNull(order->usSalesTax()), w_salesTaxLabel); + setup(w_grandTotal, w_grandTotalCopy, Currency::toDisplayString(order->grandTotal(), { }, 2)); + setup(w_grossGrandTotal, w_grossGrandTotalCopy, Currency::toDisplayString(gtGross, { }, 2), + hasVat, w_grossGrandTotalLabel); + setup(w_netGrandTotal, w_netGrandTotalCopy, Currency::toDisplayString(gtNet, { }, 2), + hasVat, w_netGrandTotalLabel); + setup(w_vat, w_vatCopy, Currency::toDisplayString(vatCharge, { }, 2), + hasVat, w_vatLabel); } diff --git a/src/desktop/orderinformationdialog.ui b/src/desktop/orderinformationdialog.ui index eb9e0799..01689245 100755 --- a/src/desktop/orderinformationdialog.ui +++ b/src/desktop/orderinformationdialog.ui @@ -6,8 +6,8 @@ 0 0 - 603 - 449 + 626 + 493 @@ -89,6 +89,7 @@ + 75 true @@ -155,6 +156,37 @@ + + + + 24 + + + QLayout::SetDefaultConstraint + + + + + Address + + + + + + + C + + + + .. + + + true + + + + + @@ -383,23 +415,27 @@ - - - - 24 - - - QLayout::SetDefaultConstraint + + + + Phone + + + + - + - Address + xxx + + + true - - + + C @@ -427,41 +463,6 @@ - - - - - - xxx - - - true - - - - - - - C - - - - .. - - - true - - - - - - - - - Phone - - - @@ -511,13 +512,54 @@ + + + Order Total + + + + + + + 0 + + + + + xxx + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + C + + + + .. + + + true + + + + + + Shipping - + 0 @@ -551,14 +593,14 @@ - + Insurance - + 0 @@ -592,14 +634,14 @@ - + Additional Charges 1 - + 0 @@ -633,14 +675,14 @@ - + Additional Charges 2 - + 0 @@ -674,14 +716,14 @@ - + Credit - + 0 @@ -715,14 +757,14 @@ - + Credit Coupon - + 0 @@ -756,20 +798,20 @@ - - + + - Order Total + Sales Tax - - + + 0 - + xxx @@ -782,7 +824,7 @@ - + C @@ -797,20 +839,36 @@ - - + + + + + 10 + 0 + + + + QFrame::Plain + + + Qt::Horizontal + + + + + - Sales Tax + Grand Total - - + + 0 - + xxx @@ -823,7 +881,7 @@ - + C @@ -838,20 +896,36 @@ - - + + + + + 75 + true + + + + QFrame::NoFrame + - Grand Total + VAT Information: - - + + + + Net Grand Total + + + + + 0 - + xxx @@ -864,7 +938,7 @@ - + C @@ -879,20 +953,20 @@ - - + + - %1 VAT Charge (Seller) + %1 VAT (%2) - + 0 - + xxx @@ -905,7 +979,7 @@ - + C @@ -920,20 +994,20 @@ - - + + - %1 VAT Charge (BrickLink) + Gross Grand Total - - + + 0 - + xxx @@ -946,7 +1020,7 @@ - + C @@ -961,6 +1035,16 @@ + + + + QFrame::HLine + + + + + + diff --git a/translations/brickstore_de.ts b/translations/brickstore_de.ts index e981d7e7..24ee4b63 100644 --- a/translations/brickstore_de.ts +++ b/translations/brickstore_de.ts @@ -1347,83 +1347,83 @@ BrickLink::Orders - + Address not available Adresse ist nicht verfügbar - + Cannot write order address to cache Konnte Adresse zur Bestellung nicht in den Cache schreiben - + Cannot save order to file Konnte Bestellung nicht in eine Datei speichern - + Cannot write order XML to cache Konnte die XML Daten der Bestellung nicht in den Cache schreiben - - + + Could not parse the received order XML data Konnte XML Daten nicht verarbeiten - + Cannot open order XML Konnte die XML Daten der Bestellung nicht laden - + Received Erhalten - + Placed Getätigt - + Date Datum - + Type Typ - + Status Status - + Order ID Bestellnr. - + Buyer/Seller Käufer/Verkäufer - + Items Teile - + Lots Posten - + Total Gesamt @@ -3582,7 +3582,7 @@ Bitte wählen Sie auch aus, welche Eigenschaften (z.B. Anmerkungen, Staffelpreis Download...<br>Zu <b>%p%</b> fertig<br>(%v von %m) - + Customize Toolbar... Werkzeugleiste anpassen... @@ -3636,84 +3636,103 @@ Bitte wählen Sie auch aus, welche Eigenschaften (z.B. Anmerkungen, Staffelpreis Status - + Last updated Letzte Aktualisierung - + Tracking Number Tracking Nummer - + Address Adresse - + Phone Telefon - + Currency Code Währung - + Shipping Versand - + Insurance Versicherung - + Additional Charges 1 Zusätzliche Kosten 1 - + Additional Charges 2 Zusätzliche Kosten 2 - + Credit Gutschrift - + Credit Coupon Gutschrift Coupon - + + VAT Information: + Mehrwertsteuer: + + + + Net Grand Total + Netto Gesamtbetrag + + + + %1 VAT (%2) + x% VAT (Seller or BrickLink) + %1 MwSt. (%2) + + + + Gross Grand Total + Brutto Gesamtbetrag + + + Order Total Bestellwert - + Sales Tax US "Sales Tax" - + Grand Total Gesamtbetrag - %1 VAT Charge (Seller) - %1 MwSt. (Verkäufer) + %1 MwSt. (Verkäufer) - %1 VAT Charge (BrickLink) - %1 MwSt. (BrickLink) + %1 MwSt. (BrickLink) VAT Charges @@ -3739,6 +3758,18 @@ Bitte wählen Sie auch aus, welche Eigenschaften (z.B. Anmerkungen, Staffelpreis Payment in Bezahlung in + + + Seller + x% VAT (Seller) + Verkäufer + + + + BrickLink + x% VAT (BrickLink) + BrickLink + OrderModel @@ -3750,82 +3781,82 @@ Bitte wählen Sie auch aus, welche Eigenschaften (z.B. Anmerkungen, Staffelpreis Orders - + Unknown - + Pending - + Updated - + Processing - + Ready - + Paid - + Packed - + Shipped - + Received Erhalten - + Completed - + OCR - + NPB - + NPX - + NRS - + NSS - + Cancelled diff --git a/translations/brickstore_en.ts b/translations/brickstore_en.ts index f6673b58..89913e29 100644 --- a/translations/brickstore_en.ts +++ b/translations/brickstore_en.ts @@ -1291,83 +1291,83 @@ BrickLink::Orders - + Address not available - + Cannot write order address to cache - + Cannot save order to file - + Cannot write order XML to cache - - + + Could not parse the received order XML data - + Cannot open order XML - + Received - + Placed - + Date - + Type - + Status - + Order ID - + Buyer/Seller - + Items - + Lots - + Total @@ -3100,7 +3100,7 @@ Please also select which item's attributes (e.g. remarks, tiered prices, .. - + Customize Toolbar... @@ -3154,83 +3154,94 @@ Please also select which item's attributes (e.g. remarks, tiered prices, .. - + Last updated - + Tracking Number - + Address - + Phone - + Currency Code - + Shipping - + Insurance - + Additional Charges 1 - + Additional Charges 2 - + Credit - + Credit Coupon - - Order Total + + VAT Information: - - Sales Tax + + Net Grand Total - - Grand Total + + %1 VAT (%2) + x% VAT (Seller or BrickLink) - - %1 VAT Charge (Seller) + + Gross Grand Total - - %1 VAT Charge (BrickLink) + + Order Total + + + + + Sales Tax + + + + + Grand Total @@ -3253,86 +3264,98 @@ Please also select which item's attributes (e.g. remarks, tiered prices, .. Payment in + + + Seller + x% VAT (Seller) + + + + + BrickLink + x% VAT (BrickLink) + + Orders - + Unknown - + Pending - + Updated - + Processing - + Ready - + Paid - + Packed - + Shipped - + Received - + Completed - + OCR - + NPB - + NPX - + NRS - + NSS - + Cancelled diff --git a/translations/brickstore_es.ts b/translations/brickstore_es.ts index 0994c868..ccaf80e0 100755 --- a/translations/brickstore_es.ts +++ b/translations/brickstore_es.ts @@ -1295,83 +1295,83 @@ BrickLink::Orders - + Address not available Dirección no disponible - + Cannot write order address to cache No se puede escribir la dirección del pedido en la caché - + Cannot save order to file No se puede guardar el pedido en un archivo - + Cannot write order XML to cache No se puede escribir el pedido XML en la caché - - + + Could not parse the received order XML data No se ha podido convertir los datos XML del pedido recibido - + Cannot open order XML No se puede abir el XML del pedido - + Received Recibidos - + Placed Realizados - + Date Fecha - + Type Tipo - + Status Estado - + Order ID ID Pedido - + Buyer/Seller Comprador/Vendedor - + Items Artículos - + Lots Lotes - + Total Total @@ -3116,7 +3116,7 @@ Por favor seleciona también que atributos (p.ej. notas, precios encadenados, .. Descargando...<br><b>%p%</b> finalizado<br>(%v de %m) - + Customize Toolbar... Personalizar Barra de heramientas... @@ -3170,84 +3170,103 @@ Por favor seleciona también que atributos (p.ej. notas, precios encadenados, .. Estado - + Last updated Última Actualización - + Tracking Number Número de Seguimiento - + Address Dirección - + Phone Teléfono - + Currency Code Código de Moneda - + Shipping Envío - + Insurance Seguro - + Additional Charges 1 Cargos Adicionales 1 - + Additional Charges 2 Cargos Adicionales 2 - + Credit Crédito - + Credit Coupon Crédito de Cupón - + + VAT Information: + + + + + Net Grand Total + + + + + %1 VAT (%2) + x% VAT (Seller or BrickLink) + %1 VAT (%2) + + + + Gross Grand Total + + + + Order Total Total Pedido - + Sales Tax Impuestos de Ventas - + Grand Total Gran Total - %1 VAT Charge (Seller) - Cargo %1 IVA (Vendedor) + Cargo %1 IVA (Vendedor) - %1 VAT Charge (BrickLink) - Cargo %1 IVA (BrickLink) + Cargo %1 IVA (BrickLink) VAT Charges @@ -3273,86 +3292,98 @@ Por favor seleciona también que atributos (p.ej. notas, precios encadenados, .. Payment in Pago en + + + Seller + x% VAT (Seller) + Vendedor + + + + BrickLink + x% VAT (BrickLink) + BrickLink + Orders - + Unknown Desconocido - + Pending Pendiente - + Updated Actualizado - + Processing Precesando - + Ready Listo - + Paid Pagado - + Packed Empaquetado - + Shipped Enviado - + Received Recibido - + Completed Completado - + OCR OCR - + NPB NPB - + NPX NPX - + NRS NRS - + NSS NSS - + Cancelled Cancelado diff --git a/translations/brickstore_fr.ts b/translations/brickstore_fr.ts index 448e7f49..536f6793 100644 --- a/translations/brickstore_fr.ts +++ b/translations/brickstore_fr.ts @@ -1322,83 +1322,83 @@ BrickLink::Orders - + Address not available - + Cannot write order address to cache - + Cannot save order to file - + Cannot write order XML to cache - - + + Could not parse the received order XML data - + Cannot open order XML - + Received Reçue - + Placed Passée - + Date Date - + Type Type - + Status Statut - + Order ID Numéro - + Buyer/Seller - + Items Items - + Lots Lots - + Total Total @@ -4050,7 +4050,7 @@ Please also select which item's attributes (e.g. remarks, tiered prices, .. Téléchargement...<br><b>%p%</b> terminé<br>(%v of %m) - + Customize Toolbar... @@ -4116,83 +4116,94 @@ Please also select which item's attributes (e.g. remarks, tiered prices, .. Statut - + Last updated - + Tracking Number - + Address - + Phone - + Currency Code - + Shipping - + Insurance - + Additional Charges 1 - + Additional Charges 2 - + Credit - + Credit Coupon - - Order Total + + VAT Information: - - Sales Tax + + Net Grand Total - - Grand Total + + %1 VAT (%2) + x% VAT (Seller or BrickLink) - - %1 VAT Charge (Seller) + + Gross Grand Total - - %1 VAT Charge (BrickLink) + + Order Total + + + + + Sales Tax + + + + + Grand Total @@ -4215,6 +4226,18 @@ Please also select which item's attributes (e.g. remarks, tiered prices, .. Payment in + + + Seller + x% VAT (Seller) + + + + + BrickLink + x% VAT (BrickLink) + + OrderModel @@ -4226,82 +4249,82 @@ Please also select which item's attributes (e.g. remarks, tiered prices, .. Orders - + Unknown - + Pending - + Updated - + Processing - + Ready - + Paid - + Packed - + Shipped - + Received Reçue - + Completed - + OCR - + NPB - + NPX - + NRS - + NSS - + Cancelled