from invoice_base import * class Invoice(BaseInvoice): def __str__(self): taxestotal = '' for x in self.taxes: taxestotal += str(x) allarticles = '' for a in self.articles: allarticles += str(a) alltenders = '' for t in self.tenders: alltenders += str(t) xml = f''' urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 {self.nr} {self.receipt.year}-{self.receipt.month}-{self.receipt.day} {self.receipt.year}-{self.receipt.month}-{self.receipt.day} 388 {self.currency()} {self.receipt.store}{self.receipt.year}{self.receipt.month}{self.receipt.day}{self.receipt.till}{self.receipt.seq.zfill(6)} {self.seller} {self.buyer} {alltenders} {self.receipt.year}-{self.receipt.month}-{self.receipt.day} {self.totals} {self.total_taxes():.2f} {taxestotal} {allarticles} ''' result = "" result += xml # if self.seller: # result += str(self.seller) # else: # result += "[ == no country / PVH-ofice found ==]\n" # if self.buyer: # result += str(self.buyer) # for a in self.articles: # result += str(a) # for t in self.tenders: # result += str(t) return result class Discount(BaseDiscount): def __str__(self): return f''' false 95 {self.promotionID} {self.net_amount():.2f} ''' class Tax(BaseTax): spaces = 'tax' #### TODO translation pls note self.country is always XX def translated_group(self): result = 'S' # peppol: S: standard p = float(self.percentage) if p < 18.0: result = 'AA' # lower rate if p <0.01: result = 'E' # zero rate return result def __str__(self): return f"{self.spaces},{self.typesubtype},{self.code},{self.amount},{self.percentage}%,{self.translated_group()},{self.taxableamount}\n" class TotalTax(Tax): def __str__(self): return f''' {self.taxableamount:.2f} {self.amount:.2f} {self.translated_group()} {self.percentage} VAT ''' class Header(BaseHeader): pass class Totals(BaseTotals): def __str__(self): return f''' {self.netAmount:.2f} {self.netAmount:.2f} {self.grandAmount:.2f} {self.grandAmount:.2f} ''' class Receipt(BaseReceipt): pass class Buyer(BaseBuyer): def __str__(self): return f''' {self.orgid} {self.name} {self.street1} {self.street2} {self.city} {self.zip} {self.country} {self.taxID} tax {self.name} {self.orgid} {self.name} {self.phone} {self.email} ''' class Delivery(): pass class Seller(BaseSeller): def __str__(self): return f''' {self.orgid} {self.name} {self.street1} {self.street2} {self.city} {self.zip} {self.country} {self.taxID} tax {self.name} {self.orgid} ''' class Tender(BaseTender): def translate(self, code): return '54' # credit card def __str__(self): return f''' {self.type} ''' class Article(BaseArticle): def __str__(self): discounts = '' for d in self.discounts: discounts += str(d) return f''' {self.sequence} {'-' if self.returnflag else ''}{self.quantity} {'-' if self.returnflag else ''}{self.netSalesPrice():.2f} {discounts} {self.description} {self.description} {self.itemid} {self.upc} {self.tax.translated_group()} {self.tax.percentage} VAT {self.netBasePrice():.2f} '''