Merge pull request #5445 from expsa/remove_replace_family
Remove replace family
This commit is contained in:
commit
abbc9c2399
|
|
@ -7504,4 +7504,57 @@ msgstr "سجل الإستبدال"
|
|||
msgid "Paid"
|
||||
msgstr "منتهي"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__check_number
|
||||
msgid "Check Number"
|
||||
msgstr "رقم الشيك"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__journal_id
|
||||
msgid "Journal"
|
||||
msgstr "حساب الجمعية"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__partner_bank_id
|
||||
msgid "Partner Bank"
|
||||
msgstr "بنك المتبرع"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__payment_amount
|
||||
msgid "Payment Amount"
|
||||
msgstr "المبلغ"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__payment_file_attachment
|
||||
msgid "Payment Attachment"
|
||||
msgstr "مرفق الدفع"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__payment_method
|
||||
msgid "Payment Method"
|
||||
msgstr "طريقة الدفع"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__check_due_date
|
||||
msgid "Check Due Date"
|
||||
msgstr "تاريخ الإستحقاق"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__check_number
|
||||
msgid "Check Number"
|
||||
msgstr "رقم الشيك"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_donation_extension_wizard__is_different_payment
|
||||
msgid "Is Different Payment"
|
||||
msgstr "طرف دفع متعددة"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model_terms:ir.ui.view,arch_db:odex_takaful.view_account_payment_register_form
|
||||
msgid "Association Journal"
|
||||
msgstr "حساب الجمعية"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model_terms:ir.ui.view,arch_db:odex_takaful.donation_extension_wizard_form
|
||||
msgid "Sub Payments"
|
||||
msgstr "دفع متعدد"
|
||||
|
|
@ -157,7 +157,7 @@ class DonationsDetailsLines(models.Model):
|
|||
today = fields.Date.today()
|
||||
for rec in self:
|
||||
show_extend_button = (
|
||||
((rec.record_type == 'donation' and rec.direct_debit) or rec.record_type == 'sponsorship') and
|
||||
rec.record_type == 'sponsorship' and
|
||||
rec.end_date and
|
||||
rec.end_date >= today and
|
||||
rec.state == 'active'
|
||||
|
|
@ -168,9 +168,9 @@ class DonationsDetailsLines(models.Model):
|
|||
def _compute_show_replaced_button(self):
|
||||
for rec in self:
|
||||
show_replaced_button = (
|
||||
((rec.record_type == 'donation' and rec.donation_mechanism == 'with_conditions') or rec.record_type == 'sponsorship') and
|
||||
rec.state in ('active', 'paid','replace') and
|
||||
(rec.benefit_id or rec.benefit_ids or rec.family_id)
|
||||
rec.record_type == 'sponsorship' and
|
||||
rec.state in ('active','replace') and
|
||||
(rec.benefit_id or rec.benefit_ids)
|
||||
|
||||
)
|
||||
rec.show_replaced_button = show_replaced_button
|
||||
|
|
|
|||
|
|
@ -148,6 +148,8 @@ class SchedulingLine(models.Model):
|
|||
line.sudo().write({'status': 'paid'})
|
||||
if line.donation_detail_linked_id.state == 'waiting' or (not line.donation_detail_linked_id.benefit_id and line.donation_detail_linked_id.record_type == 'sponsorship'):
|
||||
line.donation_detail_linked_id.sudo().write({'state': 'waiting'})
|
||||
elif line.donation_detail_linked_id.record_type == 'donation':
|
||||
line.donation_detail_linked_id.sudo().write({'state': 'confirmed'})
|
||||
else:
|
||||
line.donation_detail_linked_id.sudo().write({'state': 'active'})
|
||||
line.donation_detail_linked_id.sponsorship_id.sudo().write({'state': 'wait_pay'})
|
||||
|
|
|
|||
|
|
@ -89,24 +89,66 @@ class DonationExtensionWizard(models.TransientModel):
|
|||
donation_line_ids += result[1]
|
||||
|
||||
if invoice_ids and self.is_different_payment:
|
||||
invoices = invoice_ids.filtered(
|
||||
lambda inv: inv.state == 'posted' and inv.move_type in ('out_invoice', 'out_refund'))
|
||||
if not invoices:
|
||||
return
|
||||
|
||||
residual_map = {inv.id: float(inv.amount_residual) for inv in invoices}
|
||||
|
||||
invoices = invoices.sorted(key=lambda r: r.invoice_date or r.date or fields.Date.context_today(self))
|
||||
|
||||
for pay_line in self.payment_line_ids:
|
||||
payment_register_vals = {
|
||||
'payment_type': 'inbound',
|
||||
'partner_type': 'customer',
|
||||
'partner_id': pay_line.partner_id.id,
|
||||
'amount': pay_line.payment_amount,
|
||||
'journal_id': pay_line.journal_id.id,
|
||||
'payment_method_id': pay_line.payment_method.id,
|
||||
'communication': _("Extension Payment"),
|
||||
}
|
||||
remaining = float(pay_line.payment_amount or 0.0)
|
||||
if float_compare(remaining, 0.0, precision_digits=2) <= 0:
|
||||
continue
|
||||
|
||||
payment_register = self.env['account.payment.register'].sudo().with_context(
|
||||
active_model='account.move',
|
||||
active_ids=invoice_ids.ids,
|
||||
).create(payment_register_vals)
|
||||
print('.................',payment_register)
|
||||
payment_register.action_create_payments()
|
||||
candidate_invoices = invoices.filtered(lambda inv: inv.partner_id == pay_line.partner_id)
|
||||
|
||||
if not candidate_invoices:
|
||||
candidate_invoices = invoices
|
||||
|
||||
for inv in candidate_invoices:
|
||||
if float_compare(remaining, 0.0, precision_digits=2) <= 0:
|
||||
break
|
||||
|
||||
inv_res = residual_map.get(inv.id, 0.0)
|
||||
if float_compare(inv_res, 0.0, precision_digits=2) <= 0:
|
||||
continue
|
||||
|
||||
pay_amount = min(remaining, inv_res)
|
||||
|
||||
payment_register_vals = {
|
||||
'payment_type': 'inbound',
|
||||
'partner_type': 'customer',
|
||||
'partner_id': pay_line.partner_id.id,
|
||||
'amount': pay_amount,
|
||||
'journal_id': pay_line.journal_id.id,
|
||||
'payment_method_id': pay_line.payment_method.id,
|
||||
'communication': _("Extension Payment for %s") % inv.name,
|
||||
'transaction_file_attachment': pay_line.payment_file_attachment,
|
||||
|
||||
}
|
||||
|
||||
ctx = {
|
||||
'active_model': 'account.move',
|
||||
'active_ids': [inv.id],
|
||||
'dont_redirect_to_payments': True,
|
||||
'sponsorship_line_ids': donation_line_ids.ids,
|
||||
'sponsorship_payment': True,
|
||||
'default_sponsorship_payment': True,
|
||||
}
|
||||
|
||||
payment_register = self.env['account.payment.register'].sudo().with_context(ctx).new(
|
||||
payment_register_vals)
|
||||
payments = payment_register.action_create_payments()
|
||||
|
||||
inv_sudo = inv.sudo()
|
||||
inv_sudo.invalidate_cache(['amount_residual'])
|
||||
new_residual = float(inv_sudo.amount_residual or 0.0)
|
||||
residual_map[inv.id] = new_residual
|
||||
|
||||
remaining = remaining - pay_amount
|
||||
|
||||
elif invoice_ids and not self.is_different_payment:
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in New Issue