facho/fe/fe.py: cufe/cude se trunca segun 10.1.1.
FossilOrigin-Name: e6759139dbd42db6583de02608763403ce12b720f48283993250159ad7c87765
This commit is contained in:
		@@ -183,14 +183,14 @@ class DianXMLExtensionCUFE(DianXMLExtensionCUDFE):
 | 
				
			|||||||
            '%s' % build_vars['NumFac'],
 | 
					            '%s' % build_vars['NumFac'],
 | 
				
			||||||
            '%s' % build_vars['FecFac'],
 | 
					            '%s' % build_vars['FecFac'],
 | 
				
			||||||
            '%s' % build_vars['HoraFac'],
 | 
					            '%s' % build_vars['HoraFac'],
 | 
				
			||||||
            '%.02f' % round(build_vars['ValorBruto'], 2),
 | 
					            form.Amount(build_vars['ValorBruto']).format('%.02f'),
 | 
				
			||||||
            '%02d' % CodImpuesto1,
 | 
					            '%02d' % CodImpuesto1,
 | 
				
			||||||
            '%.02f' % round(build_vars['ValorImpuestoPara'].get(CodImpuesto1, 0.0), 2),
 | 
					            form.Amount(build_vars['ValorImpuestoPara'].get(CodImpuesto1, 0.0)).format('%.02f'),
 | 
				
			||||||
            '%02d' % CodImpuesto2,
 | 
					            '%02d' % CodImpuesto2,
 | 
				
			||||||
            '%.02f' % round(build_vars['ValorImpuestoPara'].get(CodImpuesto2, 0.0), 2),
 | 
					            form.Amount(build_vars['ValorImpuestoPara'].get(CodImpuesto2, 0.0)).format('%.02f'),
 | 
				
			||||||
            '%02d' % CodImpuesto3,
 | 
					            '%02d' % CodImpuesto3,
 | 
				
			||||||
            '%.02f' % round(build_vars['ValorImpuestoPara'].get(CodImpuesto3, 0.0), 2),
 | 
					            form.Amount(build_vars['ValorImpuestoPara'].get(CodImpuesto3, 0.0)).format('%.02f'),
 | 
				
			||||||
            '%.02f' % round(build_vars['ValorTotalPagar'], 2),
 | 
					            form.Amount(build_vars['ValorTotalPagar']).format('%.02f'),
 | 
				
			||||||
            '%s' % build_vars['NitOFE'],
 | 
					            '%s' % build_vars['NitOFE'],
 | 
				
			||||||
            '%s' % build_vars['NumAdq'],
 | 
					            '%s' % build_vars['NumAdq'],
 | 
				
			||||||
            '%s' % build_vars['ClTec'],
 | 
					            '%s' % build_vars['ClTec'],
 | 
				
			||||||
