facho/fe/form.py(Invoice): adiciona prepaid_payment.
FossilOrigin-Name: feceabdbddaa65c5c767ae46cc79f7d7c158e9ffa01c3f0d507a02caef8ac33c
This commit is contained in:
parent
45e4bff58b
commit
ae91c2e68d
@ -138,13 +138,9 @@ class PaymentMean:
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Payment:
|
class PrePaidPayment:
|
||||||
amount: float
|
#DIAN 1.7.-2020: FBD03
|
||||||
at: datetime
|
paid_amount: float = 0.0
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class PrePaidPayment(Payment):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -190,7 +186,9 @@ class LegalMonetaryTotal:
|
|||||||
tax_exclusive_amount: float = 0.0
|
tax_exclusive_amount: float = 0.0
|
||||||
tax_inclusive_amount: float = 0.0
|
tax_inclusive_amount: float = 0.0
|
||||||
charge_total_amount: float = 0.0
|
charge_total_amount: float = 0.0
|
||||||
|
allowance_total_amount: float = 0.0
|
||||||
payable_amount: float = 0.0
|
payable_amount: float = 0.0
|
||||||
|
prepaid_amount: float = 0.0
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class AllowanceCharge:
|
class AllowanceCharge:
|
||||||
@ -211,6 +209,7 @@ class AllowanceCharge:
|
|||||||
self.charge_indicator = False
|
self.charge_indicator = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Invoice:
|
class Invoice:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.invoice_period_start = None
|
self.invoice_period_start = None
|
||||||
@ -225,6 +224,7 @@ class Invoice:
|
|||||||
self.invoice_payments = []
|
self.invoice_payments = []
|
||||||
self.invoice_lines = []
|
self.invoice_lines = []
|
||||||
self.invoice_allowance_charge = []
|
self.invoice_allowance_charge = []
|
||||||
|
self.invoice_prepaid_payment = []
|
||||||
|
|
||||||
def set_period(self, startdate, enddate):
|
def set_period(self, startdate, enddate):
|
||||||
self.invoice_period_start = startdate
|
self.invoice_period_start = startdate
|
||||||
@ -254,6 +254,9 @@ class Invoice:
|
|||||||
def add_invoice_line(self, line: InvoiceLine):
|
def add_invoice_line(self, line: InvoiceLine):
|
||||||
self.invoice_lines.append(line)
|
self.invoice_lines.append(line)
|
||||||
|
|
||||||
|
def add_prepaid_payment(self, paid: PrePaidPayment):
|
||||||
|
self.invoice_prepaid_payment.append(paid)
|
||||||
|
|
||||||
def accept(self, visitor):
|
def accept(self, visitor):
|
||||||
visitor.visit_payment_mean(self.invoice_payment_mean)
|
visitor.visit_payment_mean(self.invoice_payment_mean)
|
||||||
visitor.visit_customer(self.invoice_customer)
|
visitor.visit_customer(self.invoice_customer)
|
||||||
@ -270,14 +273,26 @@ class Invoice:
|
|||||||
#DIAN 1.7.-2020: FAU6
|
#DIAN 1.7.-2020: FAU6
|
||||||
self.invoice_legal_monetary_total.tax_inclusive_amount += invline.total_tax_inclusive_amount
|
self.invoice_legal_monetary_total.tax_inclusive_amount += invline.total_tax_inclusive_amount
|
||||||
|
|
||||||
|
#DIAN 1.7.-2020: FAU08
|
||||||
|
allownaces = filter(lambda charge: charge.isDiscount(), self.invoice_allowance_charge)
|
||||||
|
amounts_allowance = map(lambda charge: charge.amount, allownaces)
|
||||||
|
self.invoice_legal_monetary_total.allowance_total_amount = sum(amounts_allowance)
|
||||||
|
|
||||||
#DIAN 1.7.-2020: FAU10
|
#DIAN 1.7.-2020: FAU10
|
||||||
allowance_charges = filter(lambda charge: charge.isCharge(), self.invoice_allowance_charge)
|
allowance_charges = filter(lambda charge: charge.isCharge(), self.invoice_allowance_charge)
|
||||||
amounts_allowance_charge = map(lambda charge: charge.amount, allowance_charges)
|
amounts_allowance_charge = map(lambda charge: charge.amount, allowance_charges)
|
||||||
self.invoice_legal_monetary_total.charge_total_amount = sum(amounts_allowance_charge)
|
self.invoice_legal_monetary_total.charge_total_amount = sum(amounts_allowance_charge)
|
||||||
|
|
||||||
#DIAN 1.7.-2020: FAU14 parcial
|
#DIAN 1.7.-2020: FAU12
|
||||||
self.invoice_legal_monetary_total.payable_amount = self.invoice_legal_monetary_total.tax_inclusive_amount + self.invoice_legal_monetary_total.charge_total_amount
|
amounts_prepaid = map(lambda paid: paid.paid_amount, self.invoice_prepaid_payment)
|
||||||
|
self.invoice_legal_monetary_total.prepaid_amount = sum(amounts_prepaid)
|
||||||
|
|
||||||
|
#DIAN 1.7.-2020: FAU14
|
||||||
|
self.invoice_legal_monetary_total.payable_amount = \
|
||||||
|
self.invoice_legal_monetary_total.tax_inclusive_amount \
|
||||||
|
+ self.invoice_legal_monetary_total.allowance_total_amount \
|
||||||
|
+ self.invoice_legal_monetary_total.charge_total_amount \
|
||||||
|
- self.invoice_legal_monetary_total.prepaid_amount
|
||||||
|
|
||||||
def calculate(self):
|
def calculate(self):
|
||||||
for invline in self.invoice_lines:
|
for invline in self.invoice_lines:
|
||||||
|
@ -65,3 +65,29 @@ def test_FAU10():
|
|||||||
assert inv.invoice_legal_monetary_total.tax_exclusive_amount == 100.0
|
assert inv.invoice_legal_monetary_total.tax_exclusive_amount == 100.0
|
||||||
assert inv.invoice_legal_monetary_total.tax_inclusive_amount == 119.0
|
assert inv.invoice_legal_monetary_total.tax_inclusive_amount == 119.0
|
||||||
assert inv.invoice_legal_monetary_total.charge_total_amount == 19.0
|
assert inv.invoice_legal_monetary_total.charge_total_amount == 19.0
|
||||||
|
|
||||||
|
|
||||||
|
def test_FAU14():
|
||||||
|
inv = form.Invoice()
|
||||||
|
inv.add_invoice_line(form.InvoiceLine(
|
||||||
|
quantity = 1,
|
||||||
|
description = 'producto facho',
|
||||||
|
item = form.StandardItem('test', 9999),
|
||||||
|
price = form.Price(
|
||||||
|
amount = 100.0,
|
||||||
|
type_code = '01',
|
||||||
|
type = 'x'
|
||||||
|
),
|
||||||
|
tax = form.TaxTotal(
|
||||||
|
subtotals = [
|
||||||
|
form.TaxSubTotal(
|
||||||
|
percent = 19.0,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
))
|
||||||
|
inv.add_allownace_charge(form.AllowanceCharge(amount=19.0))
|
||||||
|
inv.add_prepaid_payment(form.PrePaidPayment(paid_amount = 50.0))
|
||||||
|
inv.calculate()
|
||||||
|
|
||||||
|
assert inv.invoice_legal_monetary_total.payable_amount == 119.0 + 19.0 - 50.0
|
||||||
|
Loading…
Reference in New Issue
Block a user