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)
|
narration = fields.String(required=False, allow_none=True)
|
||||||
portalUrl = fields.String(required=False, allow_none=True)
|
portalUrl = fields.String(required=False, allow_none=True)
|
||||||
moveType = 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)
|
dateEnd = fields.String(required=False, allow_none=True)
|
||||||
transactionMethodId = fields.Integer(required=False, allow_none=True)
|
transactionMethodId = fields.Integer(required=False, allow_none=True)
|
||||||
transactionType = fields.String(required=False, allow_none=True)
|
transactionType = fields.String(required=False, allow_none=True)
|
||||||
# REVIEW: Fields to avoid?:
|
|
||||||
|
|
||||||
|
|
||||||
class PmsTransactionsResults(Datamodel):
|
class PmsTransactionsResults(Datamodel):
|
||||||
@@ -38,6 +37,7 @@ class PmsTransactionInfo(Datamodel):
|
|||||||
pmsPropertyId = fields.Integer(required=False, allow_none=True)
|
pmsPropertyId = fields.Integer(required=False, allow_none=True)
|
||||||
createUid = fields.Integer(required=False, allow_none=True)
|
createUid = fields.Integer(required=False, allow_none=True)
|
||||||
transactionType = fields.String(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?:
|
# REVIEW: Fields to avoid?:
|
||||||
partnerName = fields.String(required=False, allow_none=True)
|
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
|
if payment.partner_id
|
||||||
else None,
|
else None,
|
||||||
reference=payment.ref if payment.ref else None,
|
reference=payment.ref if payment.ref else None,
|
||||||
isReconcilied=(
|
isReconcilied=(payment.reconciled_statements_count > 0),
|
||||||
payment.reconciled_statements_count > 0
|
downPaymentInvoiceId=payment.reconciled_invoice_ids.filtered(
|
||||||
or payment.reconciled_invoices_count > 0
|
lambda inv: inv._is_downpayment()
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -606,6 +606,9 @@ class PmsFolioService(Component):
|
|||||||
moveLines=move_lines if move_lines else None,
|
moveLines=move_lines if move_lines else None,
|
||||||
portalUrl=portal_url,
|
portalUrl=portal_url,
|
||||||
moveType=move.move_type,
|
moveType=move.move_type,
|
||||||
|
isReverse=move.payment_state == "reversed",
|
||||||
|
isDownPaymentInvoice=move._is_downpayment(),
|
||||||
|
isSimpleInvoice=move.journal_id.is_simplified_invoice,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return invoices
|
return invoices
|
||||||
|
|||||||
@@ -224,14 +224,29 @@ class PmsPartnerService(Component):
|
|||||||
PmsTransactiontInfo = self.env.datamodels["pms.transaction.info"]
|
PmsTransactiontInfo = self.env.datamodels["pms.transaction.info"]
|
||||||
payments = []
|
payments = []
|
||||||
for payment in partnerPayments:
|
for payment in partnerPayments:
|
||||||
|
if payment.is_internal_transfer:
|
||||||
|
destination_journal_id = (
|
||||||
|
payment.pms_api_counterpart_payment_id.journal_id.id
|
||||||
|
)
|
||||||
payments.append(
|
payments.append(
|
||||||
PmsTransactiontInfo(
|
PmsTransactiontInfo(
|
||||||
id=payment.id,
|
id=payment.id,
|
||||||
amount=round(payment.amount, 2),
|
name=payment.name if payment.name else None,
|
||||||
journalId=payment.journal_id.id,
|
amount=payment.amount,
|
||||||
date=payment.date.strftime("%d/%m/%Y"),
|
journalId=payment.journal_id.id if payment.journal_id else None,
|
||||||
reference=payment.ref,
|
destinationJournalId=destination_journal_id or None,
|
||||||
transactionType=payment.pms_api_transaction_type,
|
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
|
return payments
|
||||||
|
|||||||
@@ -179,9 +179,9 @@ class PmsTransactionService(Component):
|
|||||||
if transaction.create_uid
|
if transaction.create_uid
|
||||||
else None,
|
else None,
|
||||||
transactionType=transaction.pms_api_transaction_type or None,
|
transactionType=transaction.pms_api_transaction_type or None,
|
||||||
isReconcilied=(
|
isReconcilied=(transaction.reconciled_statements_count > 0),
|
||||||
transaction.reconciled_statements_count > 0
|
downPaymentInvoiceId=transaction.reconciled_invoice_ids.filtered(
|
||||||
or transaction.reconciled_invoices_count > 0
|
lambda inv: inv._is_downpayment()
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -223,9 +223,9 @@ class PmsTransactionService(Component):
|
|||||||
reference=transaction.ref if transaction.ref else None,
|
reference=transaction.ref if transaction.ref else None,
|
||||||
createUid=transaction.create_uid.id if transaction.create_uid else None,
|
createUid=transaction.create_uid.id if transaction.create_uid else None,
|
||||||
transactionType=transaction.pms_api_transaction_type or None,
|
transactionType=transaction.pms_api_transaction_type or None,
|
||||||
isReconcilied=(
|
isReconcilied=(transaction.reconciled_statements_count > 0),
|
||||||
transaction.reconciled_statements_count > 0
|
downPaymentInvoiceId=transaction.reconciled_invoice_ids.filtered(
|
||||||
or transaction.reconciled_invoices_count > 0
|
lambda inv: inv._is_downpayment()
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user