@@ -220,14 +220,14 @@ class DianXMLExtensionCUDE(DianXMLExtensionCUDFE):
 | 
				
			|||||||
            '%s' % build_vars['NumFac'],
 | 
					            '%s' % build_vars['NumFac'],
 | 
				
			||||||
            '%s' % build_vars['FecFac'],
 | 
					            '%s' % build_vars['FecFac'],
 | 
				
			||||||
            '%s' % build_vars['HoraFac'],
 | 
					            '%s' % build_vars['HoraFac'],
 | 
				
			||||||
            '%.02f' % round(build_vars['ValorBruto'], 2),
 | 
					            form.Amount(build_vars['ValorBruto']).format('%.02f'),
 | 
				
			||||||
            '%02d' % CodImpuesto1,
 | 
					            '%02d' % CodImpuesto1,
 | 
				
			||||||
            '%.02f' % round(build_vars['ValorImpuestoPara'].get(CodImpuesto1, 0.0), 2),
 | 
					            form.Amount(build_vars['ValorImpuestoPara'].get(CodImpuesto1, 0.0)).format('%.02f'),
 | 
				
			||||||
            '%02d' % CodImpuesto2,
 | 
					            '%02d' % CodImpuesto2,
 | 
				
			||||||
            '%.02f' % round(build_vars['ValorImpuestoPara'].get(CodImpuesto2, 0.0), 2),
 | 
					            form.Amount(build_vars['ValorImpuestoPara'].get(CodImpuesto2, 0.0)).format('%.02f'),
 | 
				
			||||||
            '%02d' % CodImpuesto3,
 | 
					            '%02d' % CodImpuesto3,
 | 
				
			||||||
            '%.02f' % round(build_vars['ValorImpuestoPara'].get(CodImpuesto3, 0.0), 2),
 | 
					            form.Amount(build_vars['ValorImpuestoPara'].get(CodImpuesto3, 0.0)).format('%.02f'),
 | 
				
			||||||
            '%.02f' % round(build_vars['ValorTotalPagar'], 2),
 | 
					            form.Amount(build_vars['ValorTotalPagar']).format('%.02f'),
 | 
				
			||||||
            '%s' % build_vars['NitOFE'],
 | 
					            '%s' % build_vars['NitOFE'],
 | 
				
			||||||
            '%s' % build_vars['NumAdq'],
 | 
					            '%s' % build_vars['NumAdq'],
 | 
				
			||||||
            '%s' % build_vars['Software-PIN'],
 | 
					            '%s' % build_vars['Software-PIN'],
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,24 +56,33 @@ class Amount:
 | 
				
			|||||||
    def __init__(self, amount: int or float or Amount, currency: Currency = Currency('COP')):
 | 
					    def __init__(self, amount: int or float or Amount, currency: Currency = Currency('COP')):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #DIAN 1.7.-2020: 1.2.3.1
 | 
					        #DIAN 1.7.-2020: 1.2.3.1
 | 
				
			||||||
        if amount < 0:
 | 
					        if isinstance(amount, Amount):
 | 
				
			||||||
 | 
					            if amount < Amount(0.0):
 | 
				
			||||||
                raise ValueError('amount must be positive >= 0')
 | 
					                raise ValueError('amount must be positive >= 0')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if isinstance(amount, Amount):
 | 
					 | 
				
			||||||
            self.amount = amount.amount
 | 
					            self.amount = amount.amount
 | 
				
			||||||
            self.currency = amount.currency
 | 
					            self.currency = amount.currency
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
 | 
					            if amount < 0:
 | 
				
			||||||
 | 
					                raise ValueError('amount must be positive >= 0')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            self.amount = Decimal(amount, decimal.Context(prec=DECIMAL_PRECISION,
 | 
					            self.amount = Decimal(amount, decimal.Context(prec=DECIMAL_PRECISION,
 | 
				
			||||||
                                                          #DIAN 1.7.-2020: 1.2.1.1
 | 
					                                                          #DIAN 1.7.-2020: 1.2.1.1
 | 
				
			||||||
                                                          rounding=decimal.ROUND_HALF_EVEN ))
 | 
					                                                          rounding=decimal.ROUND_HALF_EVEN ))
 | 
				
			||||||
            self.currency = currency
 | 
					            self.currency = currency
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __round__(self, prec):
 | 
					    def __round__(self, prec):
 | 
				
			||||||
        return round(self.amount, prec)
 | 
					        return round(self.amount, prec)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return '%.06f' % self.amount
 | 
					        return '%.06f' % self.amount
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def __lt__(self, other):
 | 
				
			||||||
 | 
					        if not self.is_same_currency(other):
 | 
				
			||||||
 | 
					            raise AmountCurrencyError()
 | 
				
			||||||
 | 
					        return round(self.amount, DECIMAL_PRECISION) < round(other, 2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __eq__(self, other):
 | 
					    def __eq__(self, other):
 | 
				
			||||||
        if not self.is_same_currency(other):
 | 
					        if not self.is_same_currency(other):
 | 
				
			||||||
            raise AmountCurrencyError()
 | 
					            raise AmountCurrencyError()
 | 
				
			||||||
@@ -97,6 +106,12 @@ class Amount:
 | 
				
			|||||||
    def is_same_currency(self, other):
 | 
					    def is_same_currency(self, other):
 | 
				
			||||||
        return self.currency == other.currency
 | 
					        return self.currency == other.currency
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def format(self, formatter):
 | 
				
			||||||
 | 
					        return formatter % self.float()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def float(self):
 | 
				
			||||||
 | 
					        return round(self.amount, DECIMAL_PRECISION)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Quantity(Amount):
 | 
					class Quantity(Amount):
 | 
				
			||||||
    pass
 | 
					    pass
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user