Skip to content

Commit

Permalink
Flatten down FuelItem into FuelLine & minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
cavalle committed Sep 12, 2023
1 parent ce4472f commit 86e2823
Showing 1 changed file with 26 additions and 32 deletions.
58 changes: 26 additions & 32 deletions regimes/mx/fuel_complement.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,52 @@ import (
"github.com/invopop/gobl/tax"
)

// FuelComplement carries the data to produce the CFDI's "Complemento de Estado
// de Cuenta de Combustibles para Monederos Electrónicos" (version 1.2 revision
// B) which provides detailed information about fuel purchases made with
// electronic wallets. In Mexico, e-wallet suppliers are required to report this
// information as part of the invoices they issue to their customers.
// FuelComplement carries the data to produce a CFDI's "Complemento de Estado de
// Cuenta de Combustibles para Monederos Electrónicos" (version 1.2 revision B)
// providing detailed information about fuel purchases made with electronic
// wallets. In Mexico, e-wallet suppliers are required to report this
// complementary information in the invoices they issue to their customers.
type FuelComplement struct {
// Customer's e-wallet account number
// Customer's e-wallet account number.
WalletAccountNumber string `json:"wallet_account_number" jsonschema:"title=Wallet Account Number"`
// List of fuel purchases made with the customer's e-wallets
// List of fuel purchases made with the customer's e-wallets.
Lines []*FuelLine `json:"lines" jsonschema:"title=Lines"`
// Summary of all the purchases totals, including taxes (calculated)
// Summary of all the purchases totals, including taxes (calculated).
Totals *FuelTotals `json:"totals" jsonschema:"title=Totals" jsonschema_extras:"calculated=true"`
}

// FuelLine represents a single fuel purchase made with an e-wallet issued by
// the invoice's supplier to the invoice's customer.
// the invoice's supplier.
type FuelLine struct {
// Identifier of the e-wallet used to make the purchase
// Identifier of the e-wallet used to make the purchase.
WalletID cbc.Code `json:"wallet_id" jsonschema:"title=Wallet Identifier"`
// Date and time of the purchase
PurchaseDateTime cal.DateTime `json:"purchase_date" jsonschema:"title=Purchase Date"`
// Tax ID (RFC) of the fuel seller
// Date and time of the purchase.
PurchaseDateTime cal.DateTime `json:"purchase_date_time" jsonschema:"title=Purchase Date and Time"`
// Tax ID (RFC) of the fuel seller.
SellerTaxID cbc.Code `json:"seller_tax_id" jsonschema:"title=Seller's Tax ID"`
// Code of the service station where the purchase was made
// Code of the service station where the purchase was made.
ServiceStationCode cbc.Code `json:"service_station_code" jsonschema:"title=Service Station Code"`
// Amount of fuel units purchased
Quantity num.Amount `json:"quantity" jsonschema:"title=Quantity"`
// Details about the fuel purchased
Item FuelItem `json:"item" jsonschema:"title=Item"`
// Identifier of the purchase (folio)
PurchaseID cbc.Code `json:"purchase_id" jsonschema:"title=Purchase Identifier"`
// Result of quantity multiplied by the item's price (calculated)
Total num.Amount `json:"total" jsonschema:"title=Total" jsonschema_extras:"calculated=true"`
// Map of taxes applied to the purchase
Taxes tax.Set `json:"taxes" jsonschema:"title=Taxes"`
}

// FuelItem provides the details of the fuel purchased.
type FuelItem struct {
// Reference unit of measure used in the price and the quantity
// Reference unit of measure used in the price and the quantity.
Unit org.Unit `json:"unit" jsonschema:"title=Unit"`
// Type of fuel (c_ClaveTipoCombustible codes)
Type cbc.Code `json:"type,omitempty" jsonschema:"title=Type"`
// Type of fuel ("c_ClaveTipoCombustible" codes).
FuelType cbc.Code `json:"type,omitempty" jsonschema:"title=Type"`
// Name of the fuel
Name string `json:"name" jsonschema:"title=Name"`
// Base price of a single unit of the fuel
FuelName string `json:"name" jsonschema:"title=Name"`
// Base price of a single unit of the fuel.
Price num.Amount `json:"price" jsonschema:"title=Price"`
// Identifier of the purchase ("Folio").
PurchaseCode cbc.Code `json:"purchase_code" jsonschema:"title=Purchase Code"`
// Result of quantity multiplied by the item's price (calculated).
Total num.Amount `json:"total" jsonschema:"title=Total" jsonschema_extras:"calculated=true"`
// Map of taxes applied to the purchase.
Taxes tax.Set `json:"taxes" jsonschema:"title=Taxes"`
}

// FuelTotals contains the summaries of all calculations for the fuel purchases.
type FuelTotals struct {
// Sum of all line sums
// Sum of all line sums.
Total num.Amount `json:"total" jsonschema:"title=Total"`
// Grand total after taxes have been applied.
TotalWithTax num.Amount `json:"total_with_tax" jsonschema:"title=Total with Tax"`
Expand Down

0 comments on commit 86e2823

Please sign in to comment.