mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP]pms_api_rest: improvemente invoice&payment datamodels: reversed, downpayments...
This commit is contained in:
@@ -20,3 +20,7 @@ class PmsAccountInvoiceInfo(Datamodel):
|
||||
narration = fields.String(required=False, allow_none=True)
|
||||
portalUrl = fields.String(required=False, allow_none=True)
|
||||
moveType = fields.String(required=False, allow_none=True)
|
||||
isReversed = fields.Boolean(required=False, allow_none=True)
|
||||
isDownPaymentInvoice = fields.Boolean(required=False, allow_none=True)
|
||||
isSimplifiedInvoice = fields.Boolean(required=False, allow_none=True)
|
||||
reversedEntryId = fields.Integer(required=False, allow_none=True)
|
||||
|
||||
@@ -13,7 +13,6 @@ class PmsTransactionSearchParam(Datamodel):
|
||||
dateEnd = fields.String(required=False, allow_none=True)
|
||||
transactionMethodId = fields.Integer(required=False, allow_none=True)
|
||||
transactionType = fields.String(required=False, allow_none=True)
|
||||
# REVIEW: Fields to avoid?:
|
||||
|
||||
|
||||
class PmsTransactionsResults(Datamodel):
|
||||
@@ -38,6 +37,7 @@ class PmsTransactionInfo(Datamodel):
|
||||
pmsPropertyId = fields.Integer(required=False, allow_none=True)
|
||||
createUid = fields.Integer(required=False, allow_none=True)
|
||||
transactionType = fields.String(required=False, allow_none=True)
|
||||
isReconcilied = fields.Boolean(required=False, allow_none=True)
|
||||
downPaymentInvoiceId = fields.Integer(required=False, allow_none=True)
|
||||
# REVIEW: Fields to avoid?:
|
||||
partnerName = fields.String(required=False, allow_none=True)
|
||||
isReconcilied = fields.Boolean(required=False, allow_none=True)
|
||||
|
||||
@@ -214,9 +214,9 @@ class PmsFolioService(Component):
|
||||
if payment.partner_id
|
||||
else None,
|
||||
reference=payment.ref if payment.ref else None,
|
||||
isReconcilied=(
|
||||
payment.reconciled_statements_count > 0
|
||||
or payment.reconciled_invoices_count > 0
|
||||
isReconcilied=(payment.reconciled_statements_count > 0),
|
||||
downPaymentInvoiceId=payment.reconciled_invoice_ids.filtered(
|
||||
lambda inv: inv._is_downpayment()
|
||||
),
|
||||
)
|
||||
)
|
||||
@@ -606,6 +606,9 @@ class PmsFolioService(Component):
|
||||
moveLines=move_lines if move_lines else None,
|
||||
portalUrl=portal_url,
|
||||
moveType=move.move_type,
|
||||
isReverse=move.payment_state == "reversed",
|
||||
isDownPaymentInvoice=move._is_downpayment(),
|
||||
isSimpleInvoice=move.journal_id.is_simplified_invoice,
|
||||
)
|
||||
)
|
||||
return invoices
|
||||
|
||||
@@ -224,14 +224,29 @@ class PmsPartnerService(Component):
|
||||
PmsTransactiontInfo = self.env.datamodels["pms.transaction.info"]
|
||||
payments = []
|
||||
for payment in partnerPayments:
|
||||
if payment.is_internal_transfer:
|
||||
destination_journal_id = (
|
||||
payment.pms_api_counterpart_payment_id.journal_id.id
|
||||
)
|
||||
payments.append(
|
||||
PmsTransactiontInfo(
|
||||
id=payment.id,
|
||||
amount=round(payment.amount, 2),
|
||||
journalId=payment.journal_id.id,
|
||||
date=payment.date.strftime("%d/%m/%Y"),
|
||||
reference=payment.ref,
|
||||
transactionType=payment.pms_api_transaction_type,
|
||||
name=payment.name if payment.name else None,
|
||||
amount=payment.amount,
|
||||
journalId=payment.journal_id.id if payment.journal_id else None,
|
||||
destinationJournalId=destination_journal_id or None,
|
||||
date=datetime.combine(
|
||||
payment.date, datetime.min.time()
|
||||
).isoformat(),
|
||||
partnerId=payment.partner_id.id if payment.partner_id else None,
|
||||
partnerName=payment.partner_id.name if payment.partner_id else None,
|
||||
reference=payment.ref if payment.ref else None,
|
||||
createUid=payment.create_uid.id if payment.create_uid else None,
|
||||
transactionType=payment.pms_api_transaction_type or None,
|
||||
isReconcilied=(payment.reconciled_statements_count > 0),
|
||||
downPaymentInvoiceId=payment.reconciled_invoice_ids.filtered(
|
||||
lambda inv: inv._is_downpayment()
|
||||
),
|
||||
)
|
||||
)
|
||||
return payments
|
||||
|
||||
@@ -179,9 +179,9 @@ class PmsTransactionService(Component):
|
||||
if transaction.create_uid
|
||||
else None,
|
||||
transactionType=transaction.pms_api_transaction_type or None,
|
||||
isReconcilied=(
|
||||
transaction.reconciled_statements_count > 0
|
||||
or transaction.reconciled_invoices_count > 0
|
||||
isReconcilied=(transaction.reconciled_statements_count > 0),
|
||||
downPaymentInvoiceId=transaction.reconciled_invoice_ids.filtered(
|
||||
lambda inv: inv._is_downpayment()
|
||||
),
|
||||
)
|
||||
)
|
||||
@@ -223,9 +223,9 @@ class PmsTransactionService(Component):
|
||||
reference=transaction.ref if transaction.ref else None,
|
||||
createUid=transaction.create_uid.id if transaction.create_uid else None,
|
||||
transactionType=transaction.pms_api_transaction_type or None,
|
||||
isReconcilied=(
|
||||
transaction.reconciled_statements_count > 0
|
||||
or transaction.reconciled_invoices_count > 0
|
||||
isReconcilied=(transaction.reconciled_statements_count > 0),
|
||||
downPaymentInvoiceId=transaction.reconciled_invoice_ids.filtered(
|
||||
lambda inv: inv._is_downpayment()
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user