/** * Invoked when posting of an act is complete. * * <p>This prompts to pay the account, and pops up a dialog to print the act. * * @param act the act */ @Override protected void onPosted(final FinancialAct act) { HelpContext help = getHelpContext().subtopic("post"); Tasks tasks = new Tasks(help); TaskContext context = new DefaultTaskContext(getContext(), help); context.addObject(act); String shortName = act.getArchetypeId().getShortName(); BigDecimal total = act.getTotal(); if (TypeHelper.isA(act, INVOICE, COUNTER)) { PaymentWorkflow payment = new PaymentWorkflow(total, getContext(), help); payment.setRequired(false); tasks.addTask(payment); // need to reload the act as it may be changed via the payment // workflow as part of the CustomerAccountRules tasks.addTask(new ReloadTask(shortName)); tasks.addTaskListener( new DefaultTaskListener() { public void taskEvent(TaskEvent event) { // force a refresh so the summary updates onRefresh(act); } }); } PrintActTask print = new PrintActTask(shortName, getMailContext()); print.setRequired(false); print.setEnableSkip(false); tasks.addTask(print); tasks.start(context); }
/** * Returns a <tt>MonetaryTotalType</tt> for an order. * * @param order the order * @param currency the currency * @return the corresponding <tt>MonetaryTotalType</tt> */ private MonetaryTotalType getMonetaryTotal(FinancialAct order, Currency currency) { BigDecimal payableAmount = order.getTotal(); BigDecimal lineExtensionAmount = payableAmount.subtract(order.getTaxAmount()); MonetaryTotalType result = new MonetaryTotalType(); result.setLineExtensionAmount( UBLHelper.initAmount(new LineExtensionAmountType(), lineExtensionAmount, currency)); result.setPayableAmount(UBLHelper.initAmount(new PayableAmountType(), payableAmount, currency)); return result; }
/** * Helper to create a POSTED <em>act.supplierOrder</em> and corresponding * <em>act.supplierOrderItem</em>. * * @param amount the act total * @param supplier the supplier * @param stockLocation the stockLocation * @param product the product * @return a list containing the invoice act and its item */ public static List<FinancialAct> createOrder( BigDecimal amount, Party supplier, Party stockLocation, Product product) { FinancialAct act = (FinancialAct) create(SupplierArchetypes.ORDER); act.setStatus(OrderStatus.POSTED); FinancialAct item = createItem( SupplierArchetypes.ORDER_ITEM, product, BigDecimal.ONE, 1, PACKAGE_UNITS, amount, amount); ActBean bean = new ActBean(act); bean.addNodeParticipation("supplier", supplier); bean.addNodeParticipation("stockLocation", stockLocation); bean.addRelationship(SupplierArchetypes.ORDER_ITEM_RELATIONSHIP, item); bean.setValue("amount", item.getTotal()); return Arrays.asList(act, item); }